Fix for Bug#1776547: graphical versus source
[geda-gaf/peter-b.git] / gnetlist / configure.ac
blobfbe6e50c06e50946a0a64b0b13f0b27739771fb9
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/gnetlist.c])
4 AC_PREREQ(2.54)
6 PACKAGE=geda-gnetlist
7 DOTTED_VERSION=1.1.2
8 DATE_VERSION=20070818
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])
15 #########################################################################
16 # Command line flags start
17
18 # Change default location for rc files
19 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
21 AC_MSG_CHECKING([For the default pcb installation data directory])
22 AC_ARG_WITH(pcb-datadir,
23         [  --with-pcb-datadir=path
24                           Change the default location for an installed pcb.  This is used
25                           to set the default search path for pcb newlib libraries.
26                           [[default=${datadir}]]],
27         [PCBDATADIR=$withval],
28         [PCBDATADIR="${datadir}"]
30 AC_MSG_RESULT([${PCBDATADIR}])
31 AC_SUBST(PCBDATADIR)
33 # Change default location for pcb's m4 library directory
34 AC_MSG_CHECKING([For the default pcb m4 directory])
35 AC_ARG_WITH(pcbm4dir,
36         [  --with-pcbm4dir=path     Change where the PCB m4 files are installed [[default=${PCBDATADIR}/pcb/m4]]],
37         [PCBM4DIR=$withval],
38         [PCBM4DIR="${PCBDATADIR}/pcb/m4"]
40 AC_MSG_RESULT([${PCBM4DIR}])
41 AC_SUBST(PCBM4DIR)
43 # Change default location for pcb's newlib library directory
44 AC_ARG_WITH(pcb-newlib-path,
45         [  --with-pcb-newlib-path=path   Change the default search path for PCB newlib libraries [[default=${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib:]]],
46         [PCBLIBPATH=$withval],
47         [PCBLIBPATH="${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib"]
49 AC_SUBST(PCBLIBPATH)
51 # Change default location for pcb's m4 site configuration directory
52 AC_ARG_WITH(pcbconfdir,
53         [  --with-pcbconfdir=path     Change where the PCB site config files are installed [[default=${sysconfdir}/pcb]]],
54         [PCBCONFDIR=$withval],
55         [PCBCONFDIR="${sysconfdir}/pcb"]
57 AC_SUBST(PCBCONFDIR)
59 ## Added by SDB 3.3.2006
60 # Check for getopt_long
61 dnl check GNU getopt() - thanks libcmml!
62 HAVE_GETOPT_LONG="no"
63 GETOPT_LONG_LIBS=""
64 AC_CHECK_FUNC([getopt_long], [HAVE_GETOPT_LONG="yes"])
65 if test "x$HAVE_GETOPT_LONG" != xyes ; then
66         dnl FreeBSD has a gnugetopt library
67         AC_CHECK_LIB([gnugetopt], [getopt_long], [HAVE_GETOPT_LONG="yes"])
68         if test "x$HAVE_GETOPT_LONG" = xyes ; then
69                 GETOPT_LONG_LIBS="-lgnugetopt"
70         fi
72 if test "x$HAVE_GETOPT_LONG" = xyes ; then
73         AC_DEFINE(HAVE_GETOPT_LONG, [], [Define to 1 if you have the 'getopt_long' function])
75 AC_SUBST(GETOPT_LONG_LIBS)
76 AC_SUBST(HAVE_GETOPT_LONG)
78
79 # Command line flags end
80 #########################################################################
82 # Checks for programs.
83 AC_PROG_CC
84 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
85 AC_PROG_CPP
86 AC_PROG_MAKE_SET
87 AC_PATH_PROGS(AWK, nawk gawk mawk awk, )
88 AC_PATH_PROGS(M4, gm4 m4, m4)
90 ##############################################################3
91 # Test for __func__
94 AC_MSG_CHECKING([For a working C99 __func__])
95 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
96         [[const char *foo = __func__;]])],
97    [ac_cv_cpp_func=yes],
98    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
99                 [[const char *foo = __FUNCTION__;]])],
100                 [ac_cv_cpp_func=__FUNCTION__],
101                 [ac_cv_cpp_func="\"no\""])]
104 if test "X$ac_cv_cpp_func" = "X__FUNCTION__"; then
105         AC_MSG_RESULT([__FUNCTION__])
106 elif test "x$ac_cv_cpp_func" = "xyes" ; then
107         AC_MSG_RESULT([__func__])
108 else
109         AC_MSG_RESULT([no])
111 if test "X$ac_cv_cpp_func" != "Xyes" ; then
112         AC_DEFINE_UNQUOTED([__func__], [$ac_cv_cpp_func], [Define to be a __func__ replacement])
116 ##############################################################3
118 #########################################################################
120 # Misc win32 / mingw checks and variables start
121 AC_CANONICAL_HOST
123 # Figure out if we are building on win32 and what environment.
124 case $host_os in
125   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
126 esac
128 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
129    MINGW="yes"
130    PATHSEP=\\\\
131    OTHERPATHSEP=/
132 else
133    # Unix host
134    MINGW="no"
135    PATHSEP=/
136    OTHERPATHSEP=\\\\
140 # Misc win32 / mingw checks and variables end
141 #########################################################################
144 ############################################################################
145 # Check for guile start
146 GUILE_FLAGS
148 # Check Guile version
149 guile_need_major=1
150 guile_need_minor=6
151 guile_need_version="$guile_need_major[].$guile_need_minor.0"
153 AC_MSG_CHECKING([Guile version >= $guile_need_version])
154 GUILE_VERSION=`$GUILE_CONFIG info guileversion`
156 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
157 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
158 AC_MSG_RESULT($GUILE_VERSION)
160 if test $guile_need_major -gt $guile_major \
161    || test $guile_need_minor -gt $guile_minor; then
162   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
165 # Guile 1.6 compatability
167 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
168 scm_from_int,  scm_is_true,    scm_is_false,
169 scm_from_locale_string, scm_to_locale_string],,,
170 [#include <libguile.h>])
172 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
173 #  define scm_is_string(x) SCM_STRINGP(x)
174 #endif])
175 AH_VERBATIM(SCM_IS_INTEGER, [#if !HAVE_DECL_SCM_IS_INTEGER
176 #  define scm_is_integer(x) SCM_INUMP(x)
177 #endif])
178 AH_VERBATIM(SCM_TO_INT, [#if !HAVE_DECL_SCM_TO_INT
179 #  define scm_to_int(x)     SCM_INUM(x)
180 #endif])
181 AH_VERBATIM(SCM_FROM_INT, [#if !HAVE_DECL_SCM_FROM_INT
182 #  define scm_from_int(x)   SCM_MAKINUM(x)
183 #endif])
184 AH_VERBATIM(SCM_IS_TRUE, [#if !HAVE_DECL_SCM_IS_TRUE
185 #  define scm_is_true(x)    SCM_NFALSEP(x)
186 #endif])
187 AH_VERBATIM(SCM_IS_FALSE, [#if !HAVE_DECL_SCM_IS_FALSE
188 #  define scm_is_false(x)   SCM_FALSEP(x)
189 #endif])
190 AH_VERBATIM(SCM_FROM_LOCALE_STRING, [#if !HAVE_DECL_SCM_FROM_LOCALE_STRING
191 #  define scm_from_locale_string(x) scm_makfrom0str(x)
192 #endif])
193 AH_VERBATIM(SCM_TO_LOCALE_STRING, [#if !HAVE_DECL_SCM_TO_LOCALE_STRING
194 #  define scm_to_locale_string(x)   strdup(SCM_STRING_CHARS(x))
195 #endif])
198 # Check for guile end
199 ############################################################################
201 ############################################################################
202 # Check for mics things start
204 # Checking for rint in math library
205 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
207 # Checking for dynamic lib
208 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
210 # Check for mics things start
211 ############################################################################
213 ############################################################################
214 # Check for gtk+ 2.4 start
217 # Check for pkg-config
218 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
219 if test $PKG_CONFIG = no; then
220    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
223 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
225 # This next bit of code figures out what gtk we need to use.
226 if test "$GTK24" = "yes" 
227 then
229    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
230    GTK_CFLAGS=$GTK24_CFLAGS
231    GTK_LIBS=$GTK24_LIBS
232    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
234    # Search for glib
235    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
236    if test "$GLIB24" != "yes"
237    then
238        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
239    fi
240    GLIB_CFLAGS=$GLIB24_CFLAGS
241    GLIB_LIBS=$GLIB24_LIBS
242    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
244 else
245    GTK_VERSION=""
248 if test "$GTK_VERSION" = ""
249 then
250    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
254 # Check for gtk+ 2.4 end
255 ############################################################################
257 ############################################################################
258 # Check for libgeda start
260 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
261                   no_LIBGEDA="yes")
263 if test "$LIBGEDA" = "yes" 
264 then
265    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
266 else
267    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
271 # Check for libgeda end
272 ############################################################################
274 #########################################################################
275 # Checks for header files start
277 AC_HEADER_STDC
278 AC_HEADER_SYS_WAIT
279 AC_HEADER_DIRENT
280 AC_CHECK_HEADERS(unistd.h string.h strings.h stdlib.h \
281                  stdarg.h assert.h fcntl.h errno.h getopt.h)
283 # Checks for typedefs, structures, and compiler characteristics.
284 AC_C_CONST
286 # Checks for library functions.
287 AC_TYPE_SIGNAL
288 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
290 AC_MSG_CHECKING([for optarg in unistd.h])
291 AC_TRY_COMPILE(
292 [#include <unistd.h>],
293 [ char *string = optarg; int i = optind; ],
294 optarg_found=yes,
295 optarg_found=no)
296 AC_MSG_RESULT($optarg_found)
298 if test $optarg_found = yes; then
299     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
303 # Checks for header files start
304 #########################################################################
306 #########################################################################
309 # ------------- dmalloc -------------------
310 dnl dmalloc checks
311 with_dmalloc="no"
312 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
313 AC_ARG_ENABLE([dmalloc],
314 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
316 if test "X$enable_dmalloc" != "Xno" ; then
317         AC_MSG_RESULT([yes])
318         AC_CHECK_HEADER(dmalloc.h,,
319                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
320         AC_CHECK_LIB(dmalloc,main,,
321                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
322         DMALLOC_LIBS="-ldmalloc"
323         with_dmalloc="yes"
324 else
325         AC_MSG_RESULT([no])
326         DMALLOC_LIBS=""
330         AC_MSG_RESULT([no])
331         DMALLOC_LIBS=""
334 # ------------- ElectricFence -------------------
335 dnl ElectricFence checks
336 with_efence="no"
337 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
338 AC_ARG_ENABLE([efence],
339 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
341 if test "X$enable_efence" != "Xno" ; then
342         AC_MSG_RESULT([yes])
343         AC_CHECK_LIB(efence,main,,
344                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
345         with_efence="yes"
346 else
347         AC_MSG_RESULT([no])
351 AC_MSG_RESULT([no])
355 #########################################################################
356 #########################################################################
357 # Check for groff start
360 # search for groff
361 AC_PATH_PROG(GROFF, groff, no, ${PATH})
362 if test $GROFF = "no"; then
363         echo "Cannot find groff, some documentation will not be created."
367 # Check for groff end
368 #########################################################################
370 #########################################################################
371 # gEDA/gaf specify setup start
374 DATADIR=gEDA
375 GEDADATADIR=$datadir/$DATADIR
377 if eval "test x$opt_rcdir = x"; then
378         # path not was specified with --with-rcdir
379         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
380         GEDARCDIR=$GEDADATADIR
381 else
382         # path WAS specified with --with-rcdir
383         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
384         GEDARCDIR="$opt_rcdir"
387 # Expand the prefix variable
388 # I don't like the way this is done, but it works (I hope).
389 if eval "test x$prefix = xNONE"; then
390  dprefix=$ac_default_prefix
391 else
392  dprefix=$prefix
395 gedatopdir=$dprefix/share/$DATADIR
396 expandgedadatadir=`echo $gedatopdir`
398 gedadocdir=$dprefix/share/doc/geda-doc
399 # --with-docdir : tells where to store documentation if not default
400 AC_ARG_WITH(docdir,
401     [  --with-docdir      Where to store documentation if not default.],
402         gedadocdir=$withval)
403 expandgedadocdir=`echo $gedadocdir`
404 GEDADOCDIR=$expandgedadocdir
405 AC_SUBST(GEDADOCDIR)
407 # this has to be expanded ( no ${prefix} ) --
408 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
409 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
410 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
411 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
414 # gEDA/gaf specify things which need to setup
415 #########################################################################
417 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
418 GNETLIST_CFLAGS="$LIBGEDA_CFLAGS"
419 GNETLIST_LDFLAGS="$LIBGEDA_LIBS $DMALLOC_LIBS"
421 # Makefile.in variable substitution
422 AC_SUBST(DATE_VERSION)
423 AC_SUBST(DOTTED_VERSION)
424 AC_SUBST(GNETLIST_CFLAGS)
425 AC_SUBST(GNETLIST_LDFLAGS)
426 AC_SUBST(GEDARCDIR)
427 AC_SUBST(GEDADATADIR)
428 AC_SUBST(PATHSEP)
429 AC_SUBST(OTHERPATHSEP)
431 # Create all the necessary derived files
432 AC_CONFIG_FILES([Makefile 
433                  src/Makefile 
434                  include/Makefile 
435                  scheme/Makefile 
436                  examples/Makefile 
437                  tests/Makefile 
438                  tests/hierarchy/Makefile 
439                  tests/hierarchy2/Makefile 
440                  tests/drc2/Makefile
441                  tests/spice-sdb/Makefile
442                  tests/spice-sdb/inputs/Makefile
443                  tests/spice-sdb/inputs/sym/Makefile
444                  tests/spice-sdb/inputs/models/Makefile
445                  tests/spice-sdb/outputs/Makefile
446                  docs/Makefile 
447                  docs/vams/Makefile 
448                  examples/vams/Makefile 
449                  examples/vams/sch/Makefile 
450                  examples/vams/sym/Makefile 
451                  examples/vams/vhdl/Makefile 
452                  examples/vams/vhdl/basic-vhdl/Makefile 
453                  examples/vams/vhdl/new-vhdl/Makefile 
454                  examples/switcap/Makefile 
455                  lib/Makefile 
456                  utils/Makefile 
457                  scripts/Makefile
458                  scripts/sw2asc 
459                  lib/system-gnetlistrc ])
460 AC_CONFIG_COMMANDS([sw2asc-chmod],[[chmod +x scripts/sw2asc]],[[]])
462 AC_OUTPUT
464 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
465 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
466 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
467 expandedPCBM4DIR=`eval "echo $PCBM4DIR"`
469 AC_MSG_RESULT([
470 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION:
472    GTK+ library version:             $GTK_VERSION
473    libgeda library version:          $LIBGEDA_VERSION
474    mingw build:                      $MINGW
475    data directory:                   $expandedGEDADATADIR
476    rc directory:                     $expandedGEDARCDIR
477    documentation directory:          $expandedGEDADOCDIR
478    default PCB m4 directory:         $expandedPCBM4DIR
479    dmalloc debugging:                $with_dmalloc
480    Electric Fence debugging:         $with_efence