summaryrefslogtreecommitdiff
path: root/Build/source/libs/potrace/potrace-1.12/configure.ac
blob: b0ecb2a18d72690d5308a7340a9dc0d5c97b560e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
dnl Copyright (C) 2001-2015 Peter Selinger.
dnl This file is part of Potrace. It is free software and it is covered
dnl by the GNU General Public License. See the file COPYING for details.

dnl Process this file with autoconf to produce a configure script.

dnl ----------------------------------------------------------------------
dnl Package info
AC_INIT([potrace],[1.12],[selinger at users.sourceforge.net])
AC_CONFIG_SRCDIR(src/trace.c)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])

DATE="March 2015"

dnl ----------------------------------------------------------------------
dnl The names of the installed executables are defined here, but
dnl should not normally be changed.

POTRACE=potrace
AC_DEFINE_UNQUOTED(POTRACE,"$POTRACE",Name of the potrace binary)

MKBITMAP=mkbitmap
AC_DEFINE_UNQUOTED(MKBITMAP,"$MKBITMAP",Name of the mkbitmap binary)

dnl ----------------------------------------------------------------------
dnl figure out compiler options

dnl remember user's CFLAGS, if any
iCFLAGS="$CFLAGS"

dnl Check for compiler
AC_PROG_CC

dnl If compiler is gcc, add our own default CFLAGS if no others specified
if test "$GCC" = "yes" && test "$iCFLAGS" = ""; then
  CFLAGS="$CFLAGS -Wall -ffloat-store"
fi

dnl Also add CADD to the CFLAGS at configure time or compile time
AC_SUBST(CADD)

AC_MSG_CHECKING(what compiler options to use)
AC_MSG_RESULT($CFLAGS $CADD)

dnl ----------------------------------------------------------------------
dnl check if --with-libpotrace was given - this must be done
dnl before LT_INIT so that we can avoid building shared libraries
dnl when they are not going to be installed.

AC_ARG_WITH(libpotrace,
 AS_HELP_STRING([--with-libpotrace],[install Potrace library and headers [default=no]]))

if test "$with_libpotrace" != yes; then
 enable_shared=no
fi

dnl ----------------------------------------------------------------------
dnl Figure out how to build libraries

AC_LIBTOOL_WIN32_DLL
LT_INIT

dnl ----------------------------------------------------------------------
dnl Figure out whether to install libraries (default: no)

AC_MSG_CHECKING(whether to install the Potrace library)
if test "$with_libpotrace" = yes; then
 AC_MSG_RESULT(yes)
 INSTLIBS="libpotrace.la"
 INSTHEADERS="potracelib.h"
else
 AC_MSG_RESULT(no)
fi
AC_SUBST(INSTLIBS)
AC_SUBST(INSTHEADERS)

dnl ----------------------------------------------------------------------
dnl check for compiler bugs. 

dnl The GCC compiler used to have a loop optimization bug that affected
dnl potrace.  This bug had been present since gcc-2.X and was still
dnl pending (as of gcc version 3.3.1). Since the presence of this bug
dnl cannot be reliably tested, and I am not sure in which version it was
dnl fixed, we simply assume (conservatively) that all gcc compilers may
dnl have this bug. In future: add a test that checks the compiler
dnl version.

if test "$GCC" = "yes"; then 
  AC_MSG_CHECKING([whether gcc has bug number 12243])
  AC_DEFINE(HAVE_GCC_LOOP_BUG,, [Does the C compiler have gcc bug 12243?])
  AC_MSG_RESULT(maybe)
fi

dnl ----------------------------------------------------------------------
dnl check for features

AC_MSG_CHECKING(whether to use zlib)
AC_ARG_ENABLE(zlib,
 AS_HELP_STRING([--disable-zlib],[disable PostScript level 3 compression]))
if test "$enable_zlib" != no; then
  AC_DEFINE(HAVE_ZLIB,, Do we have the zlib library?)
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

dnl Set optional defaults
AC_MSG_CHECKING(whether to default to metric units)
AC_ARG_ENABLE(metric, 
 AS_HELP_STRING([--enable-metric],[use metric units (centimeters) as default]))
if test "$enable_metric" = yes; then
  AC_DEFINE(USE_METRIC,, Use metric units by default?)
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(whether to default to a4 paper size)
AC_ARG_ENABLE(a4, 
 AS_HELP_STRING([--enable-a4],[use a4 as the default papersize]))
if test "$enable_a4" = yes; then
  AC_DEFINE(USE_A4,, Use a4 papersize by default?)
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(whether to use the simplified progress bar)
AC_ARG_ENABLE(dumb-tty,
 AS_HELP_STRING([--enable-dumb-tty], [use simplified ASCII-only progress bar]))
dumb_tty="$enable_dumb_tty"
if test -z "$dumb_tty"; then
   AC_CANONICAL_HOST
   if test "$host_os" = "mingw32"; then
      dumb_tty="yes"
   fi
fi
if test "$dumb_tty" = "yes"; then
  AC_DEFINE(DUMB_TTY,, Use the simplified progress bar?)
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

dnl ----------------------------------------------------------------------
dnl Calculate value of "prefix", to aid guessing of include file and
dnl library locations.

USERPREFIX="$prefix"
if test "$USERPREFIX" = "NONE"; then
   USERPREFIX="$ac_default_prefix"
fi

dnl ----------------------------------------------------------------------
dnl Check for header files

if test "$enable_zlib" != no; then
  AC_CHECK_HEADER(zlib.h, true,
    [AC_MSG_WARN([zlib.h not found in standard location.
Trying again with -I$USERPREFIX/include])
    CPPFLAGS="$CPPFLAGS -I$USERPREFIX/include"
    dnl need to unset cached value to repeat the test
    unset ac_cv_header_zlib_h
    AC_CHECK_HEADER(zlib.h, true, 
      [AC_MSG_ERROR([cannot find zlib.h. 
Rerun ./configure with CPPFLAGS=-I<include dir> if you have the header
file in a non-standard directory, or with --disable-zlib to disable
support for PostScript level 3 compression.])
    ])
  ])
fi

dnl ----------------------------------------------------------------------
dnl Check for symbols
AC_CHECK_DECL(M_PI, ,
 AC_DEFINE(M_PI, 3.14159265358979323846, [Define if missing from math.h]),
 [#include <math.h>])

dnl ----------------------------------------------------------------------
dnl Check for libraries

if test "$enable_zlib" != no; then
  AC_CHECK_LIB(z, deflate, EXTRA_LIBS="$EXTRA_LIBS -lz", 
    [AC_MSG_WARN([libz library not found in standard location.
Trying again with -L$USERPREFIX/lib])
    LDFLAGS="$LDFLAGS -L$USERPREFIX/lib"
    dnl need to unset cached value to repeat the test
    unset ac_cv_lib_z_deflate
    AC_CHECK_LIB(z, deflate, EXTRA_LIBS="$EXTRA_LIBS -lz",
      [AC_MSG_ERROR([cannot find the libz library (-lz).
Rerun ./configure with LDFLAGS=-L<lib dir> if you have the library in
a non-standard directory, or with --disable-zlib to disable support
for PostScript level 3 compression.])
    ])
  ])
fi

AC_CHECK_LIB(m, floor, true, AC_MSG_ERROR([cannot find the m library (-lm)]))

dnl ----------------------------------------------------------------------
dnl Check for library functions.

dnl Check for getopt_long
AC_CHECK_FUNC(getopt_long, have_getopt_long=yes, have_getopt_long=no)
if test "$have_getopt_long" = "yes"; then
   dnl Check whether getopt_long reorders its arguments
   AC_MSG_CHECKING([whether getopt_long reorders its arguments])
   AC_RUN_IFELSE([AC_LANG_PROGRAM(
   [[ #include <getopt.h>
      static struct option longopts[] = {
        {"help", 0, 0, 'h'},
	{0, 0, 0, 0}
      };
   ]], 
   [[ int ac = 3;
      char *av[] = { "main", "file", "-h" };
      return 'h' == getopt_long(ac, av, "h", longopts, (int *)0) ? 0 : 1;
   ]])], 
   [AC_MSG_RESULT(yes)], 
   [AC_MSG_RESULT(no)
   have_getopt_long=no],
   [AC_MSG_RESULT(maybe (cross-compiling))
   have_getopt_long=no])
fi
if test "$have_getopt_long" != "yes"; then 
   EXTRA_OBJS="$EXTRA_OBJS getopt.o getopt1.o"
fi

AC_CHECK_FUNC(strcasecmp, ,
  [AC_CHECK_FUNC(stricmp, 
    [AC_DEFINE_UNQUOTED(strcasecmp, stricmp, [Replacement function for strcasecmp])],
    [AC_MSG_ERROR([cannot find a replacement for strcasecmp])]
  )]
)
AC_CHECK_FUNC(strncasecmp, ,
  [AC_CHECK_FUNC(strnicmp, 
    [AC_DEFINE_UNQUOTED(strncasecmp, strnicmp, [Replacement function for strncasecmp])],
    [AC_MSG_ERROR([cannot find a replacement for strncasecmp])]
  )]
)

dnl ----------------------------------------------------------------------
dnl Check whether we have i386 features
AC_MSG_CHECKING([for Intel 386])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int x;
  asm("bsf %1,%0\njnz 0f\nmovl $32,%0\n0:":"=r"(x):"r"(x));
  return x; /* need this so that -O2 does not optimize the asm away */
]])],[AC_MSG_RESULT(yes) 
 AC_DEFINE(HAVE_I386,, Can we use Intel 386 optimizations?)
],[AC_MSG_RESULT(no)])	


dnl ----------------------------------------------------------------------
dnl Check whether compiler supports inlining

AC_C_INLINE

dnl ----------------------------------------------------------------------
dnl Set up substitutions of non-standard configuration parameters
AC_SUBST(DATE)
AC_SUBST(POTRACE)
AC_SUBST(MKBITMAP)
AC_SUBST(EXTRA_OBJS)
AC_SUBST(EXTRA_LIBS)
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(POTRACELIB_VERSION)

dnl ----------------------------------------------------------------------
AC_CONFIG_FILES([Makefile 
	   src/Makefile 
	   doc/Makefile
	   check/Makefile
	   doc/potrace.1
	   doc/mkbitmap.1
          ])
AC_OUTPUT