A bunch of changes in prep for a release along with some minor bug fixes.
[geda-gaf/peter-b.git] / gschem / configure.ac
blobc0a742b547d59a4caf52e75dd465f39bc955659c
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([noweb/gschem.nw])
4 AC_PREREQ(2.54)
6 PACKAGE=geda-gschem
7 VERSION=20060123
8 echo Configuring $PACKAGE version $VERSION
10 # Initialize automake 
11 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
12 AM_CONFIG_HEADER([config.h])
14 # Initialize maintainer mode
15 AM_MAINTAINER_MODE
18 #########################################################################
19 # Command line flags start
20
21 # --disable-stroke : turn off stroke support
22 AC_ARG_ENABLE(stroke,
23     [  --disable-stroke       Disable stroke support (don't use LibStroke at all)], [ if test $enableval = "no"; then
24          no_stroke=yes
25         fi ])
27 # --disable-gdgeda : turn off libgdgeda support
28 AC_ARG_ENABLE(gdgeda,
29     [  --disable-gdgeda        Disable libgdgeda support (don't use libgdgeda at all)], [ if test $enableval = "no"; then
30             no_gdgeda=yes
31            fi ])
33 # Change default location for rc files
34 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
36 # Allow the user to specify where there libstroke library lives
37 AC_ARG_WITH(stroke, [  --with-stroke=DIR       Tell configure where to find libstroke], [opt_stroke=$withval])
39
40 # Command line flags end
41 #########################################################################
43 #########################################################################
44
45 # Misc win32 / mingw checks and variables start
46 AC_CANONICAL_HOST
48 # Figure out if we are building on win32 and what environment.
49 case $host_os in
50   *cygwin*  ) AC_MSG_ERROR([Building gEDA/gaf under cygwin is not supported]) ;;
51   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
52 esac
54 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
55    MINGW="yes"
56    PATHSEP=\\\\
57    OTHERPATHSEP=/
58 else
59    # Unix host
60    MINGW="no"
61    PATHSEP=/
62    OTHERPATHSEP=\\\\
65
66 # Misc win32 / mingw checks and variables end
67 #########################################################################
69 # Checks for programs.
70 AC_PROG_CC
71 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
72 AC_PROG_CPP
73 AC_PROG_MAKE_SET
75 ############################################################################
76 # Check for guile start
77 # Do a very basic guile test, as the bulk of the flags will come from 
78 # libgeda.pc
80 GUILE_FLAGS
82 # Manually search for guile-config.  This is provided by GUILE_PROGS, but
83 # guile-1.4 does not have GUILE_PROGS, so we have to do it manually.
84 AC_PATH_PROG(GUILE_CONFIG,guile-config)
85 if test "$GUILE_CONFIG" = "" ; then
86     AC_MSG_ERROR([guile-config required but not found])
88 AC_SUBST(GUILE_CONFIG)
90 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
93 # Check for guile end
94 ############################################################################
96 ############################################################################
97 # Check for mics things start
98
99 # Checking for rint in math library
100 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
102 # Checking for dynamic lib
103 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
105 # Check for mics things start
106 ############################################################################
108 ############################################################################
109 # Check for X11 start
112 if test "$MINGW" = "no"
113 then
114    AC_PATH_X
115    AC_PATH_XTRA 
116     
117    X_EXTRA_LIBS="$X_EXTRA_LIBS"
118    X_LDFLAGS="$X_LDFLAGS $X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS -lX11 -lm"
120    _use_rpath=no
121    AC_MSG_CHECKING([if hardcoding of the X11 runtime library path is desired])
122    AC_ARG_ENABLE([rpath],
123        [  --enable-rpath         Enable hardcoding the X11 runtime library path [default=disabled]],
124        [
125         if test "X$enable_rpath" = "Xno" ; then
126            AC_MSG_RESULT([no])
127            _use_rpath=no
128         else
129            AC_MSG_RESULT([yes])
130            _use_rpath=yes
131         fi
132        ],
133        [
134            AC_MSG_RESULT([no])
135            _use_rpath=no
136        ])
138    if test "X$_use_rpath" = "Xyes" ; then
139       # Try to figure out if we need -Rpath for finding X11 libs
140       # at runtime.  Why autoconf doesn't already do this, I don't
141       # know...
142       xlib_path=""
143       for p in $X_LDFLAGS ; do
144             case $p in
145             -L*)
146                 xlib_path="$xlib_path $p"
147                 ;;
148                 esac
149       done
151       _save_LIBS=$LIBS
152       LIBS="$LIBS $X_LDFLAGS"
153       rpath=""
154       for fl in "-Wl,-rpath " "-Wl,--rpath " "-rpath " "--rpath " "-Wl,-R" "-R" "-R " ; do
155           xlib_rpath=`echo $xlib_path | sed "s/-L/$fl/g"`
156           LIBS="$_save_LIBS $X_LIBS $xlib_rpath"
157           AC_MSG_CHECKING([if the compiler accepts ${fl}path for runtime libraries])
158           AC_LINK_IFELSE([AC_LANG_PROGRAM()],
159           AC_MSG_RESULT([yes])
160             rpath=$fl, 
161             AC_MSG_RESULT([no]))
162             test -n "$rpath" && break
163       done
164       if test -n "$rpath"; then
165          X_LDFLAGS="$X_LDFLAGS $xlib_rpath"
166       fi
167       LIBS=$_save_LIBS
168    fi
173 # Check for X11 end
174 ############################################################################
176 ############################################################################
177 # Check for gtk+ 2.2 start
180 # Check for pkg-config
181 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
182 if test $PKG_CONFIG = no; then
183    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
186 PKG_CHECK_MODULES(GTK22, gtk+-2.0 >= 2.2.0, GTK22="yes", no_GTK22="yes")
188 # This next bit of code figures out what gtk we need to use.
189 if test "$GTK22" = "yes"
190 then
192    AC_DEFINE(HAS_GTK22, 1, [If gtk+ 2.2.x has been installed, define this])
193    GTK_CFLAGS=$GTK22_CFLAGS
194    GTK_LIBS=$GTK22_LIBS
195    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
197    # Search for glib
198    PKG_CHECK_MODULES(GLIB22, glib-2.0 >= 2.2.0, GLIB22="yes", no_GLIB22="yes")
199    if test "$GLIB22" != "yes"
200    then
201        AC_MSG_ERROR([Cannot find glib 2.2.x, install it and rerun ./configure.])
202    fi
203    GLIB_CFLAGS=$GLIB22_CFLAGS
204    GLIB_LIBS=$GLIB22_LIBS
205    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
207 else
208    GTK_VERSION=""
211 if test "$GTK_VERSION" = ""
212 then
213    AC_MSG_ERROR([Cannot find gtk+ 2.2.x or later, please install gtk+.])
217 # Check for gtk+ 2.2 end
218 ############################################################################
220 ############################################################################
221 # Check for libgeda start
223 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $VERSION, LIBGEDA="yes", 
224                   no_LIBGEDA="yes")
226 if test "$LIBGEDA" = "yes" 
227 then
228    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
229 else
230    AC_MSG_ERROR([Cannot find libgeda (or libgeda.pc), please install libgeda])
234 # Check for libgeda end
235 ############################################################################
237 ############################################################################
238 # Check for libgdgeda start
239 # Do some very simple tests, as we just need to know if libgeda was
240 # built with libgdgeda support.
243 haslibgdgeda=`echo $LIBGEDA_LIBS | grep gdgeda`
244 if test "$haslibgdgeda" != ""; then
245    # Check disable-gdgeda command line flag value
246    if test "$no_gdgeda" = "yes"; then
247       echo found libgdgeda, but disabling gdgeda support
248       LIBGDGEDA=no
249    else 
250       AC_DEFINE(HAS_LIBGDGEDA, 1, [Define if you have libgdgeda installed])
251       LIBGDGEDA=yes
252    fi
253 else
254       LIBGDGEDA=no
258 # Check for libgdgeda end
259 ############################################################################
262 ############################################################################
263 # Check for libstroke start
266 # user specified --with-stroke
267 if eval "test x$opt_stroke != x"; then
268    LIBSTROKE_LIBS="-L$opt_stroke/lib"
269    LIBSTROKE_CFLAGS="-I$opt_stroke/include"
272 # only check if the user has not disable strokes
273 if test "$no_stroke" != "yes"; then
274    save_cppflags="$CPPFLAGS"
275    save_ldflags="$LDFLAGS"
276    CPPFLAGS="$CPPFLAGS $LIBSTROKE_CFLAGS"
277    LDFLAGS="$LDFLAGS $LIBSTROKE_LIBS"
278    AC_CHECK_LIB(stroke, stroke_init, LIBSTROKE="yes", LIBSTROKE="no")
279    CPPFLAGS="$save_cppflags"
280    LDFLAGS="$save_ldflags"
283 if test "$LIBSTROKE" = "yes"; then
284    AC_DEFINE(HAS_LIBSTROKE, 1, [Define if you have libstroke installed])
285    if eval "test x$opt_stroke = x"; then
286        LIBSTROKE_LIBS="-lstroke"
287        LIBSTROKE_CFLAGS=""
288    else
289        LIBSTROKE_LIBS="$LIBSTROKE_LIBS -lstroke"
290        # LIBSTROKE_CFLAGS set above
291    fi
294 if test "$no_stroke" = "yes"; then
295    echo "**                                **"
296    echo "** Disabling libstroke by request **"
297    echo "**                                **"
298    LIBSTROKE_LIB=""
299    LIBSTROKE_CFLAGS=""
300    LIBSTROKE="no"
304 # Check for libstroke end
305 ############################################################################
307 ############################################################################
308 # Check for notangle, noweave, texi2html, indent start
311 # Tangling is required if there is no C source files in the src/ 
312 # directory. Therefore they need to be extracted from the documented
313 # sources in noweb/ either with notangle or notangle_guile.
315 # notangle is the utility that comes with the noweb package.
316 # notangle_guile is a script that act the same as notangle
317 # but only require a guile interpreter with built-in module regex
318 # and getopt-long
320 # search for notangle
321 AC_PATH_PROG(NOTANGLE, notangle, no, ${PATH})
322 cfiles=`\ls -1 src/libgeda.c 2> /dev/null`
323 exit_status=$?
325 if test "$NOTANGLE" = "no" -a "$exit_status" = "1"; then
327    # notangle not found, and no C sources in src 
328    # need notangle_guile
329    echo "** Cannot find notangle (part of noweb) : using notangle_guile instead **"
330         
331    # find the guile interpreter
332    AC_PATH_PROG(GUILEINTERP, guile, no, ${PATH})
333    if test "$GUILEINTERP" = "no"; then
334       AC_MSG_ERROR([guile interpreter is required])
335    fi
336   
337    # check (ice-9 getopt-long) module in guile
338    AC_MSG_CHECKING([for getopt-long module in guile])
339    guilegetopt=`$GUILEINTERP -c  '(use-modules (ice-9 getopt-long))' 2> /dev/null`
340    exit_status=$?
341    if test "$exit_status" = "1"; then
342       AC_MSG_RESULT([no])
343       echo "no support for getopt-long module in guile interpreter"
344       AC_MSG_ERROR([this module is required by notangle_guile but is not available in the interpreter])
345    fi
346    AC_MSG_RESULT([yes])
348    # check (ice-9 regex) module in guile
349    AC_MSG_CHECKING([for regex module in guile])
350    guileregex=`$GUILEINTERP -c  '(use-modules (ice-9 regex))' 2> /dev/null`
351    exit_status=$?
352    if test ! "$exit_status" = "0"; then
353       AC_MSG_RESULT([no])
354       echo "no support for regex module in guile interpreter"
355       AC_MSG_ERROR([this module is required by notangle_guile but is not available in the interpreter])
356    fi
357    AC_MSG_RESULT([yes])
359    # set NOTANGLE and NOTANGLEROOT to use notangle_guile
360    # as the result of the previous tests
361    #  - NOTANGLE is the relative pathname to script from the source dir
362    #  - NOTANGLEROOT is the option to give the root code chunk name
363    #  - NOTANGLEFLAGS are other flags to notangle_guile
364    NOTANGLE="../scripts/notangle_guile"
365    NOTANGLEROOT="--rootname="
366    NOTANGLEFLAGS=""
368    echo "--            notangle_guile should work fine on this system           --"
370 else
372    # NOTANGLE has been set by AC_PATH_PROG above
373    NOTANGLEROOT="-R"
374    NOTANGLEFLAGS="-L"
378 # Weaving is extracting the documentation from the noweb files.
379 # The noweb package provides noweave to weave these files.
381 # The documentation is here written in Texinfo. A backend is 
382 # provided in scripts to format the code chunks in Texinfo.
384 # The noweave program is therefore required to produce the 
385 # documentation but building documentation is optionnal.
388 # search for noweave
389 AC_PATH_PROG(NOWEAVE, noweave, no, ${PATH})
390 # search for AWK
391 #  the noweb texinfo backend is based on awk. If awk is not available,
392 #  the backend will not work, and therefore it disables the 
393 #  documentation creation.
394 AC_PROG_AWK
396 if test "$NOWEAVE" = "no" -o "$AWK" = "no"; then 
397    # noweave is not available on the system
398    echo "** Cannot find noweave (part of noweb)! **"
399    echo "**   Documentation creation disabled    **"
400    NOWEAVE=echo
402    # prevent from weaving the nw files
403    # but does not prevent from processing gschemdoc
404    builddoc=false
405 else 
406    # noweave is available on the system.
407    # now checking if the tools for Texinfo files processing
408    # is installed.
409    # The docs can be either processed to produce dvi, html or info
410    # with texi2dvi, texi2html or makeinfo respectively
411    # Note : these tests on makeinfo and texi2dvi are no more 
412    #        needed as automake makes them for us
414    # enable the weaving of the nw files to get documentation
415    builddoc=true
418 # depending on variable builddoc, weaving is performed or not
419 # using conditionnal in docs/Makefile.in
420 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
422 # search for texi2html
423 # it looks like automake does not take care of html doc creation
424 AC_PATH_PROG(TEXI2HTML, texi2html, no, ${PATH})
426 if test "$TEXI2HTML" = "no"; then 
427    echo "**   Cannot find texi2html     **"
428    echo "** HTML file creation disabled **"
429    TEXI2HTML=echo
432 # search for indent
433 AC_PATH_PROG(INDENT, indent, no, ${PATH})
435 if ! test "$INDENT" = "no"; then 
436    indentversion=`$INDENT --version | grep GNU`
437 else 
438    indentversion=
441 if test "$INDENT" = "no" -o "$indentversion"x = x; then 
442   AC_PATH_PROG(GINDENT, gindent, no, ${PATH})
443   if test "$GINDENT" = "no"; then 
444     echo "** Cannot find GNU indent or gindent, C code formatting disabled **"
445     INDENT=echo
446   else
447     INDENT=$GINDENT
448   fi
452 # Check for notangle, noweave, texi2html, indent end
453 #########################################################################
455 #########################################################################
456 # Check for groff start
459 # search for groff
460 AC_PATH_PROG(GROFF, groff, no, ${PATH})
461 if test $GROFF = "no"; then
462         echo "Cannot find groff, some documentation will not be created."
466 # Check for groff end
467 #########################################################################
469 #########################################################################
470 # Checks for header files start
472 AC_HEADER_STDC
473 AC_HEADER_SYS_WAIT
474 AC_HEADER_DIRENT
475 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
476                  stdarg.h assert.h fcntl.h errno.h sys/param.h)
478 # Checks for typedefs, structures, and compiler characteristics.
479 AC_C_CONST
481 # Checks for library functions.
482 AC_TYPE_SIGNAL
483 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
485 AC_MSG_CHECKING([for optarg in unistd.h])
486 AC_TRY_COMPILE(
487 [#include <unistd.h>],
488 [ char *string = optarg; int i = optind; ],
489 optarg_found=yes,
490 optarg_found=no)
491 AC_MSG_RESULT($optarg_found)
493 if test $optarg_found = yes; then
494     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
498 # Checks for header files end
499 #########################################################################
501 #########################################################################
504 # ------------- dmalloc -------------------
505 dnl dmalloc checks
506 with_dmalloc="no"
507 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
508 AC_ARG_ENABLE([dmalloc],
509 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
511 if test "X$enable_dmalloc" != "Xno" ; then
512         AC_MSG_RESULT([yes])
513         AC_CHECK_HEADER(dmalloc.h,,
514                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
515         AC_CHECK_LIB(dmalloc,main,,
516                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
517         DMALLOC_LIBS="-ldmalloc"
518         with_dmalloc="yes"
519 else
520         AC_MSG_RESULT([no])
521         DMALLOC_LIBS=""
525         AC_MSG_RESULT([no])
526         DMALLOC_LIBS=""
529 # ------------- ElectricFence -------------------
530 dnl ElectricFence checks
531 with_efence="no"
532 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
533 AC_ARG_ENABLE([efence],
534 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
536 if test "X$enable_efence" != "Xno" ; then
537         AC_MSG_RESULT([yes])
538         AC_CHECK_LIB(efence,main,,
539                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
540         with_efence="yes"
541 else
542         AC_MSG_RESULT([no])
546 AC_MSG_RESULT([no])
550 #########################################################################
551 #########################################################################
552 # gEDA/gaf specific setup start
555 DATADIR=gEDA
556 GEDADATADIR=$datadir/$DATADIR
558 if eval "test x$opt_rcdir = x"; then
559         # path was not specified with --with-rcdir
560         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
561         GEDARCDIR=$GEDADATADIR
562 else
563         # path WAS specified with --with-rcdir
564         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
565         GEDARCDIR="$opt_rcdir"
568 # Expand the prefix variable
569 # I don't like the way this is done, but it works (I hope).
570 if eval "test x$prefix = xNONE"; then
571  dprefix=$ac_default_prefix
572 else
573  dprefix=$prefix
576 gedatopdir=$dprefix/share/$DATADIR
577 expandgedadatadir=`echo $gedatopdir`
579 gedadocdir=$dprefix/share/doc/geda-doc
580 # --with-docdir : tells where to store documentation if not default
581 AC_ARG_WITH(docdir,
582     [  --with-docdir      Where to store documentation if not default.],
583         gedadocdir=$withval)
584 expandgedadocdir=`echo $gedadocdir`
585 GEDADOCDIR=$expandgedadocdir
586 AC_SUBST(GEDADOCDIR)
588 # this has to be expanded ( no ${prefix} ) --
589 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
590 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Currently running version of gEDA/gaf])
593 # gEDA/gaf specify things which need to setup
594 #########################################################################
596 # Initialized gettext 
597 AM_GNU_GETTEXT
598 AM_GNU_GETTEXT_VERSION(0.12.1)
600 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
601 GSCHEM_CFLAGS="$LIBSTROKE_CFLAGS $LIBGEDA_CFLAGS"
602 GSCHEM_LDFLAGS="$LIBSTROKE_LIBS $LIBGEDA_LIBS $GTK_LIBS $X_LDFLAGS $DMALLOC_LIBS" 
604 # Makefile.in variable substitution
605 AC_SUBST(GSCHEM_CFLAGS)
606 AC_SUBST(GSCHEM_LDFLAGS)
607 AC_SUBST(GEDADATADIR)
608 AC_SUBST(GEDARCDIR)
609 AC_SUBST(PATHSEP)
610 AC_SUBST(OTHERPATHSEP)
611 AC_SUBST(NOTANGLE)
612 AC_SUBST(NOTANGLEROOT)
613 AC_SUBST(NOTANGLEFLAGS)
614 AC_SUBST(GUILEINTERP)
615 AC_SUBST(NOWEAVE)
616 AC_SUBST(TEXI2HTML)
617 AC_SUBST(INDENT)
619 # Create all the necessary derived files
620 AC_CONFIG_FILES([Makefile 
621                 m4/Makefile 
622                 po/Makefile.in 
623                 intl/Makefile 
624                 src/Makefile
625                 include/Makefile
626                 scheme/Makefile
627                 bitmap/Makefile
628                 scripts/Makefile
629                 examples/Makefile
630                 docs/Makefile
631                 lib/Makefile
632                 noweb/Makefile
633                 tests/Makefile
634                 lib/system-gschemrc
635                 scripts/geda_totexi
636                 scripts/notangle_guile ])
638 AC_CONFIG_COMMANDS([geda_totexi-chmod],[[chmod +x scripts/geda_totexi]],[[]])
639 AC_CONFIG_COMMANDS([notangle_guile-chmod],[[chmod +x scripts/notangle_guile]],[[]])
641 AC_OUTPUT
643 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
644 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
645 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
647 AC_MSG_RESULT([
648 ** Configuration summary for $PACKAGE $VERSION:
650    GTK+ library version:             $GTK_VERSION
651    GUILE library version:            $GUILE_VERSION
652    libgeda library version:          $LIBGEDA_VERSION
653    libstroke library:                $LIBSTROKE
654    libdgeda library:                 $LIBGDGEDA
655    mingw build:                      $MINGW
656    data directory:                   $expandedGEDADATADIR
657    rc directory:                     $expandedGEDARCDIR
658    documentation directory:          $expandedGEDADOCDIR
659    dmalloc debugging:                $with_dmalloc
660    ElectricFence debugging:          $with_efence