Bumped versions to 1.3.1/20080110/32:0:0 for the next development snapshot
[geda-gaf.git] / gschem / configure.ac.in
blob57f773d37fefde611ab79fb0419023af759e9b6f
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/gschem.c])
4 AC_PREREQ(2.54)
6 PACKAGE=geda-gschem
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])
14 AC_SUBST([CONFIG_DEPENDENCIES], ['$(top_srcdir)/configure.ac.in'])
16 # Call this to make autoconf and friends happy
17 AC_GNU_SOURCE
19 #########################################################################
20 # Command line flags start
21
22 # --disable-stroke : turn off stroke support
23 AC_ARG_ENABLE(stroke,
24     [  --disable-stroke       Disable stroke support (don't use LibStroke at all)], [ if test $enableval = "no"; then
25          no_stroke=yes
26         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 # Change default location for XDG files (.desktop and icons)
32 AC_ARG_WITH(xdgdatadir, [  --with-xdgdatadir=path  Change where the .desktop file and theme icons are installed [[DATADIR]]], [opt_xdgdatadir=$withval])
34 # Allow the user to specify where there libstroke library lives
35 AC_ARG_WITH(stroke, [  --with-stroke=DIR       Tell configure where to find libstroke], [opt_stroke=$withval])
37
38 # Command line flags end
39 #########################################################################
41 #########################################################################
42
43 # Misc win32 / mingw checks and variables start
44 AC_CANONICAL_HOST
46 # Figure out if we are building on win32 and what environment.
47 case $host_os in
48   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
49 esac
51 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
52    MINGW="yes"
53 else
54    # Unix host
55    MINGW="no"
58
59 # Misc win32 / mingw checks and variables end
60 #########################################################################
62 # Checks for programs.
63 AC_PROG_CC
64 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
65 AC_PROG_CPP
66 AC_PROG_MAKE_SET
67 IT_PROG_INTLTOOL(0.35.0)
69 ############################################################################
70 # Update desktop database utility start
73 AC_ARG_ENABLE(update-desktop-database,
74    AC_HELP_STRING([--disable-update-desktop-database],
75                    [do not update desktop file database after installation]),,
76                    enable_update_desktop_database=yes)
78 AM_CONDITIONAL(ENABLE_UPDATE_DESKTOP_DATABASE,
79                test x$enable_update_desktop_database = xyes)
81 if test x$enable_update_desktop_database = xyes ; then
82   AC_PATH_PROG(UPDATE_DESKTOP_DATABASE, [update-desktop-database], no)
83   if test $UPDATE_DESKTOP_DATABASE = no; then
84      AC_MSG_ERROR([Cannot find update-desktop-database, make sure it is installed and in your PATH, or configure with --disable-update-desktop-database])
85   fi
89 # Update desktop database utility end
90 ############################################################################
92 ############################################################################
93 # Check for guile start
94 GUILE_FLAGS
96 # Check Guile version
97 guile_need_major=1
98 guile_need_minor=6
99 guile_need_version="$guile_need_major[].$guile_need_minor.0"
101 AC_MSG_CHECKING([Guile version >= $guile_need_version])
102 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
104 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
105 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
106 AC_MSG_RESULT($GUILE_VERSION)
108 if test "$guile_need_major" -gt "$guile_major" \
109    || (test "$guile_need_major" -eq "$guile_major" \
110        && test "$guile_need_minor" -gt "$guile_minor"); then
111   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
114 # Guile 1.6 compatability
116 CFLAGS_temp_save="$CFLAGS"
117 CFLAGS="$CFLAGS $GUILE_CFLAGS"
118 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
119 scm_from_int,  scm_is_true,    scm_is_false,
120 scm_from_locale_string, scm_to_locale_string],,,
121 [#include <libguile.h>])
122 CFLAGS="$CFLAGS_temp_save"
124 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
125 #  define scm_is_string(x) SCM_STRINGP(x)
126 #endif])
127 AH_VERBATIM(SCM_IS_INTEGER, [#if !HAVE_DECL_SCM_IS_INTEGER
128 #  define scm_is_integer(x) SCM_INUMP(x)
129 #endif])
130 AH_VERBATIM(SCM_TO_INT, [#if !HAVE_DECL_SCM_TO_INT
131 #  define scm_to_int(x)     SCM_INUM(x)
132 #endif])
133 AH_VERBATIM(SCM_FROM_INT, [#if !HAVE_DECL_SCM_FROM_INT
134 #  define scm_from_int(x)   SCM_MAKINUM(x)
135 #endif])
136 AH_VERBATIM(SCM_IS_TRUE, [#if !HAVE_DECL_SCM_IS_TRUE
137 #  define scm_is_true(x)    SCM_NFALSEP(x)
138 #endif])
139 AH_VERBATIM(SCM_IS_FALSE, [#if !HAVE_DECL_SCM_IS_FALSE
140 #  define scm_is_false(x)   SCM_FALSEP(x)
141 #endif])
142 AH_VERBATIM(SCM_FROM_LOCALE_STRING, [#if !HAVE_DECL_SCM_FROM_LOCALE_STRING
143 #  define scm_from_locale_string(x) scm_makfrom0str(x)
144 #endif])
145 AH_VERBATIM(SCM_TO_LOCALE_STRING, [#if !HAVE_DECL_SCM_TO_LOCALE_STRING
146 #  define scm_to_locale_string(x)   strdup(SCM_STRING_CHARS(x))
147 #endif])
150 # Check for guile end
151 ############################################################################
153 ############################################################################
154 # Check for mics things start
156 # Checking for rint in math library
157 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
159 # Checking for dynamic lib
160 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
162 # Check for mics things start
163 ############################################################################
165 ############################################################################
166 # Check for X11 start
169 if test "$MINGW" = "no"
170 then
171    AC_PATH_X
172    AC_PATH_XTRA 
173     
174    X_EXTRA_LIBS="$X_EXTRA_LIBS"
175    X_LDFLAGS="$X_LDFLAGS $X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS -lX11 -lm"
177    _use_rpath=no
178    AC_MSG_CHECKING([if hardcoding of the X11 runtime library path is desired])
179    AC_ARG_ENABLE([rpath],
180        [  --enable-rpath         Enable hardcoding the X11 runtime library path [default=disabled]],
181        [
182         if test "X$enable_rpath" = "Xno" ; then
183            AC_MSG_RESULT([no])
184            _use_rpath=no
185         else
186            AC_MSG_RESULT([yes])
187            _use_rpath=yes
188         fi
189        ],
190        [
191            AC_MSG_RESULT([no])
192            _use_rpath=no
193        ])
195    if test "X$_use_rpath" = "Xyes" ; then
196       # Try to figure out if we need -Rpath for finding X11 libs
197       # at runtime.  Why autoconf doesn't already do this, I don't
198       # know...
199       xlib_path=""
200       for p in $X_LDFLAGS ; do
201             case $p in
202             -L*)
203                 xlib_path="$xlib_path $p"
204                 ;;
205                 esac
206       done
208       _save_LIBS=$LIBS
209       LIBS="$LIBS $X_LDFLAGS"
210       rpath=""
211       for fl in "-Wl,-rpath " "-Wl,--rpath " "-rpath " "--rpath " "-Wl,-R" "-R" "-R " ; do
212           xlib_rpath=`echo $xlib_path | sed "s/-L/$fl/g"`
213           LIBS="$_save_LIBS $X_LIBS $xlib_rpath"
214           AC_MSG_CHECKING([if the compiler accepts ${fl}path for runtime libraries])
215           AC_LINK_IFELSE([AC_LANG_PROGRAM()],
216           AC_MSG_RESULT([yes])
217             rpath=$fl, 
218             AC_MSG_RESULT([no]))
219             test -n "$rpath" && break
220       done
221       if test -n "$rpath"; then
222          X_LDFLAGS="$X_LDFLAGS $xlib_rpath"
223       fi
224       LIBS=$_save_LIBS
225    fi
230 # Check for X11 end
231 ############################################################################
233 ############################################################################
234 # Check for gtk+ 2.4 start
237 # Check for pkg-config
238 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
239 if test $PKG_CONFIG = no; then
240    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
243 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
245 # This next bit of code figures out what gtk we need to use.
246 if test "$GTK24" = "yes"
247 then
249    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
250    GTK_CFLAGS=$GTK24_CFLAGS
251    GTK_LIBS=$GTK24_LIBS
252    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
254    # Search for glib
255    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
256    if test "$GLIB24" != "yes"
257    then
258        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
259    fi
260    GLIB_CFLAGS=$GLIB24_CFLAGS
261    GLIB_LIBS=$GLIB24_LIBS
262    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
264    # Search for gthread
265    PKG_CHECK_MODULES(GTHREAD, gthread-2.0, GTHREAD="yes", no_GTHREAD="yes")
266    if test "$GTHREAD" = "yes"
267    then
268        AC_DEFINE(HAVE_GTHREAD, 1, [If gthread support is installed, define this])
269    fi
271 else
272    GTK_VERSION=""
275 if test "$GTK_VERSION" = ""
276 then
277    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
281 # Check for gtk+ 2.4 end
282 ############################################################################
284 ############################################################################
285 # Check for libgeda start
287 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
288                   no_LIBGEDA="yes")
290 if test "$LIBGEDA" = "yes" 
291 then
292    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
293 else
294    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
298 # Check for libgeda end
299 ############################################################################
301 ############################################################################
302 # Check for libstroke start
305 # user specified --with-stroke
306 if eval "test x$opt_stroke != x"; then
307    LIBSTROKE_LIBS="-L$opt_stroke/lib"
308    LIBSTROKE_CFLAGS="-I$opt_stroke/include"
311 # only check if the user has not disable strokes
312 if test "$no_stroke" != "yes"; then
313    save_cppflags="$CPPFLAGS"
314    save_ldflags="$LDFLAGS"
315    CPPFLAGS="$CPPFLAGS $LIBSTROKE_CFLAGS"
316    LDFLAGS="$LDFLAGS $LIBSTROKE_LIBS"
317    AC_CHECK_LIB(stroke, stroke_init, LIBSTROKE="yes", LIBSTROKE="no")
318    CPPFLAGS="$save_cppflags"
319    LDFLAGS="$save_ldflags"
322 if test "$LIBSTROKE" = "yes"; then
323    AC_DEFINE(HAS_LIBSTROKE, 1, [Define if you have libstroke installed])
324    if eval "test x$opt_stroke = x"; then
325        LIBSTROKE_LIBS="-lstroke"
326        LIBSTROKE_CFLAGS=""
327    else
328        LIBSTROKE_LIBS="$LIBSTROKE_LIBS -lstroke"
329        # LIBSTROKE_CFLAGS set above
330    fi
333 if test "$no_stroke" = "yes"; then
334    echo "**                                **"
335    echo "** Disabling libstroke by request **"
336    echo "**                                **"
337    LIBSTROKE_LIB=""
338    LIBSTROKE_CFLAGS=""
339    LIBSTROKE="no"
343 # Check for libstroke end
344 ############################################################################
346 ############################################################################
347 # Check for doxygen start
349 # Doxygen is a utility for generating html and latex documentation
350 # from c source code files.
352 # search for Doxygen
353 AC_PATH_PROG(DOXYGEN, doxygen, no, ${PATH})
355 if test "$DOXYGEN" = "no"; then 
356    # doxygen is not available on the system
357    echo "** Cannot find Doxygen! **"
358    echo "**   Documentation creation disabled    **"
359    DOXYGEN=echo
361    # prevent from weaving the nw files
362    # but does not prevent from processing gschemdoc
363    builddoc=false
364 else 
365    # doxygen is available on the system.
366    # now checking if the tools for Texinfo files processing
367    # is installed.
368    # The docs can be either processed to produce dvi, html or info
369    # with texi2dvi, texi2html or makeinfo respectively
370    # Note : these tests on makeinfo and texi2dvi are no more 
371    #        needed as automake makes them for us
373    # enable the creation of html and latex documents.
374    builddoc=true
377 # depending on variable builddoc, weaving is performed or not
378 # using conditionnal in docs/Makefile.in
379 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
382 # Check for doxygen end
383 #########################################################################
385 #########################################################################
386 # Check for groff start
389 # search for groff
390 AC_PATH_PROG(GROFF, groff, no, ${PATH})
391 if test $GROFF = "no"; then
392         echo "Cannot find groff, some documentation will not be created."
396 # Check for groff end
397 #########################################################################
399 #########################################################################
400 # Checks for header files start
402 AC_HEADER_STDC
403 AC_HEADER_SYS_WAIT
404 AC_HEADER_DIRENT
405 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
406                  stdarg.h assert.h fcntl.h errno.h sys/param.h)
408 # Check for locale.h
410 # Set USE_NLS
411 AM_NLS
412 AC_CHECK_HEADER([locale.h],
413                 [AC_DEFINE([HAVE_LOCALE_H], 1, [Define if you have locale.h])],
414                 [
415                   if test "$USE_NLS" = "yes"; then
416                     AC_MSG_ERROR([Cannot find useful locale.h, and nls support is enabled. Try compiling with --disable-nls])
417                   fi
418                 ])
420 # Set package name for translations
421 GETTEXT_PACKAGE=$PACKAGE
422 AC_SUBST(GETTEXT_PACKAGE)
424 # Checks for typedefs, structures, and compiler characteristics.
425 AC_C_CONST
427 # Checks for library functions.
428 AC_TYPE_SIGNAL
429 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf getuid getgid)
431 AC_MSG_CHECKING([for optarg in unistd.h])
432 AC_TRY_COMPILE(
433 [#include <unistd.h>],
434 [ char *string = optarg; int i = optind; ],
435 optarg_found=yes,
436 optarg_found=no)
437 AC_MSG_RESULT($optarg_found)
439 if test $optarg_found = yes; then
440     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
444 # Checks for header files end
445 #########################################################################
447 #########################################################################
450 # ------------- dmalloc -------------------
451 dnl dmalloc checks
452 with_dmalloc="no"
453 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
454 AC_ARG_ENABLE([dmalloc],
455 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
457 if test "X$enable_dmalloc" != "Xno" ; then
458         AC_MSG_RESULT([yes])
459         AC_CHECK_HEADER(dmalloc.h,,
460                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
461         AC_CHECK_LIB(dmalloc,main,,
462                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
463         DMALLOC_LIBS="-ldmalloc"
464         with_dmalloc="yes"
465 else
466         AC_MSG_RESULT([no])
467         DMALLOC_LIBS=""
471         AC_MSG_RESULT([no])
472         DMALLOC_LIBS=""
475 # ------------- ElectricFence -------------------
476 dnl ElectricFence checks
477 with_efence="no"
478 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
479 AC_ARG_ENABLE([efence],
480 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
482 if test "X$enable_efence" != "Xno" ; then
483         AC_MSG_RESULT([yes])
484         AC_CHECK_LIB(efence,main,,
485                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
486         with_efence="yes"
487 else
488         AC_MSG_RESULT([no])
492 AC_MSG_RESULT([no])
496 #########################################################################
497 #########################################################################
498 # gEDA/gaf specific setup start
501 DATADIR=gEDA
502 GEDADATADIR=$datadir/$DATADIR
504 if eval "test x$opt_rcdir = x"; then
505         # path was not specified with --with-rcdir
506         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
507         GEDARCDIR=$GEDADATADIR
508 else
509         # path WAS specified with --with-rcdir
510         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
511         GEDARCDIR="$opt_rcdir"
514 if test x$opt_xdgdatadir = x; then
515         # path was not specified with --with-xdgdatadir
516         XDGDATADIR='${datadir}'
517 else
518         # path WAS specified with --with-xdgdatadir
519         XDGDATADIR="$opt_xdgdatadir"
521 AC_SUBST(XDGDATADIR)
523 # Expand the prefix variable
524 # I don't like the way this is done, but it works (I hope).
525 if eval "test x$prefix = xNONE"; then
526  dprefix=$ac_default_prefix
527 else
528  dprefix=$prefix
531 gedatopdir=$dprefix/share/$DATADIR
532 expandgedadatadir=`echo $gedatopdir`
534 gedadocdir=$dprefix/share/doc/geda-doc
535 # --with-docdir : tells where to store documentation if not default
536 AC_ARG_WITH(docdir,
537     [  --with-docdir      Where to store documentation if not default.],
538         gedadocdir=$withval)
539 expandgedadocdir=`echo $gedadocdir`
540 GEDADOCDIR=$expandgedadocdir
541 AC_SUBST(GEDADOCDIR)
543 # this has to be expanded ( no ${prefix} ) --
544 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
545 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
546 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
547 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
550 # gEDA/gaf specify things which need to setup
551 #########################################################################
553 # Initialized gettext 
554 AM_GNU_GETTEXT
555 AM_GNU_GETTEXT_VERSION([%INSTALLED_GETTEXT_VERSION%])
557 #GETTEXT_PACKAGE=$PACKAGE
558 #AC_SUBST(GETTEXT_PACKAGE)
559 #AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"],
560 #                   [The domain to use with gettext])
561 #AM_GLIB_GNU_GETTEXT
563 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
564 GSCHEM_CFLAGS="$LIBSTROKE_CFLAGS $LIBGEDA_CFLAGS $GTHREAD_CFLAGS"
565 GSCHEM_LDFLAGS="$LIBSTROKE_LIBS $LIBGEDA_LIBS $GTK_LIBS $X_LDFLAGS $DMALLOC_LIBS $GTHREAD_LIBS"
567 # Makefile.in variable substitution
568 AC_SUBST(DATE_VERSION)
569 AC_SUBST(DOTTED_VERSION)
570 AC_SUBST(GSCHEM_CFLAGS)
571 AC_SUBST(GSCHEM_LDFLAGS)
572 AC_SUBST(GEDADATADIR)
573 AC_SUBST(GEDARCDIR)
574 AC_SUBST(GUILEINTERP)
575 AC_SUBST(INDENT)
577 # Create all the necessary derived files
578 AC_CONFIG_FILES([Makefile 
579                 m4/Makefile 
580                 po/Makefile.in 
581                 intl/Makefile 
582                 src/Makefile
583                 include/Makefile
584                 scheme/Makefile
585                 bitmap/Makefile
586                 scripts/Makefile
587                 scripts/config.sh
588                 examples/Makefile
589                 docs/Makefile
590                 lib/Makefile
591                 tests/Makefile
592                 data/Makefile
593                 lib/system-gschemrc ])
596 AC_OUTPUT
598 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
599 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
600 expandedXDGDATADIR=`eval "echo $XDGDATADIR"`
601 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
603 AC_MSG_RESULT([
604 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION:
606    GTK+ library version:             $GTK_VERSION
607    GUILE library version:            $GUILE_VERSION
608    libgeda library version:          $LIBGEDA_VERSION
609    libstroke library:                $LIBSTROKE
610    mingw build:                      $MINGW
611    data directory:                   $expandedGEDADATADIR
612    rc directory:                     $expandedGEDARCDIR
613    xdg directory:                    $expandedXDGDATADIR
614    documentation directory:          $expandedGEDADOCDIR
615    dmalloc debugging:                $with_dmalloc
616    ElectricFence debugging:          $with_efence