xref: /potrace-1.14/configure.ac (revision b3fce824)
1*b3fce824SCristian Pallarésdnl Copyright (C) 2001-2017 Peter Selinger.
2189777a2SCristian Pallaresdnl This file is part of Potrace. It is free software and it is covered
3189777a2SCristian Pallaresdnl by the GNU General Public License. See the file COPYING for details.
4189777a2SCristian Pallares
5189777a2SCristian Pallaresdnl Process this file with autoconf to produce a configure script.
6189777a2SCristian Pallares
7189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
8189777a2SCristian Pallaresdnl Package info
9*b3fce824SCristian PallarésAC_INIT([potrace],[1.14],[selinger at users.sourceforge.net])
10189777a2SCristian PallaresAC_CONFIG_SRCDIR(src/trace.c)
11189777a2SCristian PallaresAM_INIT_AUTOMAKE
12189777a2SCristian PallaresAC_CONFIG_HEADER(config.h)
13189777a2SCristian PallaresAC_CONFIG_MACRO_DIR([m4])
14189777a2SCristian Pallares
15*b3fce824SCristian PallarésDATE="February 2017"
16189777a2SCristian Pallares
17189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
18189777a2SCristian Pallaresdnl The names of the installed executables are defined here, but
19189777a2SCristian Pallaresdnl should not normally be changed.
20189777a2SCristian Pallares
21189777a2SCristian PallaresPOTRACE=potrace
22189777a2SCristian PallaresAC_DEFINE_UNQUOTED(POTRACE,"$POTRACE",Name of the potrace binary)
23189777a2SCristian Pallares
24189777a2SCristian PallaresMKBITMAP=mkbitmap
25189777a2SCristian PallaresAC_DEFINE_UNQUOTED(MKBITMAP,"$MKBITMAP",Name of the mkbitmap binary)
26189777a2SCristian Pallares
27189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
28189777a2SCristian Pallaresdnl figure out compiler options
29189777a2SCristian Pallares
30189777a2SCristian Pallaresdnl Check for compiler
31*b3fce824SCristian PallarésAC_PROG_CC([clang gcc cc c99 mgcc c89 pcc opencc sunc99 suncc])
32189777a2SCristian Pallares
33189777a2SCristian Pallaresdnl Also add CADD to the CFLAGS at configure time or compile time
34189777a2SCristian PallaresAC_SUBST(CADD)
35189777a2SCristian Pallares
36189777a2SCristian PallaresAC_MSG_CHECKING(what compiler options to use)
37189777a2SCristian PallaresAC_MSG_RESULT($CFLAGS $CADD)
38189777a2SCristian Pallares
39189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
40189777a2SCristian Pallaresdnl check if --with-libpotrace was given - this must be done
41189777a2SCristian Pallaresdnl before LT_INIT so that we can avoid building shared libraries
42189777a2SCristian Pallaresdnl when they are not going to be installed.
43189777a2SCristian Pallares
44189777a2SCristian PallaresAC_ARG_WITH(libpotrace,
45189777a2SCristian Pallares AS_HELP_STRING([--with-libpotrace],[install Potrace library and headers [default=no]]))
46189777a2SCristian Pallares
47189777a2SCristian Pallaresif test "$with_libpotrace" != yes; then
48189777a2SCristian Pallares enable_shared=no
49189777a2SCristian Pallaresfi
50189777a2SCristian Pallares
51189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
52189777a2SCristian Pallaresdnl Figure out how to build libraries
53189777a2SCristian Pallares
54189777a2SCristian PallaresAC_LIBTOOL_WIN32_DLL
55189777a2SCristian PallaresLT_INIT
56189777a2SCristian Pallares
57189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
58189777a2SCristian Pallaresdnl Figure out whether to install libraries (default: no)
59189777a2SCristian Pallares
60189777a2SCristian PallaresAC_MSG_CHECKING(whether to install the Potrace library)
61189777a2SCristian Pallaresif test "$with_libpotrace" = yes; then
62189777a2SCristian Pallares AC_MSG_RESULT(yes)
63189777a2SCristian Pallares INSTLIBS="libpotrace.la"
64189777a2SCristian Pallares INSTHEADERS="potracelib.h"
65189777a2SCristian Pallareselse
66189777a2SCristian Pallares AC_MSG_RESULT(no)
67189777a2SCristian Pallaresfi
68189777a2SCristian PallaresAC_SUBST(INSTLIBS)
69189777a2SCristian PallaresAC_SUBST(INSTHEADERS)
70189777a2SCristian Pallares
71189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
72189777a2SCristian Pallaresdnl check for compiler bugs.
73189777a2SCristian Pallares
74189777a2SCristian Pallaresdnl The GCC compiler used to have a loop optimization bug that affected
75189777a2SCristian Pallaresdnl potrace.  This bug had been present since gcc-2.X and was still
76189777a2SCristian Pallaresdnl pending (as of gcc version 3.3.1). Since the presence of this bug
77189777a2SCristian Pallaresdnl cannot be reliably tested, and I am not sure in which version it was
78189777a2SCristian Pallaresdnl fixed, we simply assume (conservatively) that all gcc compilers may
79189777a2SCristian Pallaresdnl have this bug. In future: add a test that checks the compiler
80189777a2SCristian Pallaresdnl version.
81189777a2SCristian Pallares
82189777a2SCristian Pallaresif test "$GCC" = "yes"; then
83189777a2SCristian Pallares  AC_MSG_CHECKING([whether gcc has bug number 12243])
84189777a2SCristian Pallares  AC_DEFINE(HAVE_GCC_LOOP_BUG,, [Does the C compiler have gcc bug 12243?])
85189777a2SCristian Pallares  AC_MSG_RESULT(maybe)
86189777a2SCristian Pallaresfi
87189777a2SCristian Pallares
88189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
89189777a2SCristian Pallaresdnl check for features
90189777a2SCristian Pallares
91189777a2SCristian PallaresAC_MSG_CHECKING(whether to use zlib)
92189777a2SCristian PallaresAC_ARG_ENABLE(zlib,
93189777a2SCristian Pallares AS_HELP_STRING([--disable-zlib],[disable PostScript level 3 compression]))
94189777a2SCristian Pallaresif test "$enable_zlib" != no; then
95189777a2SCristian Pallares  AC_DEFINE(HAVE_ZLIB,, Do we have the zlib library?)
96189777a2SCristian Pallares  AC_MSG_RESULT(yes)
97189777a2SCristian Pallareselse
98189777a2SCristian Pallares  AC_MSG_RESULT(no)
99189777a2SCristian Pallaresfi
100189777a2SCristian Pallares
101189777a2SCristian Pallaresdnl Set optional defaults
102189777a2SCristian PallaresAC_MSG_CHECKING(whether to default to metric units)
103189777a2SCristian PallaresAC_ARG_ENABLE(metric,
104189777a2SCristian Pallares AS_HELP_STRING([--enable-metric],[use metric units (centimeters) as default]))
105189777a2SCristian Pallaresif test "$enable_metric" = yes; then
106189777a2SCristian Pallares  AC_DEFINE(USE_METRIC,, Use metric units by default?)
107189777a2SCristian Pallares  AC_MSG_RESULT(yes)
108189777a2SCristian Pallareselse
109189777a2SCristian Pallares  AC_MSG_RESULT(no)
110189777a2SCristian Pallaresfi
111189777a2SCristian Pallares
112189777a2SCristian PallaresAC_MSG_CHECKING(whether to default to a4 paper size)
113189777a2SCristian PallaresAC_ARG_ENABLE(a4,
114189777a2SCristian Pallares AS_HELP_STRING([--enable-a4],[use a4 as the default papersize]))
115189777a2SCristian Pallaresif test "$enable_a4" = yes; then
116189777a2SCristian Pallares  AC_DEFINE(USE_A4,, Use a4 papersize by default?)
117189777a2SCristian Pallares  AC_MSG_RESULT(yes)
118189777a2SCristian Pallareselse
119189777a2SCristian Pallares  AC_MSG_RESULT(no)
120189777a2SCristian Pallaresfi
121189777a2SCristian Pallares
122189777a2SCristian PallaresAC_MSG_CHECKING(whether to use the simplified progress bar)
123189777a2SCristian PallaresAC_ARG_ENABLE(dumb-tty,
124189777a2SCristian Pallares AS_HELP_STRING([--enable-dumb-tty], [use simplified ASCII-only progress bar]))
125189777a2SCristian Pallaresdumb_tty="$enable_dumb_tty"
126189777a2SCristian Pallaresif test -z "$dumb_tty"; then
127189777a2SCristian Pallares   AC_CANONICAL_HOST
128189777a2SCristian Pallares   if test "$host_os" = "mingw32"; then
129189777a2SCristian Pallares      dumb_tty="yes"
130189777a2SCristian Pallares   fi
131189777a2SCristian Pallaresfi
132189777a2SCristian Pallaresif test "$dumb_tty" = "yes"; then
133189777a2SCristian Pallares  AC_DEFINE(DUMB_TTY,, Use the simplified progress bar?)
134189777a2SCristian Pallares  AC_MSG_RESULT(yes)
135189777a2SCristian Pallareselse
136189777a2SCristian Pallares  AC_MSG_RESULT(no)
137189777a2SCristian Pallaresfi
138189777a2SCristian Pallares
139189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
140189777a2SCristian Pallaresdnl Calculate value of "prefix", to aid guessing of include file and
141189777a2SCristian Pallaresdnl library locations.
142189777a2SCristian Pallares
143189777a2SCristian PallaresUSERPREFIX="$prefix"
144189777a2SCristian Pallaresif test "$USERPREFIX" = "NONE"; then
145189777a2SCristian Pallares   USERPREFIX="$ac_default_prefix"
146189777a2SCristian Pallaresfi
147189777a2SCristian Pallares
148189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
149189777a2SCristian Pallaresdnl Check for header files
150189777a2SCristian Pallares
151189777a2SCristian Pallaresif test "$enable_zlib" != no; then
152189777a2SCristian Pallares  AC_CHECK_HEADER(zlib.h, true,
153189777a2SCristian Pallares    [AC_MSG_WARN([zlib.h not found in standard location.
154189777a2SCristian PallaresTrying again with -I$USERPREFIX/include])
155189777a2SCristian Pallares    CPPFLAGS="$CPPFLAGS -I$USERPREFIX/include"
156189777a2SCristian Pallares    dnl need to unset cached value to repeat the test
157189777a2SCristian Pallares    unset ac_cv_header_zlib_h
158189777a2SCristian Pallares    AC_CHECK_HEADER(zlib.h, true,
159189777a2SCristian Pallares      [AC_MSG_ERROR([cannot find zlib.h.
160189777a2SCristian PallaresRerun ./configure with CPPFLAGS=-I<include dir> if you have the header
161189777a2SCristian Pallaresfile in a non-standard directory, or with --disable-zlib to disable
162189777a2SCristian Pallaressupport for PostScript level 3 compression.])
163189777a2SCristian Pallares    ])
164189777a2SCristian Pallares  ])
165189777a2SCristian Pallaresfi
166189777a2SCristian Pallares
167189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
168189777a2SCristian Pallaresdnl Check for symbols
169189777a2SCristian PallaresAC_CHECK_DECL(M_PI, ,
170189777a2SCristian Pallares AC_DEFINE(M_PI, 3.14159265358979323846, [Define if missing from math.h]),
171189777a2SCristian Pallares [#include <math.h>])
172189777a2SCristian Pallares
173189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
174189777a2SCristian Pallaresdnl Check for libraries
175189777a2SCristian Pallares
176189777a2SCristian Pallaresif test "$enable_zlib" != no; then
177189777a2SCristian Pallares  AC_CHECK_LIB(z, deflate, EXTRA_LIBS="$EXTRA_LIBS -lz",
178189777a2SCristian Pallares    [AC_MSG_WARN([libz library not found in standard location.
179189777a2SCristian PallaresTrying again with -L$USERPREFIX/lib])
180189777a2SCristian Pallares    LDFLAGS="$LDFLAGS -L$USERPREFIX/lib"
181189777a2SCristian Pallares    dnl need to unset cached value to repeat the test
182189777a2SCristian Pallares    unset ac_cv_lib_z_deflate
183189777a2SCristian Pallares    AC_CHECK_LIB(z, deflate, EXTRA_LIBS="$EXTRA_LIBS -lz",
184189777a2SCristian Pallares      [AC_MSG_ERROR([cannot find the libz library (-lz).
185189777a2SCristian PallaresRerun ./configure with LDFLAGS=-L<lib dir> if you have the library in
186189777a2SCristian Pallaresa non-standard directory, or with --disable-zlib to disable support
187189777a2SCristian Pallaresfor PostScript level 3 compression.])
188189777a2SCristian Pallares    ])
189189777a2SCristian Pallares  ])
190189777a2SCristian Pallaresfi
191189777a2SCristian Pallares
192189777a2SCristian PallaresAC_CHECK_LIB(m, floor, true, AC_MSG_ERROR([cannot find the m library (-lm)]))
193189777a2SCristian Pallares
194189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
195189777a2SCristian Pallaresdnl Check for library functions.
196189777a2SCristian Pallares
197189777a2SCristian Pallaresdnl Check for getopt_long
198189777a2SCristian PallaresAC_CHECK_FUNC(getopt_long, have_getopt_long=yes, have_getopt_long=no)
199189777a2SCristian Pallaresif test "$have_getopt_long" = "yes"; then
200189777a2SCristian Pallares   dnl Check whether getopt_long reorders its arguments
201189777a2SCristian Pallares   AC_MSG_CHECKING([whether getopt_long reorders its arguments])
202189777a2SCristian Pallares   AC_RUN_IFELSE([AC_LANG_PROGRAM(
203189777a2SCristian Pallares   [[ #include <getopt.h>
204189777a2SCristian Pallares      static struct option longopts[] = {
205189777a2SCristian Pallares        {"help", 0, 0, 'h'},
206189777a2SCristian Pallares	{0, 0, 0, 0}
207189777a2SCristian Pallares      };
208189777a2SCristian Pallares   ]],
209189777a2SCristian Pallares   [[ int ac = 3;
210189777a2SCristian Pallares      char *av[] = { "main", "file", "-h" };
211189777a2SCristian Pallares      return 'h' == getopt_long(ac, av, "h", longopts, (int *)0) ? 0 : 1;
212189777a2SCristian Pallares   ]])],
213189777a2SCristian Pallares   [AC_MSG_RESULT(yes)],
214189777a2SCristian Pallares   [AC_MSG_RESULT(no)
215189777a2SCristian Pallares   have_getopt_long=no],
216189777a2SCristian Pallares   [AC_MSG_RESULT(maybe (cross-compiling))
217189777a2SCristian Pallares   have_getopt_long=no])
218189777a2SCristian Pallaresfi
219189777a2SCristian Pallaresif test "$have_getopt_long" != "yes"; then
220189777a2SCristian Pallares   EXTRA_OBJS="$EXTRA_OBJS getopt.o getopt1.o"
221189777a2SCristian Pallaresfi
222189777a2SCristian Pallares
223189777a2SCristian PallaresAC_CHECK_FUNC(strcasecmp, ,
224189777a2SCristian Pallares  [AC_CHECK_FUNC(stricmp,
225189777a2SCristian Pallares    [AC_DEFINE_UNQUOTED(strcasecmp, stricmp, [Replacement function for strcasecmp])],
226189777a2SCristian Pallares    [AC_MSG_ERROR([cannot find a replacement for strcasecmp])]
227189777a2SCristian Pallares  )]
228189777a2SCristian Pallares)
229189777a2SCristian PallaresAC_CHECK_FUNC(strncasecmp, ,
230189777a2SCristian Pallares  [AC_CHECK_FUNC(strnicmp,
231189777a2SCristian Pallares    [AC_DEFINE_UNQUOTED(strncasecmp, strnicmp, [Replacement function for strncasecmp])],
232189777a2SCristian Pallares    [AC_MSG_ERROR([cannot find a replacement for strncasecmp])]
233189777a2SCristian Pallares  )]
234189777a2SCristian Pallares)
235189777a2SCristian Pallares
236189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
237189777a2SCristian Pallaresdnl Check whether we have i386 features
238189777a2SCristian PallaresAC_MSG_CHECKING([for Intel 386])
239189777a2SCristian PallaresAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int x;
240189777a2SCristian Pallares  asm("bsf %1,%0\njnz 0f\nmovl $32,%0\n0:":"=r"(x):"r"(x));
241189777a2SCristian Pallares  return x; /* need this so that -O2 does not optimize the asm away */
242189777a2SCristian Pallares]])],[AC_MSG_RESULT(yes)
243189777a2SCristian Pallares AC_DEFINE(HAVE_I386,, Can we use Intel 386 optimizations?)
244189777a2SCristian Pallares],[AC_MSG_RESULT(no)])
245189777a2SCristian Pallares
246189777a2SCristian Pallares
247189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
248189777a2SCristian Pallaresdnl Check whether compiler supports inlining
249189777a2SCristian Pallares
250189777a2SCristian PallaresAC_C_INLINE
251189777a2SCristian Pallares
252189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
253189777a2SCristian Pallaresdnl Set up substitutions of non-standard configuration parameters
254189777a2SCristian PallaresAC_SUBST(DATE)
255189777a2SCristian PallaresAC_SUBST(POTRACE)
256189777a2SCristian PallaresAC_SUBST(MKBITMAP)
257189777a2SCristian PallaresAC_SUBST(EXTRA_OBJS)
258189777a2SCristian PallaresAC_SUBST(EXTRA_LIBS)
2591f13f311SSkyrpexAC_SUBST(AM_CPPFLAGS)
260189777a2SCristian PallaresAC_SUBST(POTRACELIB_VERSION)
261189777a2SCristian Pallares
262189777a2SCristian Pallaresdnl ----------------------------------------------------------------------
263189777a2SCristian PallaresAC_CONFIG_FILES([Makefile
264189777a2SCristian Pallares	   src/Makefile
265189777a2SCristian Pallares	   doc/Makefile
266189777a2SCristian Pallares	   check/Makefile
267189777a2SCristian Pallares	   doc/potrace.1
268189777a2SCristian Pallares	   doc/mkbitmap.1
269189777a2SCristian Pallares          ])
270189777a2SCristian PallaresAC_OUTPUT
271