make dist changed it_IT.po file (cleanup checkin)
[geda-gaf/peter-b.git] / gschem / configure.ac
blob953e2b1b791e630725f754696b4c906cb7bbde94
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=20041228
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 # Force a specific version of gtk+          
37 AC_ARG_WITH(gtk12, [  --with-gtk12            Force the use of gtk+ 1.2.x], [opt_gtkver=1.2])
39 # Allow the user to specify where there libstroke library lives
40 AC_ARG_WITH(stroke, [  --with-stroke=DIR       Tell configure where to find libstroke], [opt_stroke=$withval])
42
43 # Command line flags end
44 #########################################################################
46 #########################################################################
47
48 # Misc win32 / mingw checks and variables start
49 AC_CANONICAL_HOST
51 # Figure out if we are building on win32 and what environment.
52 case $host_os in
53   *cygwin*  ) AC_MSG_ERROR([Building gEDA/gaf under cygwin is not supported]) ;;
54   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
55 esac
57 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
58    MINGW="yes"
59    PATHSEP=\\\\
60    OTHERPATHSEP=/
61 else
62    # Unix host
63    MINGW="no"
64    PATHSEP=/
65    OTHERPATHSEP=\\\\
68
69 # Misc win32 / mingw checks and variables end
70 #########################################################################
72 # Checks for programs.
73 AC_PROG_CC
74 AC_PROG_CPP
75 AC_PROG_MAKE_SET
77 ############################################################################
78 # Check for guile start
79 # Do a very basic guile test, as the bulk of the flags will come from 
80 # libgeda.pc
82 GUILE_FLAGS
84 # Manually search for guile-config.  This is provided by GUILE_PROGS, but
85 # guile-1.4 does not have GUILE_PROGS, so we have to do it manually.
86 AC_PATH_PROG(GUILE_CONFIG,guile-config)
87 if test "$GUILE_CONFIG" = "" ; then
88     AC_MSG_ERROR([guile-config required but not found])
90 AC_SUBST(GUILE_CONFIG)
92 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
95 # Check for guile end
96 ############################################################################
98 ############################################################################
99 # Check for mics things start
101 # Checking for rint in math library
102 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
104 # Checking for dynamic lib
105 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
107 # Check for mics things start
108 ############################################################################
110 ############################################################################
111 # Check for X11 start
114 if test "$MINGW" = "no"
115 then
116    AC_PATH_X
117    AC_PATH_XTRA 
118     
119    X_EXTRA_LIBS="$X_EXTRA_LIBS"
120    X_LDFLAGS="$X_LDFLAGS $X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS -lX11 -lm"
124 # Check for X11 end
125 ############################################################################
127 ############################################################################
128 # Check for gtk+ 1.2 and 2.2 start
131 # Check for pkg-config
132 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
133 if test $PKG_CONFIG = no; then
134    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
137 # Search for gtk+ 2.2.x first (only if we are not forcing the gtk+ to 1.2)
138 if test "$opt_gtkver" != "1.2"
139 then
140    PKG_CHECK_MODULES(GTK22, gtk+-2.0 >= 2.2.0, GTK22="yes", no_GTK22="yes")
143 # This next bit of code figures out what gtk we need to use.
144 if test "$GTK22" = "yes" -a "$opt_gtkver" != "1.2"
145 then
147    AC_DEFINE(HAS_GTK22, 1, [If gtk+ 2.2.x has been installed, define this])
148    GTK_CFLAGS=$GTK22_CFLAGS
149    GTK_LIBS=$GTK22_LIBS
150    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
152    # Search for glib
153    PKG_CHECK_MODULES(GLIB22, glib-2.0 >= 2.2.0, GLIB22="yes", no_GLIB22="yes")
154    if test "$GLIB22" != "yes"
155    then
156        AC_MSG_ERROR([Cannot find glib 2.2.x, install it and rerun ./configure.])
157    fi
158    GLIB_CFLAGS=$GLIB22_CFLAGS
159    GLIB_LIBS=$GLIB22_LIBS
160    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
162 else
164    # Search for gtk+ 1.2 now 
165    PKG_CHECK_MODULES(GTK12, gtk+ >= 1.2.3, GTK12="yes", no_GTK12="yes")
167    AC_DEFINE(HAS_GTK12, 1, [If gtk+ 1.2.x has been installed, define this])
168    GTK_CFLAGS=$GTK12_CFLAGS
169    GTK_LIBS=$GTK12_LIBS
170    GTK_VERSION=`$PKG_CONFIG gtk+ --modversion`
172    # Search for glib
173    PKG_CHECK_MODULES(GLIB12, glib >= 1.2.3, GLIB12="yes", no_GLIB12="yes")
174    if test "$GLIB12" != "yes"
175    then
176        AC_MSG_ERROR([Cannot find glib >= 1.2.3, install it and rerun ./configure.])
177    fi
178    GLIB_CFLAGS=$GLIB12_CFLAGS
179    GLIB_LIBS=$GLIB12_LIBS
180    GLIB_VERSION=`$PKG_CONFIG glib --modversion`
183 if test "$GTK_VERSION" = ""
184 then
185    AC_MSG_ERROR([Cannot find gtk+ 2.2.x or gtk+ 1.2.x, install one of them.])
189 # Check for gtk+ 1.2 and 2.2 end
190 ############################################################################
192 ############################################################################
193 # Check for libgeda start
195 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $VERSION, LIBGEDA="yes", 
196                   no_LIBGEDA="yes")
198 if test "$LIBGEDA" = "yes" 
199 then
200    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
201 else
202    AC_MSG_ERROR([Cannot find libgeda (or libgeda.pc), please install libgeda])
206 # Check for libgeda end
207 ############################################################################
209 ############################################################################
210 # Check for libgdgeda start
211 # Do some very simple tests, as we just need to know if libgeda was
212 # built with libgdgeda support.
215 haslibgdgeda=`echo $LIBGEDA_LIBS | grep gdgeda`
216 if test "$haslibgdgeda" != ""; then
217    # Check disable-gdgeda command line flag value
218    if test "$no_gdgeda" = "yes"; then
219       echo found libgdgeda, but disabling gdgeda support
220       LIBGDGEDA=no
221    else 
222       AC_DEFINE(HAS_LIBGDGEDA, 1, [Define if you have libgdgeda installed])
223       LIBGDGEDA=yes
224    fi
225 else
226       LIBGDGEDA=no
230 # Check for libgdgeda end
231 ############################################################################
234 ############################################################################
235 # Check for libstroke start
238 # user specified --with-stroke
239 if eval "test x$opt_stroke != x"; then
240    LIBSTROKE_LIBS="-L$opt_stroke/lib"
241    LIBSTROKE_CFLAGS="-I$opt_stroke/include"
244 # only check if the user has not disable strokes
245 if test "$no_stroke" != "yes"; then
246    save_cppflags="$CPPFLAGS"
247    save_ldflags="$LDFLAGS"
248    CPPFLAGS="$CPPFLAGS $LIBSTROKE_CFLAGS"
249    LDFLAGS="$LDFLAGS $LIBSTROKE_LIBS"
250    AC_CHECK_LIB(stroke, stroke_init, LIBSTROKE="yes", LIBSTROKE="no")
251    CPPFLAGS="$save_cppflags"
252    LDFLAGS="$save_ldflags"
255 if test "$LIBSTROKE" = "yes"; then
256    AC_DEFINE(HAS_LIBSTROKE, 1, [Define if you have libstroke installed])
257    if eval "test x$opt_stroke = x"; then
258        LIBSTROKE_LIBS="-lstroke"
259        LIBSTROKE_CFLAGS=""
260    else
261        LIBSTROKE_LIBS="$LIBSTROKE_LIBS -lstroke"
262        # LIBSTROKE_CFLAGS set above
263    fi
266 if test "$no_stroke" = "yes"; then
267    echo "**                                **"
268    echo "** Disabling libstroke by request **"
269    echo "**                                **"
270    LIBSTROKE_LIB=""
271    LIBSTROKE_CFLAGS=""
272    LIBSTROKE="no"
276 # Check for libstroke end
277 ############################################################################
279 ############################################################################
280 # Check for notangle, noweave, texi2html, indent start
283 # Tangling is required if there is no C source files in the src/ 
284 # directory. Therefore they need to be extracted from the documented
285 # sources in noweb/ either with notangle or notangle_guile.scm.
287 # notangle is the utility that comes with the noweb package.
288 # notangle_guile.scm is a script that act the same as notangle
289 # but only require a guile interpreter with built-in module regex
290 # and getopt-long
292 # search for notangle
293 AC_PATH_PROG(NOTANGLE, notangle, no, ${PATH})
294 cfiles=`\ls -1 src/libgeda.c 2> /dev/null`
295 exit_status=$?
297 if test "$NOTANGLE" = "no" -a "$exit_status" = "1"; then
299    # notangle not found, and no C sources in src 
300    # need notangle_guile.scm
301    echo "** Cannot find notangle (part of noweb) : using notangle_guile.scm instead **"
302         
303    # find the guile interpreter
304    AC_PATH_PROG(GUILEINTERP, guile, no, ${PATH})
305    if test "$GUILEINTERP" = "no"; then
306       AC_MSG_ERROR([guile interpreter is required])
307    fi
308   
309    # check (ice-9 getopt-long) module in guile
310    AC_MSG_CHECKING([for getopt-long module in guile])
311    guilegetopt=`$GUILEINTERP -c  '(use-modules (ice-9 getopt-long))' 2> /dev/null`
312    exit_status=$?
313    if test "$exit_status" = "1"; then
314       AC_MSG_RESULT([no])
315       echo "no support for getopt-long module in guile interpreter"
316       AC_MSG_ERROR([this module is required by notangle_guile.scm but is not available in the interpreter])
317    fi
318    AC_MSG_RESULT([yes])
320    # check (ice-9 regex) module in guile
321    AC_MSG_CHECKING([for regex module in guile])
322    guileregex=`$GUILEINTERP -c  '(use-modules (ice-9 regex))' 2> /dev/null`
323    exit_status=$?
324    if test ! "$exit_status" = "0"; then
325       AC_MSG_RESULT([no])
326       echo "no support for regex module in guile interpreter"
327       AC_MSG_ERROR([this module is required by notangle_guile.scm but is not available in the interpreter])
328    fi
329    AC_MSG_RESULT([yes])
331    # set NOTANGLE and NOTANGLEROOT to use notangle_guile.scm
332    # as the result of the previous tests
333    #  - NOTANGLE is the relative pathname to script from the source dir
334    #  - NOTANGLEROOT is the option to give the root code chunk name
335    #  - NOTANGLEFLAGS are other flags to notangle_guile.scm
336    NOTANGLE="../scripts/notangle_guile.scm"
337    NOTANGLEROOT="--rootname="
338    NOTANGLEFLAGS=""
340    echo "--            notangle_guile.scm should work fine on this system           --"
342 else
344    # NOTANGLE has been set by AC_PATH_PROG above
345    NOTANGLEROOT="-R"
346    NOTANGLEFLAGS="-L"
350 # Weaving is extracting the documentation from the noweb files.
351 # The noweb package provides noweave to weave these files.
353 # The documentation is here written in Texinfo. A backend is 
354 # provided in scripts to format the code chunks in Texinfo.
356 # The noweave program is therefore required to produce the 
357 # documentation but building documentation is optionnal.
360 # search for noweave
361 AC_PATH_PROG(NOWEAVE, noweave, no, ${PATH})
362 # search for AWK
363 #  the noweb texinfo backend is based on awk. If awk is not available,
364 #  the backend will not work, and therefore it disables the 
365 #  documentation creation.
366 AC_PROG_AWK
368 if test "$NOWEAVE" = "no" -o "$AWK" = "no"; then 
369    # noweave is not available on the system
370    echo "** Cannot find noweave (part of noweb)! **"
371    echo "**   Documentation creation disabled    **"
372    NOWEAVE=echo
374    # prevent from weaving the nw files
375    # but does not prevent from processing gschemdoc
376    builddoc=false
377 else 
378    # noweave is available on the system.
379    # now checking if the tools for Texinfo files processing
380    # is installed.
381    # The docs can be either processed to produce dvi, html or info
382    # with texi2dvi, texi2html or makeinfo respectively
383    # Note : these tests on makeinfo and texi2dvi are no more 
384    #        needed as automake makes them for us
386    # enable the weaving of the nw files to get documentation
387    builddoc=true
390 # depending on variable builddoc, weaving is performed or not
391 # using conditionnal in docs/Makefile.in
392 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
394 # search for texi2html
395 # it looks like automake does not take care of html doc creation
396 AC_PATH_PROG(TEXI2HTML, texi2html, no, ${PATH})
398 if test "$TEXI2HTML" = "no"; then 
399    echo "**   Cannot find texi2html     **"
400    echo "** HTML file creation disabled **"
401    TEXI2HTML=echo
404 # search for indent
405 AC_PATH_PROG(INDENT, indent, no, ${PATH})
407 if ! test "$INDENT" = "no"; then 
408    indentversion=`$INDENT --version | grep GNU`
409 else 
410    indentversion=
413 if test "$INDENT" = "no" -o "$indentversion"x = x; then 
414   AC_PATH_PROG(GINDENT, gindent, no, ${PATH})
415   if test "$GINDENT" = "no"; then 
416     echo "** Cannot find GNU indent or gindent, C code formatting disabled **"
417     INDENT=echo
418   else
419     INDENT=$GINDENT
420   fi
424 # Check for notangle, noweave, texi2html, indent end
425 #########################################################################
427 #########################################################################
428 # Check for groff start
431 # search for groff
432 AC_PATH_PROG(GROFF, groff, no, ${PATH})
433 if test $GROFF = "no"; then
434         echo "Cannot find groff, some documentation will not be created."
438 # Check for groff end
439 #########################################################################
441 #########################################################################
442 # Checks for header files start
444 AC_HEADER_STDC
445 AC_HEADER_SYS_WAIT
446 AC_HEADER_DIRENT
447 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
448                  stdarg.h assert.h fcntl.h errno.h sys/param.h)
450 # Checks for typedefs, structures, and compiler characteristics.
451 AC_C_CONST
453 # Checks for library functions.
454 AC_TYPE_SIGNAL
455 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
457 AC_MSG_CHECKING([for optarg in unistd.h])
458 AC_TRY_COMPILE(
459 [#include <unistd.h>],
460 [ char *string = optarg; int i = optind; ],
461 optarg_found=yes,
462 optarg_found=no)
463 AC_MSG_RESULT($optarg_found)
465 if test $optarg_found = yes; then
466     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
470 # Checks for header files end
471 #########################################################################
473 #########################################################################
474 # gEDA/gaf specific setup start
477 DATADIR=gEDA
478 GEDADATADIR=$datadir/$DATADIR
480 if eval "test x$opt_rcdir = x"; then
481         # path was not specified with --with-rcdir
482         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
483         GEDARCDIR=$GEDADATADIR
484 else
485         # path WAS specified with --with-rcdir
486         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
487         GEDARCDIR="$opt_rcdir"
490 # Expand the prefix variable
491 # I don't like the way this is done, but it works (I hope).
492 if eval "test x$prefix = xNONE"; then
493  dprefix=$ac_default_prefix
494 else
495  dprefix=$prefix
498 gedatopdir=$dprefix/share/$DATADIR
499 expandgedadatadir=`echo $gedatopdir`
501 gedadocdir=$dprefix/share/doc/geda-doc
502 # --with-docdir : tells where to store documentation if not default
503 AC_ARG_WITH(docdir,
504     [  --with-docdir      Where to store documentation if not default.],
505         gedadocdir=$withval)
506 expandgedadocdir=`echo $gedadocdir`
507 GEDADOCDIR=$expandgedadocdir
508 AC_SUBST(GEDADOCDIR)
510 # this has to be expanded ( no ${prefix} ) --
511 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
512 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Currently running version of gEDA/gaf])
515 # gEDA/gaf specify things which need to setup
516 #########################################################################
518 # Initialized gettext 
519 AM_GNU_GETTEXT
520 AM_GNU_GETTEXT_VERSION(0.12.1)
522 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
523 GSCHEM_CFLAGS="$LIBSTROKE_CFLAGS $LIBGEDA_CFLAGS"
524 GSCHEM_LDFLAGS="$LIBSTROKE_LIBS $LIBGEDA_LIBS $GTK_LIBS $X_LDFLAGS" 
526 # Makefile.in variable substitution
527 AC_SUBST(GSCHEM_CFLAGS)
528 AC_SUBST(GSCHEM_LDFLAGS)
529 AC_SUBST(GEDADATADIR)
530 AC_SUBST(GEDARCDIR)
531 AC_SUBST(PATHSEP)
532 AC_SUBST(OTHERPATHSEP)
533 AC_SUBST(NOTANGLE)
534 AC_SUBST(NOTANGLEROOT)
535 AC_SUBST(NOTANGLEFLAGS)
536 AC_SUBST(GUILEINTERP)
537 AC_SUBST(NOWEAVE)
538 AC_SUBST(TEXI2HTML)
539 AC_SUBST(INDENT)
541 # Create all the necessary derived files
542 AC_CONFIG_FILES([Makefile 
543                 m4/Makefile 
544                 po/Makefile.in 
545                 intl/Makefile 
546                 src/Makefile
547                 include/Makefile
548                 scheme/Makefile
549                 bitmap/Makefile
550                 scripts/Makefile
551                 examples/Makefile
552                 docs/Makefile
553                 lib/Makefile
554                 noweb/Makefile
555                 tests/Makefile
556                 lib/system-gschemrc
557                 scripts/geda_totexi
558                 scripts/notangle_guile.scm ])
560 AC_CONFIG_COMMANDS([geda_totexi-chmod],[[chmod +x scripts/geda_totexi]],[[]])
561 AC_CONFIG_COMMANDS([notangle_guile.scm-chmod],[[chmod +x scripts/notangle_guile.scm]],[[]])
563 AC_OUTPUT
565 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
566 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
567 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
569 AC_MSG_RESULT([
570 ** Configuration summary for $PACKAGE $VERSION:
572    GTK+ library version:             $GTK_VERSION
573    GUILE library version:            $GUILE_VERSION
574    libgeda library version:          $LIBGEDA_VERSION
575    libstroke library:                $LIBSTROKE
576    libdgeda library:                 $LIBGDGEDA
577    mingw build:                      $MINGW
578    data directory:                   $expandedGEDADATADIR
579    rc directory:                     $expandedGEDARCDIR
580    documentation directory:          $expandedGEDADOCDIR