1dnl Copyright (C) 2001-2017 Peter Selinger. 2dnl This file is part of Potrace. It is free software and it is covered 3dnl by the GNU General Public License. See the file COPYING for details. 4 5dnl Process this file with autoconf to produce a configure script. 6 7dnl ---------------------------------------------------------------------- 8dnl Package info 9AC_INIT([potrace],[1.14],[selinger at users.sourceforge.net]) 10AC_CONFIG_SRCDIR(src/trace.c) 11AM_INIT_AUTOMAKE 12AC_CONFIG_HEADER(config.h) 13AC_CONFIG_MACRO_DIR([m4]) 14 15DATE="February 2017" 16 17dnl ---------------------------------------------------------------------- 18dnl The names of the installed executables are defined here, but 19dnl should not normally be changed. 20 21POTRACE=potrace 22AC_DEFINE_UNQUOTED(POTRACE,"$POTRACE",Name of the potrace binary) 23 24MKBITMAP=mkbitmap 25AC_DEFINE_UNQUOTED(MKBITMAP,"$MKBITMAP",Name of the mkbitmap binary) 26 27dnl ---------------------------------------------------------------------- 28dnl figure out compiler options 29 30dnl Check for compiler 31AC_PROG_CC([clang gcc cc c99 mgcc c89 pcc opencc sunc99 suncc]) 32 33dnl Also add CADD to the CFLAGS at configure time or compile time 34AC_SUBST(CADD) 35 36AC_MSG_CHECKING(what compiler options to use) 37AC_MSG_RESULT($CFLAGS $CADD) 38 39dnl ---------------------------------------------------------------------- 40dnl check if --with-libpotrace was given - this must be done 41dnl before LT_INIT so that we can avoid building shared libraries 42dnl when they are not going to be installed. 43 44AC_ARG_WITH(libpotrace, 45 AS_HELP_STRING([--with-libpotrace],[install Potrace library and headers [default=no]])) 46 47if test "$with_libpotrace" != yes; then 48 enable_shared=no 49fi 50 51dnl ---------------------------------------------------------------------- 52dnl Figure out how to build libraries 53 54AC_LIBTOOL_WIN32_DLL 55LT_INIT 56 57dnl ---------------------------------------------------------------------- 58dnl Figure out whether to install libraries (default: no) 59 60AC_MSG_CHECKING(whether to install the Potrace library) 61if test "$with_libpotrace" = yes; then 62 AC_MSG_RESULT(yes) 63 INSTLIBS="libpotrace.la" 64 INSTHEADERS="potracelib.h" 65else 66 AC_MSG_RESULT(no) 67fi 68AC_SUBST(INSTLIBS) 69AC_SUBST(INSTHEADERS) 70 71dnl ---------------------------------------------------------------------- 72dnl check for compiler bugs. 73 74dnl The GCC compiler used to have a loop optimization bug that affected 75dnl potrace. This bug had been present since gcc-2.X and was still 76dnl pending (as of gcc version 3.3.1). Since the presence of this bug 77dnl cannot be reliably tested, and I am not sure in which version it was 78dnl fixed, we simply assume (conservatively) that all gcc compilers may 79dnl have this bug. In future: add a test that checks the compiler 80dnl version. 81 82if test "$GCC" = "yes"; then 83 AC_MSG_CHECKING([whether gcc has bug number 12243]) 84 AC_DEFINE(HAVE_GCC_LOOP_BUG,, [Does the C compiler have gcc bug 12243?]) 85 AC_MSG_RESULT(maybe) 86fi 87 88dnl ---------------------------------------------------------------------- 89dnl check for features 90 91AC_MSG_CHECKING(whether to use zlib) 92AC_ARG_ENABLE(zlib, 93 AS_HELP_STRING([--disable-zlib],[disable PostScript level 3 compression])) 94if test "$enable_zlib" != no; then 95 AC_DEFINE(HAVE_ZLIB,, Do we have the zlib library?) 96 AC_MSG_RESULT(yes) 97else 98 AC_MSG_RESULT(no) 99fi 100 101dnl Set optional defaults 102AC_MSG_CHECKING(whether to default to metric units) 103AC_ARG_ENABLE(metric, 104 AS_HELP_STRING([--enable-metric],[use metric units (centimeters) as default])) 105if test "$enable_metric" = yes; then 106 AC_DEFINE(USE_METRIC,, Use metric units by default?) 107 AC_MSG_RESULT(yes) 108else 109 AC_MSG_RESULT(no) 110fi 111 112AC_MSG_CHECKING(whether to default to a4 paper size) 113AC_ARG_ENABLE(a4, 114 AS_HELP_STRING([--enable-a4],[use a4 as the default papersize])) 115if test "$enable_a4" = yes; then 116 AC_DEFINE(USE_A4,, Use a4 papersize by default?) 117 AC_MSG_RESULT(yes) 118else 119 AC_MSG_RESULT(no) 120fi 121 122AC_MSG_CHECKING(whether to use the simplified progress bar) 123AC_ARG_ENABLE(dumb-tty, 124 AS_HELP_STRING([--enable-dumb-tty], [use simplified ASCII-only progress bar])) 125dumb_tty="$enable_dumb_tty" 126if test -z "$dumb_tty"; then 127 AC_CANONICAL_HOST 128 if test "$host_os" = "mingw32"; then 129 dumb_tty="yes" 130 fi 131fi 132if test "$dumb_tty" = "yes"; then 133 AC_DEFINE(DUMB_TTY,, Use the simplified progress bar?) 134 AC_MSG_RESULT(yes) 135else 136 AC_MSG_RESULT(no) 137fi 138 139dnl ---------------------------------------------------------------------- 140dnl Calculate value of "prefix", to aid guessing of include file and 141dnl library locations. 142 143USERPREFIX="$prefix" 144if test "$USERPREFIX" = "NONE"; then 145 USERPREFIX="$ac_default_prefix" 146fi 147 148dnl ---------------------------------------------------------------------- 149dnl Check for header files 150 151if test "$enable_zlib" != no; then 152 AC_CHECK_HEADER(zlib.h, true, 153 [AC_MSG_WARN([zlib.h not found in standard location. 154Trying again with -I$USERPREFIX/include]) 155 CPPFLAGS="$CPPFLAGS -I$USERPREFIX/include" 156 dnl need to unset cached value to repeat the test 157 unset ac_cv_header_zlib_h 158 AC_CHECK_HEADER(zlib.h, true, 159 [AC_MSG_ERROR([cannot find zlib.h. 160Rerun ./configure with CPPFLAGS=-I<include dir> if you have the header 161file in a non-standard directory, or with --disable-zlib to disable 162support for PostScript level 3 compression.]) 163 ]) 164 ]) 165fi 166 167dnl ---------------------------------------------------------------------- 168dnl Check for symbols 169AC_CHECK_DECL(M_PI, , 170 AC_DEFINE(M_PI, 3.14159265358979323846, [Define if missing from math.h]), 171 [#include <math.h>]) 172 173dnl ---------------------------------------------------------------------- 174dnl Check for libraries 175 176if test "$enable_zlib" != no; then 177 AC_CHECK_LIB(z, deflate, EXTRA_LIBS="$EXTRA_LIBS -lz", 178 [AC_MSG_WARN([libz library not found in standard location. 179Trying again with -L$USERPREFIX/lib]) 180 LDFLAGS="$LDFLAGS -L$USERPREFIX/lib" 181 dnl need to unset cached value to repeat the test 182 unset ac_cv_lib_z_deflate 183 AC_CHECK_LIB(z, deflate, EXTRA_LIBS="$EXTRA_LIBS -lz", 184 [AC_MSG_ERROR([cannot find the libz library (-lz). 185Rerun ./configure with LDFLAGS=-L<lib dir> if you have the library in 186a non-standard directory, or with --disable-zlib to disable support 187for PostScript level 3 compression.]) 188 ]) 189 ]) 190fi 191 192AC_CHECK_LIB(m, floor, true, AC_MSG_ERROR([cannot find the m library (-lm)])) 193 194dnl ---------------------------------------------------------------------- 195dnl Check for library functions. 196 197dnl Check for getopt_long 198AC_CHECK_FUNC(getopt_long, have_getopt_long=yes, have_getopt_long=no) 199if test "$have_getopt_long" = "yes"; then 200 dnl Check whether getopt_long reorders its arguments 201 AC_MSG_CHECKING([whether getopt_long reorders its arguments]) 202 AC_RUN_IFELSE([AC_LANG_PROGRAM( 203 [[ #include <getopt.h> 204 static struct option longopts[] = { 205 {"help", 0, 0, 'h'}, 206 {0, 0, 0, 0} 207 }; 208 ]], 209 [[ int ac = 3; 210 char *av[] = { "main", "file", "-h" }; 211 return 'h' == getopt_long(ac, av, "h", longopts, (int *)0) ? 0 : 1; 212 ]])], 213 [AC_MSG_RESULT(yes)], 214 [AC_MSG_RESULT(no) 215 have_getopt_long=no], 216 [AC_MSG_RESULT(maybe (cross-compiling)) 217 have_getopt_long=no]) 218fi 219if test "$have_getopt_long" != "yes"; then 220 EXTRA_OBJS="$EXTRA_OBJS getopt.o getopt1.o" 221fi 222 223AC_CHECK_FUNC(strcasecmp, , 224 [AC_CHECK_FUNC(stricmp, 225 [AC_DEFINE_UNQUOTED(strcasecmp, stricmp, [Replacement function for strcasecmp])], 226 [AC_MSG_ERROR([cannot find a replacement for strcasecmp])] 227 )] 228) 229AC_CHECK_FUNC(strncasecmp, , 230 [AC_CHECK_FUNC(strnicmp, 231 [AC_DEFINE_UNQUOTED(strncasecmp, strnicmp, [Replacement function for strncasecmp])], 232 [AC_MSG_ERROR([cannot find a replacement for strncasecmp])] 233 )] 234) 235 236dnl ---------------------------------------------------------------------- 237dnl Check whether we have i386 features 238AC_MSG_CHECKING([for Intel 386]) 239AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int x; 240 asm("bsf %1,%0\njnz 0f\nmovl $32,%0\n0:":"=r"(x):"r"(x)); 241 return x; /* need this so that -O2 does not optimize the asm away */ 242]])],[AC_MSG_RESULT(yes) 243 AC_DEFINE(HAVE_I386,, Can we use Intel 386 optimizations?) 244],[AC_MSG_RESULT(no)]) 245 246 247dnl ---------------------------------------------------------------------- 248dnl Check whether compiler supports inlining 249 250AC_C_INLINE 251 252dnl ---------------------------------------------------------------------- 253dnl Set up substitutions of non-standard configuration parameters 254AC_SUBST(DATE) 255AC_SUBST(POTRACE) 256AC_SUBST(MKBITMAP) 257AC_SUBST(EXTRA_OBJS) 258AC_SUBST(EXTRA_LIBS) 259AC_SUBST(AM_CPPFLAGS) 260AC_SUBST(POTRACELIB_VERSION) 261 262dnl ---------------------------------------------------------------------- 263AC_CONFIG_FILES([Makefile 264 src/Makefile 265 doc/Makefile 266 check/Makefile 267 doc/potrace.1 268 doc/mkbitmap.1 269 ]) 270AC_OUTPUT 271