Bumped package version to 20061020
[geda-gaf/peter-b.git] / gschem / configure.ac
blob66fa0904c648c5d8fc748d79178336f2c584ac4d
1 # $Id$
3 # Process this file with autoconf to produce a configure script.
4 AC_INIT
5 AC_CONFIG_SRCDIR([src/gschem.c])
6 AC_PREREQ(2.54)
8 PACKAGE=geda-gschem
9 VERSION=20061020
10 echo Configuring $PACKAGE version $VERSION
12 # Initialize automake 
13 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
14 AM_CONFIG_HEADER([config.h])
16 # Initialize maintainer mode
17 AM_MAINTAINER_MODE
20 #########################################################################
21 # Command line flags start
22
23 # --disable-stroke : turn off stroke support
24 AC_ARG_ENABLE(stroke,
25     [  --disable-stroke       Disable stroke support (don't use LibStroke at all)], [ if test $enableval = "no"; then
26          no_stroke=yes
27         fi ])
29 # --disable-gd : turn off libgd support
30 AC_ARG_ENABLE(gd,
31     [  --disable-gd        Disable libgd support (don't use libgd at all)], [ if test $enableval = "no"; then
32             no_gd=yes
33            fi ])
35 # Change default location for rc files
36 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
38 # Allow the user to specify where there libstroke library lives
39 AC_ARG_WITH(stroke, [  --with-stroke=DIR       Tell configure where to find libstroke], [opt_stroke=$withval])
41
42 # Command line flags end
43 #########################################################################
45 #########################################################################
46
47 # Misc win32 / mingw checks and variables start
48 AC_CANONICAL_HOST
50 # Figure out if we are building on win32 and what environment.
51 case $host_os in
52   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
53 esac
55 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
56    MINGW="yes"
57    PATHSEP=\\\\
58    OTHERPATHSEP=/
59 else
60    # Unix host
61    MINGW="no"
62    PATHSEP=/
63    OTHERPATHSEP=\\\\
66
67 # Misc win32 / mingw checks and variables end
68 #########################################################################
70 # Checks for programs.
71 AC_PROG_CC
72 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
73 AC_PROG_CPP
74 AC_PROG_MAKE_SET
76 ############################################################################
77 # Check for guile start
78 # Do a very basic guile test, as the bulk of the flags will come from 
79 # libgeda.pc
81 GUILE_FLAGS
83 # Manually search for guile-config.  This is provided by GUILE_PROGS, but
84 # guile-1.4 does not have GUILE_PROGS, so we have to do it manually.
85 AC_PATH_PROG(GUILE_CONFIG,guile-config)
86 if test "$GUILE_CONFIG" = "" ; then
87     AC_MSG_ERROR([guile-config required but not found])
89 AC_SUBST(GUILE_CONFIG)
91 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
94 # Check for guile end
95 ############################################################################
97 ############################################################################
98 # Check for mics things start
99
100 # Checking for rint in math library
101 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
103 # Checking for dynamic lib
104 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
106 # Check for mics things start
107 ############################################################################
109 ############################################################################
110 # Check for X11 start
113 if test "$MINGW" = "no"
114 then
115    AC_PATH_X
116    AC_PATH_XTRA 
117     
118    X_EXTRA_LIBS="$X_EXTRA_LIBS"
119    X_LDFLAGS="$X_LDFLAGS $X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS -lX11 -lm"
121    _use_rpath=no
122    AC_MSG_CHECKING([if hardcoding of the X11 runtime library path is desired])
123    AC_ARG_ENABLE([rpath],
124        [  --enable-rpath         Enable hardcoding the X11 runtime library path [default=disabled]],
125        [
126         if test "X$enable_rpath" = "Xno" ; then
127            AC_MSG_RESULT([no])
128            _use_rpath=no
129         else
130            AC_MSG_RESULT([yes])
131            _use_rpath=yes
132         fi
133        ],
134        [
135            AC_MSG_RESULT([no])
136            _use_rpath=no
137        ])
139    if test "X$_use_rpath" = "Xyes" ; then
140       # Try to figure out if we need -Rpath for finding X11 libs
141       # at runtime.  Why autoconf doesn't already do this, I don't
142       # know...
143       xlib_path=""
144       for p in $X_LDFLAGS ; do
145             case $p in
146             -L*)
147                 xlib_path="$xlib_path $p"
148                 ;;
149                 esac
150       done
152       _save_LIBS=$LIBS
153       LIBS="$LIBS $X_LDFLAGS"
154       rpath=""
155       for fl in "-Wl,-rpath " "-Wl,--rpath " "-rpath " "--rpath " "-Wl,-R" "-R" "-R " ; do
156           xlib_rpath=`echo $xlib_path | sed "s/-L/$fl/g"`
157           LIBS="$_save_LIBS $X_LIBS $xlib_rpath"
158           AC_MSG_CHECKING([if the compiler accepts ${fl}path for runtime libraries])
159           AC_LINK_IFELSE([AC_LANG_PROGRAM()],
160           AC_MSG_RESULT([yes])
161             rpath=$fl, 
162             AC_MSG_RESULT([no]))
163             test -n "$rpath" && break
164       done
165       if test -n "$rpath"; then
166          X_LDFLAGS="$X_LDFLAGS $xlib_rpath"
167       fi
168       LIBS=$_save_LIBS
169    fi
174 # Check for X11 end
175 ############################################################################
177 ############################################################################
178 # Check for gtk+ 2.4 start
181 # Check for pkg-config
182 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
183 if test $PKG_CONFIG = no; then
184    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
187 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
189 # This next bit of code figures out what gtk we need to use.
190 if test "$GTK24" = "yes"
191 then
193    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
194    GTK_CFLAGS=$GTK24_CFLAGS
195    GTK_LIBS=$GTK24_LIBS
196    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
198    # Search for glib
199    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
200    if test "$GLIB24" != "yes"
201    then
202        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
203    fi
204    GLIB_CFLAGS=$GLIB24_CFLAGS
205    GLIB_LIBS=$GLIB24_LIBS
206    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
208 else
209    GTK_VERSION=""
212 if test "$GTK_VERSION" = ""
213 then
214    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
218 # Check for gtk+ 2.4 end
219 ############################################################################
221 ############################################################################
222 # Check for libgeda start
224 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $VERSION, LIBGEDA="yes", 
225                   no_LIBGEDA="yes")
227 if test "$LIBGEDA" = "yes" 
228 then
229    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
230 else
231    AC_MSG_ERROR([Cannot find libgeda (or libgeda.pc), please install libgeda])
235 # Check for libgeda end
236 ############################################################################
238 ############################################################################
239 # Check for libgd start
240 # Do some very simple tests, as we just need to know if libgeda was
241 # built with libgd support.
244 if test "X$no_gd" != "Xyes"; then
245         AC_MSG_CHECKING([if libgeda was compiled with gdlib])
246         haslibgd=`$PKG_CONFIG --variable=LIBGEDA_HASGD libgeda`
247         if test "$haslibgd" != "yes"; then
248                 AC_MSG_WARN([libgeda was not built with libgd png support.
249 gschem will use the builtin png support.  If you want libgd png support, you 
250 must recompile libgeda with gdlib support.])
251                 LIBGD=no
252         else
253                 AC_MSG_RESULT([yes])
254                 LIBGD=yes
255         fi
256 else
257         LIBGD=no
262 # Check for libgd end
263 ############################################################################
266 ############################################################################
267 # Check for libstroke start
270 # user specified --with-stroke
271 if eval "test x$opt_stroke != x"; then
272    LIBSTROKE_LIBS="-L$opt_stroke/lib"
273    LIBSTROKE_CFLAGS="-I$opt_stroke/include"
276 # only check if the user has not disable strokes
277 if test "$no_stroke" != "yes"; then
278    save_cppflags="$CPPFLAGS"
279    save_ldflags="$LDFLAGS"
280    CPPFLAGS="$CPPFLAGS $LIBSTROKE_CFLAGS"
281    LDFLAGS="$LDFLAGS $LIBSTROKE_LIBS"
282    AC_CHECK_LIB(stroke, stroke_init, LIBSTROKE="yes", LIBSTROKE="no")
283    CPPFLAGS="$save_cppflags"
284    LDFLAGS="$save_ldflags"
287 if test "$LIBSTROKE" = "yes"; then
288    AC_DEFINE(HAS_LIBSTROKE, 1, [Define if you have libstroke installed])
289    if eval "test x$opt_stroke = x"; then
290        LIBSTROKE_LIBS="-lstroke"
291        LIBSTROKE_CFLAGS=""
292    else
293        LIBSTROKE_LIBS="$LIBSTROKE_LIBS -lstroke"
294        # LIBSTROKE_CFLAGS set above
295    fi
298 if test "$no_stroke" = "yes"; then
299    echo "**                                **"
300    echo "** Disabling libstroke by request **"
301    echo "**                                **"
302    LIBSTROKE_LIB=""
303    LIBSTROKE_CFLAGS=""
304    LIBSTROKE="no"
308 # Check for libstroke end
309 ############################################################################
311 ############################################################################
312 # Check for doxygen, indent start
314 # Doxygen is a utility for generating html and latex documentation
315 # from c source code files.
317 # search for Doxygen
318 AC_PATH_PROG(DOXYGEN, doxygen, no, ${PATH})
320 if test "$DOXYGEN" = "no"; then 
321    # doxygen is not available on the system
322    echo "** Cannot find Doxygen! **"
323    echo "**   Documentation creation disabled    **"
324    DOXYGEN=echo
326    # prevent from weaving the nw files
327    # but does not prevent from processing gschemdoc
328    builddoc=false
329 else 
330    # doxygen is available on the system.
331    # now checking if the tools for Texinfo files processing
332    # is installed.
333    # The docs can be either processed to produce dvi, html or info
334    # with texi2dvi, texi2html or makeinfo respectively
335    # Note : these tests on makeinfo and texi2dvi are no more 
336    #        needed as automake makes them for us
338    # enable the creation of html and latex documents.
339    builddoc=true
342 # depending on variable builddoc, weaving is performed or not
343 # using conditionnal in docs/Makefile.in
344 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
346 # search for indent
347 AC_PATH_PROG(INDENT, indent, no, ${PATH})
349 if ! test "$INDENT" = "no"; then 
350    indentversion=`$INDENT --version | grep GNU`
351 else 
352    indentversion=
355 if test "$INDENT" = "no" -o "$indentversion"x = x; then 
356   AC_PATH_PROG(GINDENT, gindent, no, ${PATH})
357   if test "$GINDENT" = "no"; then 
358     echo "** Cannot find GNU indent or gindent, C code formatting disabled **"
359     INDENT=echo
360   else
361     INDENT=$GINDENT
362   fi
366 # Check for doxygen, indent end
367 #########################################################################
369 #########################################################################
370 # Check for groff start
373 # search for groff
374 AC_PATH_PROG(GROFF, groff, no, ${PATH})
375 if test $GROFF = "no"; then
376         echo "Cannot find groff, some documentation will not be created."
380 # Check for groff end
381 #########################################################################
383 #########################################################################
384 # Checks for header files start
386 AC_HEADER_STDC
387 AC_HEADER_SYS_WAIT
388 AC_HEADER_DIRENT
389 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
390                  stdarg.h assert.h fcntl.h errno.h sys/param.h)
392 # Checks for typedefs, structures, and compiler characteristics.
393 AC_C_CONST
395 # Checks for library functions.
396 AC_TYPE_SIGNAL
397 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
399 AC_MSG_CHECKING([for optarg in unistd.h])
400 AC_TRY_COMPILE(
401 [#include <unistd.h>],
402 [ char *string = optarg; int i = optind; ],
403 optarg_found=yes,
404 optarg_found=no)
405 AC_MSG_RESULT($optarg_found)
407 if test $optarg_found = yes; then
408     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
412 # Checks for header files end
413 #########################################################################
415 #########################################################################
418 # ------------- dmalloc -------------------
419 dnl dmalloc checks
420 with_dmalloc="no"
421 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
422 AC_ARG_ENABLE([dmalloc],
423 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
425 if test "X$enable_dmalloc" != "Xno" ; then
426         AC_MSG_RESULT([yes])
427         AC_CHECK_HEADER(dmalloc.h,,
428                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
429         AC_CHECK_LIB(dmalloc,main,,
430                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
431         DMALLOC_LIBS="-ldmalloc"
432         with_dmalloc="yes"
433 else
434         AC_MSG_RESULT([no])
435         DMALLOC_LIBS=""
439         AC_MSG_RESULT([no])
440         DMALLOC_LIBS=""
443 # ------------- ElectricFence -------------------
444 dnl ElectricFence checks
445 with_efence="no"
446 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
447 AC_ARG_ENABLE([efence],
448 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
450 if test "X$enable_efence" != "Xno" ; then
451         AC_MSG_RESULT([yes])
452         AC_CHECK_LIB(efence,main,,
453                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
454         with_efence="yes"
455 else
456         AC_MSG_RESULT([no])
460 AC_MSG_RESULT([no])
464 #########################################################################
465 #########################################################################
466 # gEDA/gaf specific setup start
469 DATADIR=gEDA
470 GEDADATADIR=$datadir/$DATADIR
472 if eval "test x$opt_rcdir = x"; then
473         # path was not specified with --with-rcdir
474         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
475         GEDARCDIR=$GEDADATADIR
476 else
477         # path WAS specified with --with-rcdir
478         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
479         GEDARCDIR="$opt_rcdir"
482 # Expand the prefix variable
483 # I don't like the way this is done, but it works (I hope).
484 if eval "test x$prefix = xNONE"; then
485  dprefix=$ac_default_prefix
486 else
487  dprefix=$prefix
490 gedatopdir=$dprefix/share/$DATADIR
491 expandgedadatadir=`echo $gedatopdir`
493 gedadocdir=$dprefix/share/doc/geda-doc
494 # --with-docdir : tells where to store documentation if not default
495 AC_ARG_WITH(docdir,
496     [  --with-docdir      Where to store documentation if not default.],
497         gedadocdir=$withval)
498 expandgedadocdir=`echo $gedadocdir`
499 GEDADOCDIR=$expandgedadocdir
500 AC_SUBST(GEDADOCDIR)
502 # this has to be expanded ( no ${prefix} ) --
503 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
504 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Currently running version of gEDA/gaf])
507 # gEDA/gaf specify things which need to setup
508 #########################################################################
510 # Initialized gettext 
511 AM_GNU_GETTEXT
512 AM_GNU_GETTEXT_VERSION(0.12.1)
514 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
515 GSCHEM_CFLAGS="$LIBSTROKE_CFLAGS $LIBGEDA_CFLAGS"
516 GSCHEM_LDFLAGS="$LIBSTROKE_LIBS $LIBGEDA_LIBS $GTK_LIBS $X_LDFLAGS $DMALLOC_LIBS" 
518 # Makefile.in variable substitution
519 AC_SUBST(GSCHEM_CFLAGS)
520 AC_SUBST(GSCHEM_LDFLAGS)
521 AC_SUBST(GEDADATADIR)
522 AC_SUBST(GEDARCDIR)
523 AC_SUBST(PATHSEP)
524 AC_SUBST(OTHERPATHSEP)
525 AC_SUBST(GUILEINTERP)
526 AC_SUBST(INDENT)
528 # Create all the necessary derived files
529 AC_CONFIG_FILES([Makefile 
530                 m4/Makefile 
531                 po/Makefile.in 
532                 intl/Makefile 
533                 src/Makefile
534                 include/Makefile
535                 scheme/Makefile
536                 bitmap/Makefile
537                 scripts/Makefile
538                 examples/Makefile
539                 docs/Makefile
540                 lib/Makefile
541                 tests/Makefile
542                 lib/system-gschemrc ])
545 AC_OUTPUT
547 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
548 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
549 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
551 AC_MSG_RESULT([
552 ** Configuration summary for $PACKAGE $VERSION:
554    GTK+ library version:             $GTK_VERSION
555    GUILE library version:            $GUILE_VERSION
556    libgeda library version:          $LIBGEDA_VERSION
557    libstroke library:                $LIBSTROKE
558    libgd library:                    $LIBGD
559    mingw build:                      $MINGW
560    data directory:                   $expandedGEDADATADIR
561    rc directory:                     $expandedGEDARCDIR
562    documentation directory:          $expandedGEDADOCDIR
563    dmalloc debugging:                $with_dmalloc
564    ElectricFence debugging:          $with_efence