fix minor bug with the --with-pcbconfdir option
[geda-gaf/peter-b.git] / libgeda / configure.ac
blobfb6ff6a9559c2464cce1c089ba52fa59a0b3c006
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([include/libgeda.h])
4 AC_PREREQ(2.54)
6 PACKAGE=libgeda
7 VERSION=20050820
8 SHARED_LIBRARY_VERSION=24:0:0
9 echo Configuring $PACKAGE version $VERSION
11 # Init automake
12 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
13 AM_CONFIG_HEADER([config.h])
15 # Init libtool
16 AM_PROG_LIBTOOL
18 # Init maintainer mode
19 AM_MAINTAINER_MODE
21 #########################################################################
22 # Command line flags start
23
24 # --disable-gdgeda : turn off libgdgeda support
25 AC_ARG_ENABLE(gdgeda, [  --disable-gdgeda        Disable libgdgeda support (don't use libgdgeda at all)], 
26   [ if test $enableval = "no"; then no_gdgeda=yes; fi ])
28 # Change default location for rc files
29 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
31
32 # Command line flags end
33 #########################################################################
35 # Checks for libraries.
36 #########################################################################
37
38 # Misc win32 / mingw checks and variables start
40 # Figure out if we are building on win32 and what environment.
41 case $host_os in
42   *cygwin*  ) AC_MSG_ERROR([Building gEDA/gaf under cygwin is not supported]) ;;
43   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
44 esac
46 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
47    MINGW_CFLAGS="-mms-bitfields -mwindows"
48    MINGW_LIBS="-lregex -liberty"
49    MINGW="yes"
50    PATHSEP=\\\\
51    OTHERPATHSEP=/
52 else
53    # Unix host
54    MINGW_CFLAGS=
55    MINGW_LIBS=
56    MINGW="no"
57    PATHSEP=/
58    OTHERPATHSEP=\\\\
61
62 # Misc win32 / mingw checks and variables end
63 #########################################################################
65 # Checks for programs.
66 AC_PROG_CC
67 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
68 AC_PROG_CPP
69 AC_PROG_MAKE_SET
71 ############################################################################
72 # Check for guile start
74 GUILE_FLAGS
76 # Manually search for guile-config.  This is provided by GUILE_PROGS, but
77 # guile-1.4 does not have GUILE_PROGS, so we have to do it manually.
78 AC_PATH_PROG(GUILE_CONFIG,guile-config)
79 if test "$GUILE_CONFIG" = "" ; then
80     AC_MSG_ERROR([guile-config required but not found])
82 AC_SUBST(GUILE_CONFIG)
84 # must have guile flags in CFLAGS for AC_COMPILE_IFELSE to work right
85 saved_CFLAGS="${CFLAGS}"
86 CFLAGS="${CFLAGS} ${GUILE_CFLAGS}"
88 # 1-argument scm_eval_x (guile-1.4) or 2-argument form (guile-1.6)?
89 AC_MSG_CHECKING(
90    [if scm_eval_x() takes a second module argument])
91    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libguile.h>]], 
92    [[SCM foo,bar; scm_eval_x(foo,bar);]])],
93    [AC_DEFINE([HAVE_SCM_EVAL_X_MODULE], 1, 
94    [Define if the SCM_EVAL_X function takes a second argument "module"])
95    AC_MSG_RESULT(yes) ], [AC_MSG_RESULT(no)])
96 CFLAGS="${saved_CFLAGS}"
98 # Check that scm_make_smob_type exist
99 AC_CHECK_LIB(guile, scm_make_smob_type,,
100    [AC_MSG_ERROR([Upgrade Guile, At least version >= 1.3.2])],
101    $GUILE_LDFLAGS)
103 # Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
104 LIBS="$ac_save_LIBS"
106 # Check that scm_set_smob_mark exist
107 AC_CHECK_LIB(guile, scm_set_smob_mark,,
108    [AC_MSG_ERROR([Upgrade Guile, At least version >= 1.3.2])],
109    $GUILE_LDFLAGS)
111 # Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
112 LIBS="$ac_save_LIBS"
114 # Check that scm_set_smob_free exist
115 AC_CHECK_LIB(guile, scm_set_smob_free,,
116    [AC_MSG_ERROR([Upgrade Guile, At least version >= 1.3.2])],
117    $GUILE_LDFLAGS)
119 # Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
120 LIBS="$ac_save_LIBS"
122 # Check that scm_set_smob_print exist
123 AC_CHECK_LIB(guile, scm_set_smob_print,,
124    [AC_MSG_ERROR([Upgrade Guile, At least version >= 1.3.2])],
125    $GUILE_LDFLAGS)
127 # Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
128 LIBS="$ac_save_LIBS"
130 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
133 # Check for guile end
134 ############################################################################
136 ############################################################################
137 # Check for mics things start
139 # Checking for rint in math library
140 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
142 # Checking for dynamic lib
143 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
145 # Check for mics things start
146 ############################################################################
148 ############################################################################
149 # Check for libgdgeda start
151 AC_PATH_PROG(LIBGDGEDACONFIG, libgdgeda-config, no, ${PATH})
153 if test "$LIBGDGEDACONFIG" = "no"
154 then
155    GDGEDA_CFLAGS=
156    GDGEDA_LIBS=
157    GDGEDA_VERSION=
158    GDGEDA="no"
159 else
160    if test "$no_gdgeda" = "yes" 
161    then
162      echo found libgdgeda, but disabling gdgeda support.
163      GDGEDA_CFLAGS=
164      GDGEDA_LIBS=
165      GDGEDA_VERSION=
166      GDGEDA="no"
167    else 
168      GDGEDA_CFLAGS=`$LIBGDGEDACONFIG --cflags`
169      GDGEDA_LIBS1=`$LIBGDGEDACONFIG --ldflags`
170      GDGEDA_LIBS2=`$LIBGDGEDACONFIG --libs`
171      GDGEDA_LIBS="$GDGEDA_LIBS1 $GDGEDA_LIBS2"
172      GDGEDA_VERSION=`$LIBGDGEDACONFIG --version`
173      GDGEDA="yes"
175      # This is not really used to figure out paths, but just to make 
176      # sure >= 2.0.15 is installed
177      PKG_CHECK_MODULES(libgdgeda, libgdgeda >= 2.0.15)
178      AC_DEFINE(HAS_LIBGDGEDA, 1, [If libgdgeda has been installed, define this])
179    fi
183 # Check for libgdgeda end
184 ############################################################################
186 ############################################################################
187 # Check for X11 start
190 if test "$MINGW" = "no"
191 then
192    AC_PATH_X
193    AC_PATH_XTRA 
194     
195    X_EXTRA_LIBS="$X_EXTRA_LIBS"
196    X_LDFLAGS="$X_LDFLAGS $X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS -lX11 -lm"
200 # Check for X11 end
201 ############################################################################
203 ############################################################################
204 # Check for gtk+ 2.2 start
207 # Check for pkg-config
208 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
209 if test $PKG_CONFIG = no; then
210    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
213 PKG_CHECK_MODULES(GTK22, gtk+-2.0 >= 2.2.0, GTK22="yes", no_GTK22="yes")
215 # This next bit of code figures out what gtk we need to use.
216 if test "$GTK22" = "yes"
217 then
219    AC_DEFINE(HAS_GTK22, 1, [If gtk+ 2.2.x has been installed, define this])
220    GTK_CFLAGS=$GTK22_CFLAGS
221    GTK_LIBS=$GTK22_LIBS
222    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
224    # Search for glib
225    PKG_CHECK_MODULES(GLIB22, glib-2.0 >= 2.2.0, GLIB22="yes", no_GLIB22="yes")
226    if test "$GLIB22" != "yes"
227    then
228        AC_MSG_ERROR([Cannot find glib 2.2.x, install it and rerun ./configure.])
229    fi
230    GLIB_CFLAGS=$GLIB22_CFLAGS
231    GLIB_LIBS=$GLIB22_LIBS
232    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
234 else
235    GTK_VERSION=""
238 if test "$GTK_VERSION" = ""
239 then
240    AC_MSG_ERROR([Cannot find gtk+ 2.2.x or later, please install gtk+.])
244 # Check for gtk+ 2.2 end
245 ############################################################################
247 ############################################################################
248 # Check for gdk 2.2 or later
251 # Check for pkg-config
252 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
253 if test $PKG_CONFIG = no; then
254    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
257 PKG_CHECK_MODULES(GDK, gdk-2.0 >= 2.2.0, GDK="yes", no_GDK="yes")
259 # This next bit of code figures out what gtk we need to use.
260 if test "$GDK" = "yes" 
261 then
263    AC_DEFINE(HAS_GDK, 1, [If gdk has been installed, define this])
264    GDK_CFLAGS=$GDK_CFLAGS
265    GDK_LIBS=$GDK_LIBS
266    GDK_VERSION=`$PKG_CONFIG gdk-2.0 --modversion`
270 if test "$GDK_VERSION" = ""
271 then
272    AC_MSG_ERROR([Cannot find gdk, please make sure it is installed.])
276 # Check for gdk end
277 ############################################################################
279 ############################################################################
280 # Check for gdk-pixbuf 
283 # Check for pkg-config
284 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
285 if test $PKG_CONFIG = no; then
286    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
289 PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0 >= 0.15.0, GDK_PIXBUF="yes", no_GDK_PIXBUF="yes")
291 # This next bit of code figures out what gtk we need to use.
292 if test "$GDK_PIXBUF" = "yes" 
293 then
295    AC_DEFINE(HAS_GDK_PIXBUF, 1, [If gdk-pixbuf has been installed, define this])
296    GDK_PIXBUF_CFLAGS=$GDK_PIXBUF_CFLAGS
297    GDK_PIXBUF_LIBS=$GDK_PIXBUF_LIBS
298    GDK_PIXBUF_VERSION=`$PKG_CONFIG gdk-pixbuf-2.0 --modversion`
302 if test "$GDK_PIXBUF_VERSION" = ""
303 then
304    AC_MSG_ERROR([Cannot find gdk-pixbuf, please make sure it is installed.])
308 # Check for gdk-pixbuf end
309 ############################################################################
313 ############################################################################
314 # Check for notangle, noweave, texi2html, indent start
317 # Tangling is required if there is no C source files in the src/ 
318 # directory. Therefore they need to be extracted from the documented
319 # sources in noweb/ either with notangle or notangle_guile.
321 # notangle is the utility that comes with the noweb package.
322 # notangle_guile is a script that act the same as notangle
323 # but only require a guile interpreter with built-in module regex
324 # and getopt-long
326 # search for notangle
327 AC_PATH_PROG(NOTANGLE, notangle, no, ${PATH})
328 cfiles=`\ls -1 src/libgeda.c 2> /dev/null`
329 exit_status=$?
331 if test "$NOTANGLE" = "no" -a "$exit_status" = "1"; then
333    # notangle not found, and no C sources in src 
334    # need notangle_guile
335    echo "** Cannot find notangle (part of noweb) : using notangle_guile instead **"
336         
337    # find the guile interpreter
338    AC_PATH_PROG(GUILEINTERP, guile, no, ${PATH})
339    if test "$GUILEINTERP" = "no"; then
340       AC_MSG_ERROR([guile interpreter is required])
341    fi
342   
343    # check (ice-9 getopt-long) module in guile
344    AC_MSG_CHECKING([for getopt-long module in guile])
345    guilegetopt=`$GUILEINTERP -c  '(use-modules (ice-9 getopt-long))' 2> /dev/null`
346    exit_status=$?
347    if test "$exit_status" = "1"; then
348       AC_MSG_RESULT([no])
349       echo "no support for getopt-long module in guile interpreter"
350       AC_MSG_ERROR([this module is required by notangle_guile but is not available in the interpreter])
351    fi
352    AC_MSG_RESULT([yes])
354    # check (ice-9 regex) module in guile
355    AC_MSG_CHECKING([for regex module in guile])
356    guileregex=`$GUILEINTERP -c  '(use-modules (ice-9 regex))' 2> /dev/null`
357    exit_status=$?
358    if test ! "$exit_status" = "0"; then
359       AC_MSG_RESULT([no])
360       echo "no support for regex module in guile interpreter"
361       AC_MSG_ERROR([this module is required by notangle_guile but is not available in the interpreter])
362    fi
363    AC_MSG_RESULT([yes])
365    # set NOTANGLE and NOTANGLEROOT to use notangle_guile
366    # as the result of the previous tests
367    #  - NOTANGLE is the relative pathname to script from the source dir
368    #  - NOTANGLEROOT is the option to give the root code chunk name
369    #  - NOTANGLEFLAGS are other flags to notangle_guile
370    NOTANGLE="../scripts/notangle_guile"
371    NOTANGLEROOT="--rootname="
372    NOTANGLEFLAGS=""
374    echo "--            notangle_guile should work fine on this system           --"
376 else
378    # NOTANGLE has been set by AC_PATH_PROG above
379    NOTANGLEROOT="-R"
380    NOTANGLEFLAGS="-L"
384 # Weaving is extracting the documentation from the noweb files.
385 # The noweb package provides noweave to weave these files.
387 # The documentation is here written in Texinfo. A backend is 
388 # provided in scripts to format the code chunks in Texinfo.
390 # The noweave program is therefore required to produce the 
391 # documentation but building documentation is optionnal.
394 # search for noweave
395 AC_PATH_PROG(NOWEAVE, noweave, no, ${PATH})
396 # search for AWK
397 #  the noweb texinfo backend is based on awk. If awk is not available,
398 #  the backend will not work, and therefore it disables the 
399 #  documentation creation.
400 AC_PROG_AWK
402 if test "$NOWEAVE" = "no" -o "$AWK" = "no"; then 
403    # noweave is not available on the system
404    echo "** Cannot find noweave (part of noweb)! **"
405    echo "**   Documentation creation disabled    **"
406    NOWEAVE=echo
408    # prevent from weaving the nw files
409    # but does not prevent from processing gschemdoc
410    builddoc=false
411 else 
412    # noweave is available on the system.
413    # now checking if the tools for Texinfo files processing
414    # is installed.
415    # The docs can be either processed to produce dvi, html or info
416    # with texi2dvi, texi2html or makeinfo respectively
417    # Note : these tests on makeinfo and texi2dvi are no more 
418    #        needed as automake makes them for us
420    # enable the weaving of the nw files to get documentation
421    builddoc=true
424 # depending on variable builddoc, weaving is performed or not
425 # using conditionnal in docs/Makefile.in
426 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
428 # search for texi2html
429 # it looks like automake does not take care of html doc creation
430 AC_PATH_PROG(TEXI2HTML, texi2html, no, ${PATH})
432 if test "$TEXI2HTML" = "no"; then 
433    echo "**   Cannot find texi2html     **"
434    echo "** HTML file creation disabled **"
435    TEXI2HTML=echo
438 # search for indent
439 AC_PATH_PROG(INDENT, indent, no, ${PATH})
441 if ! test "$INDENT" = "no"; then 
442    indentversion=`$INDENT --version | grep GNU`
443 else 
444    indentversion=
447 if test "$INDENT" = "no" -o "$indentversion"x = x; then 
448   AC_PATH_PROG(GINDENT, gindent, no, ${PATH})
449   if test "$GINDENT" = "no"; then 
450     echo "** Cannot find GNU indent or gindent, C code formatting disabled **"
451     INDENT=echo
452   else
453     INDENT=$GINDENT
454   fi
458 # Check for notangle, noweave, texi2html, indent end
459 #########################################################################
461 #########################################################################
462 # Checks for header files start
465 AC_HEADER_STDC
466 AC_HEADER_SYS_WAIT
467 AC_HEADER_DIRENT
468 AC_CHECK_HEADERS(unistd.h string.h stdlib.h stdarg.h assert.h fcntl.h \
469                  errno.h)
471 AC_MSG_CHECKING([for optarg in unistd.h])
472 AC_TRY_COMPILE(
473 [#include <unistd.h>],
474 [ char *string = optarg; int i = optind; ],
475 optarg_found=yes,
476 optarg_found=no)
477 AC_MSG_RESULT($optarg_found)
478 if test $optarg_found = yes; then
479    AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
482 # Checks for typedefs, structures, and compiler characteristics.
483 AC_C_CONST
485 # Checks for library functions.
486 AC_TYPE_SIGNAL
487 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
490 # Checks for header files end
491 #########################################################################
493 #########################################################################
496 # ------------- dmalloc -------------------
497 dnl dmalloc checks
498 with_dmalloc="no"
499 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
500 AC_ARG_ENABLE([dmalloc],
501 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
503 if test "X$enable_dmalloc" != "Xno" ; then
504         AC_MSG_RESULT([yes])
505         AC_CHECK_HEADER(dmalloc.h,,
506                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
507         AC_CHECK_LIB(dmalloc,main,,
508                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
509         DMALLOC_LIBS="-ldmalloc"
510         with_dmalloc="yes"
511 else
512         AC_MSG_RESULT([no])
513         DMALLOC_LIBS=""
517         AC_MSG_RESULT([no])
518         DMALLOC_LIBS=""
521 # ------------- ElectricFence -------------------
522 dnl ElectricFence checks
523 with_efence="no"
524 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
525 AC_ARG_ENABLE([efence],
526 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
528 if test "X$enable_efence" != "Xno" ; then
529         AC_MSG_RESULT([yes])
530         AC_CHECK_LIB(efence,main,,
531                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
532         with_efence="yes"
533 else
534         AC_MSG_RESULT([no])
538 AC_MSG_RESULT([no])
542 #########################################################################
544 #########################################################################
545 # gEDA/gaf specific setup start
548 DATADIR=gEDA
549 GEDADATADIR=$datadir/$DATADIR
551 if eval "test x$opt_rcdir = x"; then
552         # path was not specified with --with-rcdir
553         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
554         GEDARCDIR=$GEDADATADIR
555 else
556         # path WAS specified with --with-rcdir
557         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
558         GEDARCDIR="$opt_rcdir"
561 # Defs for libary symbol files
563 # Expand the prefix variable
564 if eval "test x$prefix = xNONE"; then
565  dprefix=$ac_default_prefix
566 else
567  dprefix=$prefix
570 gedatopdir=$dprefix/share/$DATADIR
571 expandgedadatadir=`echo $gedatopdir`
573 # this has to be expanded ( no ${prefix} ) --
574 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
575 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Currently running version of gEDA/gaf])
578 # gEDA/gaf specify things which need to setup
579 #########################################################################
582 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
583 LIBGEDA_CFLAGS="$MINGW_CFLAGS $GUILE_CFLAGS $GDGEDA_CFLAGS $GTK_CFLAGS $X_CFLAGS $GDK_PIXBUF_CFLAGS $GDK_CFLAGS"
584 LIBGEDA_LDFLAGS="$GUILE_LDFLAGS $GDGEDA_LIBS $GLIB_LIBS $MINGW_LIBS $DMALLOC_LIBS $GDK_PIXBUF_LIBS $GDK_LIBS"
585 LIBTOOL_FLAGS="-version-info $SHARED_LIBRARY_VERSION"
587 # Makefile.in variable substitution
588 AC_SUBST(VERSION)
589 AC_SUBST(LIBGEDA_CFLAGS)
590 AC_SUBST(LIBGEDA_LDFLAGS)
591 AC_SUBST(LIBTOOL_FLAGS)
592 AC_SUBST(GEDADATADIR)
593 AC_SUBST(GEDARCDIR)
594 AC_SUBST(PATHSEP)
595 AC_SUBST(OTHERPATHSEP)
596 AC_SUBST(NOTANGLE)
597 AC_SUBST(NOTANGLEROOT)
598 AC_SUBST(NOTANGLEFLAGS)
599 AC_SUBST(GUILEINTERP)
600 AC_SUBST(NOWEAVE)
601 AC_SUBST(TEXI2HTML)
602 AC_SUBST(INDENT)
604 # Create all the necessary derived files
605 AC_CONFIG_FILES([Makefile
606                  src/Makefile
607                  noweb/Makefile
608                  scripts/Makefile
609                  include/Makefile
610                  docs/Makefile
611                  libgeda.pc
612                  scripts/geda_totexi
613                  scripts/notangle_guile ])
615 AC_CONFIG_COMMANDS([geda_totexi-chmod], 
616                    [[chmod +x scripts/geda_totexi]],[[]])
617 AC_CONFIG_COMMANDS([notangle_guile-chmod],
618                    [[chmod +x scripts/notangle_guile]],[[]])
620 AC_OUTPUT
622 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
623 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
625 AC_MSG_RESULT([
626 ** Configuration summary for $PACKAGE $VERSION:
628    GLIB library version:             $GLIB_VERSION
629    GTK+ library version:             $GTK_VERSION
630    GUILE library version:            $GUILE_VERSION
631    libgdgeda (png output):           $GDGEDA $GDGEDA_VERSION
632    mingw build:                      $MINGW
633    data directory:                   $expandedGEDADATADIR
634    rc directory:                     $expandedGEDARCDIR
635    LIBGEDA .so version:              $SHARED_LIBRARY_VERSION
636    dmalloc debugging:                $with_dmalloc
637    ElectricFence debugging:          $with_efence