1 dnl Process this file with autoconf to produce a configure script.
3 AC_CONFIG_SRCDIR([noweb/gschem.nw])
5 dnl Initialize automake stuff
10 # new way of doing version
13 echo Configuring gschem version $VERSION
15 dnl --disable-strokes : turn off stroke support
16 AC_ARG_ENABLE(strokes,
17 [ --disable-strokes Disable stroke support (don't use LibStroke at all)],
19 if test $enableval = "no"; then
24 dnl --disable-gdgeda : turn off libgdgeda support
26 [ --disable-gdgeda Disable libgdgeda support (don't use libgdgeda at all)],
28 if test $enableval = "no"; then
33 dnl --enable-debug : turn on debugging support (normally off)
35 [ --enable-debug Enable debugging support],
37 if test $enableval = "no"; then
42 dnl Change default location of gtk-config
43 AC_ARG_WITH(gtk-config, [ --with-gtk-config=path Change where gtk-config is located], [opt_gtkconfig=$withval])
45 dnl Change default location for rc files
46 AC_ARG_WITH(rcdir, [ --with-rcdir=path Change where the system-*rc files are installed], [opt_rcdir=$withval])
48 dnl Initialize automake stuff
49 dnl AM_INIT_AUTOMAKE($PACKAGE, $GEDA_VER_MAJOR.$GEDA_VER_MINOR.$GEDA_VER_MICRO, no-define)
50 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
52 dnl Create a configuration header
53 AM_CONFIG_HEADER(config.h)
55 dnl Build time sanity check...
58 dnl Initialize maintainer mode
61 dnl Checks for programs.
69 if test "$CYGWIN" = "yes"; then
70 AC_MSG_ERROR(Building gEDA/gaf under cygwin is not supported)
78 dnl Check if scm_run_hook are defined
79 AC_CHECK_LIB(guile, scm_run_hook,,
80 AC_MSG_ERROR(**Upgrade Guile** At least version >= 1.3.2),
83 dnl Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
86 dnl Check if scm_hook_empty_p are defined
87 AC_CHECK_LIB(guile, scm_hook_empty_p,,
88 AC_MSG_ERROR(**Upgrade Guile** At least version >= 1.3.2),
91 dnl Restore LIBS. Apperantly AC_CHECK_LIB destroys it.
94 saved_cflags="$CFLAGS"
95 saved_ldflags="$LDFLAGS"
97 dnl Checks for header files.
101 CFLAGS="$X_CFLAGS $CFLAGS"
102 LDFLAGS="$X_LDFLAGS $X_LIBS $LDFLAGS"
103 X_EXTRA_LIBS="$X_EXTRA_LIBS -lX11 -lm"
105 dnl Checks for X libraries.
106 AC_CHECK_LIB(X11, XOpenDisplay, X_LIBS="-lX11", X_LIBS=no, $X_EXTRA_LIBS)
107 AC_CHECK_LIB(Xext, XShmAttach, X_LIBS="-lXext $X_LIBS", X_EXT=no, $X_EXTRA_LIBS)
108 dnl AC_CHECK_LIB(Xext, XShmAttach, X_LIBS="-lXext $X_LIBS", XEXT=no, $X_EXTRA_LIBS)
110 if test "$MINGW32" = "no" -o "$MINGW32"x = x; then
111 if test "$X_LIBS" = no; then
112 AC_MSG_ERROR(Cannot find -lX11 library)
115 echo X11 not required for MINGW32 port
118 dnl Checking for rint in math library
119 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT), no_RINT="yes")
121 dnl Checking for dynamic lib
122 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
124 if eval "test x$opt_gtkconfig != x" ; then
126 if test ! -r "$opt_gtkconfig"; then
128 AC_MSG_ERROR(Cannot find $opt_gtkconfig -- be sure that this pathname is correct)
131 GTK_CONFIG=$opt_gtkconfig
134 AM_PATH_GTK(1.2.3,,AC_MSG_ERROR([*** GTK+ >= 1.2.3 not installed - please install first ***]))
137 if test $GTK_CONFIG = "no"; then
138 AC_MSG_ERROR(Cannot find gtk-config -- be sure that gtk >= 0.99.7 is installed)
141 gtk_ldflags="`$GTK_CONFIG --libs`"
142 gtk_cflags="`$GTK_CONFIG --cflags`"
144 # search for libgdgeda-config
145 AC_PATH_PROG(LIBGDGEDACONFIG, libgdgeda-config, no, ${PATH})
147 if test $LIBGDGEDACONFIG = "no" -o no_gdgeda = yes; then
152 libgdgeda_ldflags=`$LIBGDGEDACONFIG --libs`
153 libgdgeda_cflags=`$LIBGDGEDACONFIG --cflags`
154 GD_EXTRA="$libgdgeda_cflags $libgdgeda_ldflags -lm"
155 X_CFLAGS="$libgdgeda_cflags"
157 AC_CHECK_LIB(z, uncompress, Z_LIB="-lz", Z_LIB=no)
158 if test $Z_LIB = no; then
159 AC_MSG_ERROR(Cannot find libz (zlib), be sure to install zlib; it is required for libgdgeda)
163 AC_CHECK_LIB(png, png_read_png, PNG_LIB="-lpng", PNG_LIB=no, $PNG_EXTRA)
165 if test $PNG_LIB = no; then
166 AC_MSG_ERROR(Cannot find libpng, be sure to install png; it is required for libgdgeda)
168 AC_CHECK_LIB(gdgeda, gdImageColorAllocate, GDGEDA_LIB="-lgdgeda", GDGEDA_LIB=no, $GD_EXTRA)
170 if test $GDGEDA_LIB = no; then
176 AC_DEFINE(HAS_LIBPNG)
177 AC_DEFINE(HAS_LIBGDGEDA)
183 # search for gtkextra-config
184 AC_PATH_PROG(GTKEXTRACONFIG, gtkextra-config, no, ${PATH})
186 if test $GTKEXTRACONFIG = "no"; then
190 gtkextra_ldflags=`$GTKEXTRACONFIG --libs`
191 gtkextra_cflags=`$GTKEXTRACONFIG --cflags`
192 GTK_EXTRA="$gtk_cflags $gtkextra_cflags $gtkextra_ldflags $gtk_ldflags -lm"
193 AC_CHECK_LIB(gtkextra, gtk_sheet_new, GTKEXTRA_LIB="-lgtkextra", GTKEXTRA_LIB=no, $GTK_EXTRA)
194 if test $GTKEXTRA_LIB = "no"; then
195 AC_MSG_ERROR(gtkextra library improperly installed)
197 AC_DEFINE(HAS_LIBGTKEXTRA)
201 # search for libgeda-config
202 AC_PATH_PROG(LIBGEDACONFIG, libgeda-config, no, ${PATH})
204 if test $LIBGEDACONFIG = "no"; then
205 AC_MSG_ERROR(Cannot find libgeda-config -- be sure that libgeda is installed)
209 libgeda_version=`$LIBGEDACONFIG --version`
210 if test $libgeda_version != $VERSION; then
211 AC_MSG_ERROR(Found a different version of libgeda-config: $LIBGEDACONFIG -- Make sure your PATH variable is correct)
215 # search for gesym-config
216 AC_PATH_PROG(GESYMCONFIG, gesym-config, no, ${PATH})
218 if test $GESYMCONFIG = "no"; then
219 AC_MSG_ERROR(Cannot find gesym-config -- be sure that the symbols are installed)
222 gesym_version=`$GESYMCONFIG --version`
223 if test $gesym_version != $VERSION; then AC_MSG_ERROR(Found a different version of gesym-config: $GESYMCONFIG -- Make sure your PATH variable is correct)
226 AC_CHECK_LIB(stroke, stroke_init, STROKE_LIB="-lstroke", STROKE_LIB=no)
228 if test $STROKE_LIB = no; then
231 if test "$no_strokes" = "yes"; then
232 echo found libstroke, but disabling strokes
235 AC_DEFINE(HAS_LIBSTROKE)
239 # here is where the final X ld/c flags get set
245 X_LDFLAGS="`$LIBGEDACONFIG --libs` $libgdgeda_ldflags $gtkextra_ldflags $gtk_ldflags"
246 X_CFLAGS="$gtk_cflags $libgdgeda_cflags $gtkextra_cflags `$LIBGEDACONFIG --cflags`"
247 gtkversion=`$GTK_CONFIG --version | cut -d. -f1,2`
249 AC_DEFINE_UNQUOTED(GTKVERSION, "$gtkversion")
251 dnl old way of doing this, see if new way works
252 dnl CFLAGS="$CFLAGS $CFEXTRA `$GTK_CONFIG --cflags`"
254 CFLAGS="`$GTK_CONFIG --cflags` $CFLAGS $CFEXTRA"
255 LDFLAGS="$LDEXTRA `$GTK_CONFIG --libs` $LDFLAGS"
257 AC_MSG_CHECKING([for the rest of gtk])
259 [#include <gtk/gtk.h>],
260 [GtkArgSetFunc arg_set_func;],
263 AC_MSG_RESULT($gtk_found)
265 if test $gtk_found = no; then
266 AC_MSG_ERROR(Cannot include/link gtk/gdk/glib--check CFLAGS/LDFLAGS)
269 LDFLAGS="$saved_ldflags $LDEXTRA"
270 CFLAGS="$saved_cflags $CFEXTRA"
272 if ! test "$MINGW32" = "no" -o "$MINGW32"x = x; then
273 echo Including -fnative-struct in CFLAGS for MINGW32 port
274 echo Including -mwindows in CFLAGS for MINGW32 port
275 echo Including -lregex in LDFLAGS for MINGW32 port
276 CFLAGS="$CFLAGS -fnative-struct -mwindows"
277 X_LDFLAGS="-lregex -liberty $X_LDFLAGS"
285 if test "$debug" = "yes"; then
290 # Tangling is required if there is no C source files in the src/
291 # directory. Therefore they need to be extracted from the documented
292 # sources in noweb/ either with notangle or notangle_guile.scm.
294 # notangle is the utility that comes with the noweb package.
295 # notangle_guile.scm is a script that act the same as notangle
296 # but only require a guile interpreter with built-in module regex
299 # search for notangle
300 AC_PATH_PROG(NOTANGLE, notangle, no, ${PATH})
301 # BUG: should check *ALL* files and dependencies!
302 cfiles=`\ls -1 src/gschem.c 2> /dev/null`
305 if test "$NOTANGLE" = "no" -a "$exit_status" = "1"; then
306 # notangle not found, and no C sources in src
307 # need notangle_guile.scm
308 echo "** Cannot find notangle (part of noweb) : using notangle_guile.scm instead **"
310 # find the guile interpreter
311 AC_PATH_PROG(GUILEINTERP, guile, no, ${PATH})
312 if test "$GUILEINTERP" = "no"; then
313 AC_MSG_ERROR(guile interpreter is required)
316 # check (ice-9 getopt-long) module in guile
317 AC_MSG_CHECKING([for getopt-long module in guile])
318 guilegetopt=`$GUILEINTERP -c '(use-modules (ice-9 getopt-long))' 2> /dev/null`
320 if test "$exit_status" = "1"; then
322 echo "no support for getopt-long module in guile interpreter"
323 AC_MSG_ERROR(this module is required by notangle_guile.scm but is not available in the interpreter)
327 # check (ice-9 regex) module in guile
328 AC_MSG_CHECKING([for regex module in guile])
329 guileregex=`$GUILEINTERP -c '(use-modules (ice-9 regex))' 2> /dev/null`
331 if test ! "$exit_status" = "0"; then
333 echo "no support for regex module in guile interpreter"
334 AC_MSG_ERROR(this module is required by notangle_guile.scm but is not available in the interpreter)
338 # set NOTANGLE and NOTANGLEROOT to use notangle_guile.scm
339 # as the result of the previous tests
340 # - NOTANGLE is the relative pathname to script from the source dir
341 # - NOTANGLEROOT is the option to give the root code chunk name
342 # - NOTANGLEFLAGS are other flags to notangle_guile.scm
343 NOTANGLE="../scripts/notangle_guile.scm"
344 NOTANGLEROOT="--rootname="
347 echo "-- notangle_guile.scm should work fine on this system --"
350 # NOTANGLE has been set by AC_PATH_PROG above
357 # Weaving is extracting the documentation from the noweb files.
358 # The noweb package provides noweave to weave these files.
360 # The documentation is here written in Texinfo. A backend is
361 # provided in scripts to format the code chunks in Texinfo.
363 # The noweave program is therefore required to produce the
364 # documentation but building documentation is optionnal.
368 AC_PATH_PROG(NOWEAVE, noweave, no, ${PATH})
370 # the noweb texinfo backend is based on awk. If awk is not available,
371 # the backend will not work, and therefore it disables the
372 # documentation creation.
375 if test "$NOWEAVE" = "no" -o "$AWK" = "no"; then
376 # noweave is not available on the system
377 echo "** Cannot find noweave (part of noweb)! **"
378 echo "** Documentation creation disabled **"
381 # prevent from weaving the nw files
382 # but does not prevent from processing gschemdoc
386 # noweave is available on the system.
387 # now checking if the tools for Texinfo files processing
389 # The docs can be either processed to produce dvi, html or info
390 # with texi2dvi, texi2html or makeinfo respectively
391 # Note : these tests on makeinfo and texi2dvi are no more
392 # needed as automake makes them for us
394 # enable the weaving of the nw files to get documentation
399 # depending on variable builddoc, weaving is performed or not
400 # using conditionnal in docs/Makefile.in
401 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
403 # search for texi2html
404 # it looks like automake does not take care of html doc creation
405 AC_PATH_PROG(TEXI2HTML, texi2html, no, ${PATH})
407 if test "$TEXI2HTML" = "no"; then
408 echo "** Cannot find texi2html **"
409 echo "** HTML file creation disabled **"
415 AC_PATH_PROG(INDENT, indent, no, ${PATH})
417 if ! test "$INDENT" = "no"; then
418 indentversion=`$INDENT --version | grep GNU`
423 if test "$INDENT" = "no" -o "$indentversion"x = x; then
424 AC_PATH_PROG(GINDENT, gindent, no, ${PATH})
426 if test "$GINDENT" = "no"; then
427 echo "** Cannot find GNU indent or gindent, C code formatting disabled **"
437 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
438 stdarg.h assert.h fcntl.h errno.h sys/param.h)
440 dnl Checks for typedefs, structures, and compiler characteristics.
443 dnl Checks for library functions.
445 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
447 AC_MSG_CHECKING([for optarg in unistd.h])
449 [#include <unistd.h>],
450 [ char *string = optarg; int i = optind; ],
453 AC_MSG_RESULT($optarg_found)
455 if test $optarg_found = yes; then
456 AC_DEFINE(OPTARG_IN_UNISTD)
459 gedatopdir=`$GESYMCONFIG --toplevel`
462 if eval "test x$opt_rcdir = x"; then
463 # path was not specified with --with-rcdir
464 # don't set the GEDARCDIR in config.h
465 AC_DEFINE_UNQUOTED(GEDARCDIR, "none")
466 GEDARCDIR="$gedatopdir"
468 # path WAS specified with --with-rcdir
469 AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir")
470 GEDARCDIR="$opt_rcdir"
474 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir")
475 GEDADATADIR=$gedatopdir
478 AM_GNU_GETTEXT_VERSION(0.11.5)
480 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
485 AC_SUBST(GEDADATADIR)
487 AC_SUBST(OTHERPATHSEP)
499 AC_SUBST(NOTANGLEROOT)
500 AC_SUBST(NOTANGLEFLAGS)
501 AC_SUBST(GUILEINTERP)
506 AC_CONFIG_FILES([Makefile m4/Makefile po/Makefile.in intl/Makefile \
517 lib/system-gschemrc \
518 scripts/geda_totexi \
519 scripts/notangle_guile.scm ])
520 AC_CONFIG_COMMANDS([geda_totexi-chmod],[[chmod +x scripts/geda_totexi]],[[]])
521 AC_CONFIG_COMMANDS([notangle_guile.scm-chmod],[[chmod +x scripts/notangle_guile.scm]],[[]])