Stay in GETCOORDS if there are more coord prompts.
[geda-gaf/berndj.git] / utils / configure.ac
blobc7c9e572ab23ea0bdb0e725b79544713345f5aaf
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/gmk_sym.c])
4 AC_PREREQ(2.54)
6 PACKAGE=geda-utils
7 DOTTED_VERSION=1.5.0
8 DATE_VERSION=20080706
9 echo Configuring $PACKAGE version $DOTTED_VERSION.$DATE_VERSION
11 # Initialize automake 
12 AM_INIT_AUTOMAKE($PACKAGE, $DOTTED_VERSION, no-define)
13 AM_CONFIG_HEADER([config.h])
15 #########################################################################
16 # Command line flags start
17
18 # Change default location for rc files
19 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
21 # --with-docdir : tells where to store documentation if not default
22 # defined below 
23
24 # Command line flags end
25 #########################################################################
27 # Checks for programs.
28 AC_PROG_CC
29 AM_PROG_CC_C_O
30 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")
31 AC_PROG_CPP
32 AC_PROG_MAKE_SET
33 AM_PROG_LEX
35 AC_PATH_PROG(PERL, perl, [notfound])
36 AM_CONDITIONAL(MISSING_PERL, test x$PERL = xnotfound)
38 ##############################################################3
39 # Test for __func__
42 AC_MSG_CHECKING([For a working C99 __func__])
43 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
44         [[const char *foo = __func__;]])],
45    [ac_cv_cpp_func=yes],
46    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
47                 [[const char *foo = __FUNCTION__;]])],
48                 [ac_cv_cpp_func=__FUNCTION__],
49                 [ac_cv_cpp_func="\"no\""])]
52 if test "X$ac_cv_cpp_func" = "X__FUNCTION__"; then
53         AC_MSG_RESULT([__FUNCTION__])
54 elif test "x$ac_cv_cpp_func" = "xyes" ; then
55         AC_MSG_RESULT([__func__])
56 else
57         AC_MSG_RESULT([no])
59 if test "X$ac_cv_cpp_func" != "Xyes" ; then
60         AC_DEFINE_UNQUOTED([__func__], [$ac_cv_cpp_func], [Define to be a __func__ replacement])
64 ##############################################################3
66 #########################################################################
67
68 # Misc win32 / mingw checks and variables start
69 AC_CANONICAL_HOST
71 # Figure out if we are building on win32 and what environment.
72 case $host_os in
73   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
74 esac
76 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
77    MINGW_CFLAGS="-mms-bitfields -mwindows"
78    MINGW="yes"
79 else
80    # Unix host
81    MINGW_CFLAGS=
82    MINGW="no"
85
86 # Misc win32 / mingw checks and variables end
87 #########################################################################
89 ############################################################################
90 # Check for guile start
92 # Check for pkg-config
93 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
94 if test $PKG_CONFIG = no; then
95    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
98 PKG_CHECK_MODULES(GUILE, guile-1.8, GUILE_PC="yes", no_GUILE_PC="yes")
100 if test "$GUILE_PC" = "yes" 
101 then
103    GUILE_VERSION=`$PKG_CONFIG guile-1.8 --modversion`
105 else
107   # Find about the installed guile
108   GUILE_FLAGS
109   GUILE_VERSION=`$GUILE_CONFIG info guileversion`
113 # Check Guile version
114 guile_need_major=1
115 guile_need_minor=6
116 guile_need_version="$guile_need_major[].$guile_need_minor.0"
118 AC_MSG_CHECKING([Guile version >= $guile_need_version])
120 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
121 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
122 AC_MSG_RESULT($GUILE_VERSION)
124 if test "$guile_need_major" -gt "$guile_major" \
125    || (test "$guile_need_major" -eq "$guile_major" \
126        && test "$guile_need_minor" -gt "$guile_minor"); then
127   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
130 # Guile 1.6 compatability
132 CFLAGS_temp_save="$CFLAGS"
133 CFLAGS="$CFLAGS $GUILE_CFLAGS"
134 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
135 scm_from_int,  scm_is_true,    scm_is_false,
136 scm_from_locale_string, scm_to_locale_string],,,
137 [#include <libguile.h>])
138 CFLAGS="$CFLAGS_temp_save"
140 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
141 #  define scm_is_string(x) SCM_STRINGP(x)
142 #endif])
143 AH_VERBATIM(SCM_IS_INTEGER, [#if !HAVE_DECL_SCM_IS_INTEGER
144 #  define scm_is_integer(x) SCM_INUMP(x)
145 #endif])
146 AH_VERBATIM(SCM_TO_INT, [#if !HAVE_DECL_SCM_TO_INT
147 #  define scm_to_int(x)     SCM_INUM(x)
148 #endif])
149 AH_VERBATIM(SCM_FROM_INT, [#if !HAVE_DECL_SCM_FROM_INT
150 #  define scm_from_int(x)   SCM_MAKINUM(x)
151 #endif])
152 AH_VERBATIM(SCM_IS_TRUE, [#if !HAVE_DECL_SCM_IS_TRUE
153 #  define scm_is_true(x)    SCM_NFALSEP(x)
154 #endif])
155 AH_VERBATIM(SCM_IS_FALSE, [#if !HAVE_DECL_SCM_IS_FALSE
156 #  define scm_is_false(x)   SCM_FALSEP(x)
157 #endif])
158 AH_VERBATIM(SCM_FROM_LOCALE_STRING, [#if !HAVE_DECL_SCM_FROM_LOCALE_STRING
159 #  define scm_from_locale_string(x) scm_makfrom0str(x)
160 #endif])
161 AH_VERBATIM(SCM_TO_LOCALE_STRING, [#if !HAVE_DECL_SCM_TO_LOCALE_STRING
162 #  define scm_to_locale_string(x)   strdup(SCM_STRING_CHARS(x))
163 #endif])
166 # Check for guile end
167 ############################################################################
169 ############################################################################
170 # Check for mics things start
172 # Checking for rint in math library
173 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
175 # Checking for dynamic lib
176 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
178 # Check for mics things start
179 ############################################################################
181 ############################################################################
182 # Check for libgeda start
184 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
185                   no_LIBGEDA="yes")
187 if test "$LIBGEDA" = "yes" 
188 then
189    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
190 else
191    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
195 # Check for libgeda end
196 ############################################################################
198 ############################################################################
199 # Check for gtk+ 2.4 start
202 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
204 # This next bit of code figures out what gtk we need to use.
205 if test "$GTK24" = "yes"
206 then
208    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
209    GTK_CFLAGS=$GTK24_CFLAGS
210    GTK_LIBS=$GTK24_LIBS
211    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
213    # Search for glib
214    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
215    if test "$GLIB24" != "yes"
216    then
217        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
218    fi
219    GLIB_CFLAGS=$GLIB24_CFLAGS
220    GLIB_LIBS=$GLIB24_LIBS
221    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
223 else
224    GTK_VERSION=""
227 if test "$GTK_VERSION" = ""
228 then
229    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
233 # Check for gtk+ 2.4 end
234 ############################################################################
236 ############################################################################
237 # Check for glib 2.4 start
240 # Check for pkg-config
241 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
242 if test $PKG_CONFIG = no; then
243    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
246 # Search for glib 2.4.x first (only if we are not forcing the glib to 1.2)
247 if test "$opt_gtkver" != "1.2"
248 then
249    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
252 # This next bit of code figures out what glib we need to use.
253 if test "$GLIB24" = "yes" -a "$opt_gtkver" != "1.2"
254 then
255    GLIB_CFLAGS=$GLIB24_CFLAGS
256    GLIB_LIBS=$GLIB24_LIBS
257    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
258 else
259    GLIB_VERSION=""
262 if test "$GLIB_VERSION" = ""
263 then
264    AC_MSG_ERROR([Cannot find glib 2.4.x, install one of them.])
268 # Check for glib 2.4 end
269 ############################################################################
271 #########################################################################
272 # Checks for header files start
274 AC_HEADER_STDC
275 AC_HEADER_SYS_WAIT
276 AC_HEADER_DIRENT
277 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
278                  stdarg.h assert.h fcntl.h errno.h \
279                  getopt.h)
281 # Checks for typedefs, structures, and compiler characteristics.
282 AC_C_CONST
284 # Checks for library functions.
285 AC_TYPE_SIGNAL
286 AC_CHECK_FUNCS(strstr snprintf getopt_long)
287 AC_CHECK_FUNCS(strcasecmp strncasecmp stricmp strnicmp)
289 AC_MSG_CHECKING([for optarg in unistd.h])
290 AC_TRY_COMPILE(
291 [#include <unistd.h>],
292 [ char *string = optarg; int i = optind; ],
293 optarg_found=yes,
294 optarg_found=no)
295 AC_MSG_RESULT($optarg_found)
297 if test $optarg_found = yes; then
298     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
302 # Checks for header files start
303 #########################################################################
305 #########################################################################
308 # ------------- dmalloc -------------------
309 dnl dmalloc checks
310 with_dmalloc="no"
311 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
312 AC_ARG_ENABLE([dmalloc],
313 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
315 if test "X$enable_dmalloc" != "Xno" ; then
316         AC_MSG_RESULT([yes])
317         AC_CHECK_HEADER(dmalloc.h,,
318                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
319         AC_CHECK_LIB(dmalloc,main,,
320                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
321         DMALLOC_LIBS="-ldmalloc"
322         with_dmalloc="yes"
323 else
324         AC_MSG_RESULT([no])
325         DMALLOC_LIBS=""
329         AC_MSG_RESULT([no])
330         DMALLOC_LIBS=""
333 # ------------- ElectricFence -------------------
334 dnl ElectricFence checks
335 with_efence="no"
336 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
337 AC_ARG_ENABLE([efence],
338 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
340 if test "X$enable_efence" != "Xno" ; then
341         AC_MSG_RESULT([yes])
342         if test "X$with_dmalloc" = "Xyes" ; then
343                 AC_ERROR([You have requested both dmalloc and Electric Fence, however only 1 is allowed.])
344         fi
345         AC_CHECK_LIB(efence,main,,
346                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
347         with_efence="yes"
348 else
349         AC_MSG_RESULT([no])
353 AC_MSG_RESULT([no])
357 #########################################################################
359 #########################################################################
361 # Change default location for pcb's newlib library directory
363 # Used by gsch2pcb
365 AC_MSG_CHECKING([For the default pcb installation data directory])
366 AC_ARG_WITH(pcb-datadir,
367         [  --with-pcb-datadir=path
368                           Change the default location for an installed pcb.  This is used
369                           to set the default search path for pcb newlib libraries.
370                           [[default=${datadir}]]],
371         [PCBDATADIR=$withval],
372         [PCBDATADIR="${datadir}"]
374 AC_MSG_RESULT([${PCBDATADIR}])
375 CPPFLAGS="$CPPFLAGS -DPCBDATADIR=\\\"${PCBDATADIR}\\\""
377 AC_MSG_CHECKING([For the default pcb newlib search path])
378 AC_ARG_WITH(pcb-newlib-path,
379         [  --with-pcb-newlib-path=path
380                           Change the default search path for PCB newlib libraries
381                           [[default=${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib]]],
382         [PCBLIBPATH=$withval],
383         [PCBLIBPATH="${PCBDATADIR}/pcb/pcblib-newlib:${PCBDATADIR}/pcb/newlib"]
385 AC_MSG_RESULT([${PCBLIBPATH}])
386 CPPFLAGS="$CPPFLAGS -DPCBLIBPATH=\\\"${PCBLIBPATH}\\\""
389 #########################################################################
391 #########################################################################
392 # Check for groff start
395 # search for groff
396 AC_PATH_PROG(GROFF, groff, no, ${PATH})
397 if test $GROFF = "no"; then
398         echo "Cannot find groff, some documentation will not be created."
402 # Check for groff end
403 #########################################################################
405 #########################################################################
406 # gEDA/gaf specify setup start
409 DATADIR=gEDA
410 GEDADATADIR=$datadir/$DATADIR
412 if eval "test x$opt_rcdir = x"; then
413         # path not was specified with --with-rcdir
414         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
415         GEDARCDIR=$GEDADATADIR
416 else
417         # path WAS specified with --with-rcdir
418         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
419         GEDARCDIR="$opt_rcdir"
422 # Expand the prefix variable
423 # I don't like the way this is done, but it works (I hope).
424 if eval "test x$prefix = xNONE"; then
425  dprefix=$ac_default_prefix
426 else
427  dprefix=$prefix
430 gedatopdir=$dprefix/share/$DATADIR
431 expandgedadatadir=`echo $gedatopdir`
433 gedadocdir=$dprefix/share/doc/geda-doc
434 # --with-docdir : tells where to store documentation if not default
435 AC_ARG_WITH(docdir,
436     [  --with-docdir      Where to store documentation if not default.],
437         gedadocdir=$withval)
438 expandgedadocdir=`echo $gedadocdir`
439 GEDADOCDIR=$expandgedadocdir
441 # this has to be expanded ( no ${prefix} ) --
442 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
443 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
444 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
445 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
448 # gEDA/gaf specify things which need to setup
449 #########################################################################
451 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
452 GSCHLAS_CFLAGS="$LIBGEDA_CFLAGS"
453 GSCHLAS_LDFLAGS="$LIBGEDA_LIBS $GTK_LIBS"
454 GMK_SYM_CFLASG="$MINGW_CFLAGS"
455 SMASH_MEGAFILE_CFLAGS="$MINGW_CFLAGS"
456 CONVERT_SYM_CFLAGS="$LIBGEDA_CFLAGS"
457 SARLACC_SCHEM_CFLAGS="$LIBGEDA_CFLAGS"
458 OLIB_CFLAGS="$MINGW_CFLAGS"
459 GSCH2PCB_CFLAGS="$GLIB_CFLAGS $MINGW_CFLAGS"
460 GSCH2PCB_LDFLAGS="$GLIB_LIBS"
461 GRENUM_CFLAGS="$LIBGEDA_CFLAGS"
462 GRENUM_LDFLAGS="$GLIB_LIBS"
464 # Makefile.in variable substitution
465 AC_SUBST(DATE_VERSION)
466 AC_SUBST(DOTTED_VERSION)
467 AC_SUBST(GSCHLAS_CFLAGS)
468 AC_SUBST(GSCHLAS_LDFLAGS)
469 AC_SUBST(GMK_SYM_CFLAGS)
470 AC_SUBST(SMASH_MEGAFILE_CFLAGS)
471 AC_SUBST(CONVERT_SYM_CFLAGS)
472 AC_SUBST(SARLACC_SCHEM_CFLAGS)
473 AC_SUBST(OLIB_CFLAGS)
474 AC_SUBST(GSCH2PCB_CFLAGS)
475 AC_SUBST(GSCH2PCB_LDFLAGS)
476 AC_SUBST(GRENUM_CFLAGS)
477 AC_SUBST(GRENUM_LDFLAGS)
478 AC_SUBST(GEDARCDIR)
479 AC_SUBST(GEDADATADIR)
480 AC_SUBST(GEDADOCDIR)
482 # Create all the necessary derived files
483 AC_CONFIG_FILES([Makefile 
484                  examples/Makefile 
485                  examples/gmk_sym/Makefile 
486                  examples/tragesym/Makefile 
487                  examples/gsch2pcb/Makefile 
488                  gxyrs/Makefile
489                  include/Makefile 
490                  scripts/Makefile 
491                  docs/Makefile 
492                  man/Makefile 
493                  lib/Makefile 
494                  lib/system-gschlasrc 
495                  gschlas/Makefile 
496                  src/Makefile
497                  tests/Makefile
498                  tests/refdes_renum/Makefile
499                  tests/refdes_renum/inputs/Makefile
500                  tests/refdes_renum/outputs/Makefile
501                  tests/gxyrs/Makefile
502                  tests/gxyrs/inputs/Makefile
503                  tests/gxyrs/outputs/Makefile
506 AC_OUTPUT
508 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
509 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
510 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
511 expandedPCBLIBPATH=`eval "echo $PCBLIBPATH"`
513 AC_MSG_RESULT([
514 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION:
516    GTK+ library version:             $GTK_VERSION
517    GLIB library version:             $GLIB_VERSION
518    libgeda library version:          $LIBGEDA_VERSION
519    mingw build:                      $MINGW
520    data directory:                   $expandedGEDADATADIR
521    rc directory:                     $expandedGEDARCDIR
522    documentation directory:          $expandedGEDADOCDIR
523    default pcb newlib path:          $expandedPCBLIBPATH
524    dmalloc debugging:                $with_dmalloc
525    Electric Fence debugging:         $with_efence