Updated all dates and versions in all man pages
[geda-gaf/whiteaudio.git] / utils / configure.ac
blobe1699ac3865f3bfe1a399ea98c2d56810a735e94
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.3.1
8 DATE_VERSION=20080110
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
91 GUILE_FLAGS
93 # Check Guile version
94 guile_need_major=1
95 guile_need_minor=6
96 guile_need_version="$guile_need_major[].$guile_need_minor.0"
98 AC_MSG_CHECKING([Guile version >= $guile_need_version])
99 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
101 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
102 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
103 AC_MSG_RESULT($GUILE_VERSION)
105 if test "$guile_need_major" -gt "$guile_major" \
106    || (test "$guile_need_major" -eq "$guile_major" \
107        && test "$guile_need_minor" -gt "$guile_minor"); then
108   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
111 # Guile 1.6 compatability
113 CFLAGS_temp_save="$CFLAGS"
114 CFLAGS="$CFLAGS $GUILE_CFLAGS"
115 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
116 scm_from_int,  scm_is_true,    scm_is_false,
117 scm_from_locale_string, scm_to_locale_string],,,
118 [#include <libguile.h>])
119 CFLAGS="$CFLAGS_temp_save"
121 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
122 #  define scm_is_string(x) SCM_STRINGP(x)
123 #endif])
124 AH_VERBATIM(SCM_IS_INTEGER, [#if !HAVE_DECL_SCM_IS_INTEGER
125 #  define scm_is_integer(x) SCM_INUMP(x)
126 #endif])
127 AH_VERBATIM(SCM_TO_INT, [#if !HAVE_DECL_SCM_TO_INT
128 #  define scm_to_int(x)     SCM_INUM(x)
129 #endif])
130 AH_VERBATIM(SCM_FROM_INT, [#if !HAVE_DECL_SCM_FROM_INT
131 #  define scm_from_int(x)   SCM_MAKINUM(x)
132 #endif])
133 AH_VERBATIM(SCM_IS_TRUE, [#if !HAVE_DECL_SCM_IS_TRUE
134 #  define scm_is_true(x)    SCM_NFALSEP(x)
135 #endif])
136 AH_VERBATIM(SCM_IS_FALSE, [#if !HAVE_DECL_SCM_IS_FALSE
137 #  define scm_is_false(x)   SCM_FALSEP(x)
138 #endif])
139 AH_VERBATIM(SCM_FROM_LOCALE_STRING, [#if !HAVE_DECL_SCM_FROM_LOCALE_STRING
140 #  define scm_from_locale_string(x) scm_makfrom0str(x)
141 #endif])
142 AH_VERBATIM(SCM_TO_LOCALE_STRING, [#if !HAVE_DECL_SCM_TO_LOCALE_STRING
143 #  define scm_to_locale_string(x)   strdup(SCM_STRING_CHARS(x))
144 #endif])
147 # Check for guile end
148 ############################################################################
150 ############################################################################
151 # Check for mics things start
153 # Checking for rint in math library
154 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
156 # Checking for dynamic lib
157 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
159 # Check for mics things start
160 ############################################################################
162 ############################################################################
163 # Check for libgeda start
165 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
166                   no_LIBGEDA="yes")
168 if test "$LIBGEDA" = "yes" 
169 then
170    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
171 else
172    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
176 # Check for libgeda end
177 ############################################################################
179 ############################################################################
180 # Check for gtk+ 2.4 start
183 # Check for pkg-config
184 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
185 if test $PKG_CONFIG = no; then
186    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
189 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
191 # This next bit of code figures out what gtk we need to use.
192 if test "$GTK24" = "yes"
193 then
195    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
196    GTK_CFLAGS=$GTK24_CFLAGS
197    GTK_LIBS=$GTK24_LIBS
198    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
200    # Search for glib
201    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
202    if test "$GLIB24" != "yes"
203    then
204        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
205    fi
206    GLIB_CFLAGS=$GLIB24_CFLAGS
207    GLIB_LIBS=$GLIB24_LIBS
208    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
210 else
211    GTK_VERSION=""
214 if test "$GTK_VERSION" = ""
215 then
216    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
220 # Check for gtk+ 2.4 end
221 ############################################################################
223 ############################################################################
224 # Check for glib 2.4 start
227 # Check for pkg-config
228 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
229 if test $PKG_CONFIG = no; then
230    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
233 # Search for glib 2.4.x first (only if we are not forcing the glib to 1.2)
234 if test "$opt_gtkver" != "1.2"
235 then
236    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
239 # This next bit of code figures out what glib we need to use.
240 if test "$GLIB24" = "yes" -a "$opt_gtkver" != "1.2"
241 then
242    GLIB_CFLAGS=$GLIB24_CFLAGS
243    GLIB_LIBS=$GLIB24_LIBS
244    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
245 else
246    GLIB_VERSION=""
249 if test "$GLIB_VERSION" = ""
250 then
251    AC_MSG_ERROR([Cannot find glib 2.4.x, install one of them.])
255 # Check for glib 2.4 end
256 ############################################################################
258 #########################################################################
259 # Checks for header files start
261 AC_HEADER_STDC
262 AC_HEADER_SYS_WAIT
263 AC_HEADER_DIRENT
264 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
265                  stdarg.h assert.h fcntl.h errno.h \
266                  getopt.h)
268 # Checks for typedefs, structures, and compiler characteristics.
269 AC_C_CONST
271 # Checks for library functions.
272 AC_TYPE_SIGNAL
273 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf getopt_long)
274 AC_CHECK_FUNCS(strcasecmp strncasecmp stricmp strnicmp)
276 AC_MSG_CHECKING([for optarg in unistd.h])
277 AC_TRY_COMPILE(
278 [#include <unistd.h>],
279 [ char *string = optarg; int i = optind; ],
280 optarg_found=yes,
281 optarg_found=no)
282 AC_MSG_RESULT($optarg_found)
284 if test $optarg_found = yes; then
285     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
289 # Checks for header files start
290 #########################################################################
292 #########################################################################
295 # ------------- dmalloc -------------------
296 dnl dmalloc checks
297 with_dmalloc="no"
298 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
299 AC_ARG_ENABLE([dmalloc],
300 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
302 if test "X$enable_dmalloc" != "Xno" ; then
303         AC_MSG_RESULT([yes])
304         AC_CHECK_HEADER(dmalloc.h,,
305                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
306         AC_CHECK_LIB(dmalloc,main,,
307                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
308         DMALLOC_LIBS="-ldmalloc"
309         with_dmalloc="yes"
310 else
311         AC_MSG_RESULT([no])
312         DMALLOC_LIBS=""
316         AC_MSG_RESULT([no])
317         DMALLOC_LIBS=""
320 # ------------- ElectricFence -------------------
321 dnl ElectricFence checks
322 with_efence="no"
323 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
324 AC_ARG_ENABLE([efence],
325 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
327 if test "X$enable_efence" != "Xno" ; then
328         AC_MSG_RESULT([yes])
329         if test "X$with_dmalloc" = "Xyes" ; then
330                 AC_ERROR([You have requested both dmalloc and Electric Fence, however only 1 is allowed.])
331         fi
332         AC_CHECK_LIB(efence,main,,
333                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
334         with_efence="yes"
335 else
336         AC_MSG_RESULT([no])
340 AC_MSG_RESULT([no])
344 #########################################################################
346 #########################################################################
348 # Change default location for pcb's newlib library directory
350 # Used by gsch2pcb
352 AC_MSG_CHECKING([For the default pcb installation data directory])
353 AC_ARG_WITH(pcb-datadir,
354         [  --with-pcb-datadir=path
355                           Change the default location for an installed pcb.  This is used
356                           to set the default search path for pcb newlib libraries.
357                           [[default=${datadir}]]],
358         [PCBDATADIR=$withval],
359         [PCBDATADIR="${datadir}"]
361 AC_MSG_RESULT([${PCBDATADIR}])
362 CPPFLAGS="$CPPFLAGS -DPCBDATADIR=\\\"${PCBDATADIR}\\\""
364 AC_MSG_CHECKING([For the default pcb newlib search path])
365 AC_ARG_WITH(pcb-newlib-path,
366         [  --with-pcb-newlib-path=path
367                           Change the default search path for PCB newlib libraries
368                           [[default=${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib]]],
369         [PCBLIBPATH=$withval],
370         [PCBLIBPATH="${PCBDATADIR}/pcb/pcblib-newlib:${PCBDATADIR}/pcb/newlib"]
372 AC_MSG_RESULT([${PCBLIBPATH}])
373 CPPFLAGS="$CPPFLAGS -DPCBLIBPATH=\\\"${PCBLIBPATH}\\\""
376 #########################################################################
378 #########################################################################
379 # Check for groff start
382 # search for groff
383 AC_PATH_PROG(GROFF, groff, no, ${PATH})
384 if test $GROFF = "no"; then
385         echo "Cannot find groff, some documentation will not be created."
389 # Check for groff end
390 #########################################################################
392 #########################################################################
393 # gEDA/gaf specify setup start
396 DATADIR=gEDA
397 GEDADATADIR=$datadir/$DATADIR
399 if eval "test x$opt_rcdir = x"; then
400         # path not was specified with --with-rcdir
401         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
402         GEDARCDIR=$GEDADATADIR
403 else
404         # path WAS specified with --with-rcdir
405         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
406         GEDARCDIR="$opt_rcdir"
409 # Expand the prefix variable
410 # I don't like the way this is done, but it works (I hope).
411 if eval "test x$prefix = xNONE"; then
412  dprefix=$ac_default_prefix
413 else
414  dprefix=$prefix
417 gedatopdir=$dprefix/share/$DATADIR
418 expandgedadatadir=`echo $gedatopdir`
420 gedadocdir=$dprefix/share/doc/geda-doc
421 # --with-docdir : tells where to store documentation if not default
422 AC_ARG_WITH(docdir,
423     [  --with-docdir      Where to store documentation if not default.],
424         gedadocdir=$withval)
425 expandgedadocdir=`echo $gedadocdir`
426 GEDADOCDIR=$expandgedadocdir
428 # this has to be expanded ( no ${prefix} ) --
429 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
430 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
431 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
432 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
435 # gEDA/gaf specify things which need to setup
436 #########################################################################
438 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
439 GSCHLAS_CFLAGS="$LIBGEDA_CFLAGS"
440 GSCHLAS_LDFLAGS="$LIBGEDA_LIBS $GTK_LIBS"  
441 GSCH2PCB_CFLAGS="$GLIB_CFLAGS $MINGW_CFLAGS"
442 GSCH2PCB_LDFLAGS="$GLIB_LIBS"
443 GRENUM_CFLAGS="$LIBGEDA_CFLAGS"
444 GRENUM_LDFLAGS="$GLIB_LIBS"  
446 # Makefile.in variable substitution
447 AC_SUBST(DATE_VERSION)
448 AC_SUBST(DOTTED_VERSION)
449 AC_SUBST(GSCHLAS_CFLAGS)
450 AC_SUBST(GSCHLAS_LDFLAGS)
451 AC_SUBST(GSCH2PCB_CFLAGS)
452 AC_SUBST(GSCH2PCB_LDFLAGS)
453 AC_SUBST(GRENUM_CFLAGS)
454 AC_SUBST(GRENUM_LDFLAGS)
455 AC_SUBST(MINGW_CFLAGS)
456 AC_SUBST(GEDARCDIR)
457 AC_SUBST(GEDADATADIR)
458 AC_SUBST(GEDADOCDIR)
460 # Create all the necessary derived files
461 AC_CONFIG_FILES([Makefile 
462                  examples/Makefile 
463                  examples/gmk_sym/Makefile 
464                  examples/tragesym/Makefile 
465                  examples/gsch2pcb/Makefile 
466                  include/Makefile 
467                  scripts/Makefile 
468                  docs/Makefile 
469                  man/Makefile 
470                  lib/Makefile 
471                  lib/system-gschlasrc 
472                  gschlas/Makefile 
473                  src/Makefile
474                  tests/Makefile
475                  tests/refdes_renum/Makefile
476                  tests/refdes_renum/inputs/Makefile
477                  tests/refdes_renum/outputs/Makefile
480 AC_OUTPUT
482 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
483 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
484 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
485 expandedPCBLIBPATH=`eval "echo $PCBLIBPATH"`
487 AC_MSG_RESULT([
488 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION:
490    GTK+ library version:             $GTK_VERSION
491    GLIB library version:             $GLIB_VERSION
492    libgeda library version:          $LIBGEDA_VERSION
493    mingw build:                      $MINGW
494    data directory:                   $expandedGEDADATADIR
495    rc directory:                     $expandedGEDARCDIR
496    documentation directory:          $expandedGEDADOCDIR
497    default pcb newlib path:          $expandedPCBLIBPATH
498    dmalloc debugging:                $with_dmalloc
499    Electric Fence debugging:         $with_efence