Updated wiki from the website. Fixed wikifetch.sh to not download forever.
[geda-gaf/peter-b.git] / gnetlist / configure.ac
blob193ba7bb13444a00241816a02d74a0a7fa7a6e4c
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 VERSION=20070216
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 # Change default location for rc files
22 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
24 AC_MSG_CHECKING([For the default pcb installation data directory])
25 AC_ARG_WITH(pcb-datadir,
26         [  --with-pcb-datadir=path
27                           Change the default location for an installed pcb.  This is used
28                           to set the default search path for pcb newlib libraries.
29                           [[default=${datadir}]]],
30         [PCBDATADIR=$withval],
31         [PCBDATADIR="${datadir}"]
33 AC_MSG_RESULT([${PCBDATADIR}])
34 AC_SUBST(PCBDATADIR)
36 # Change default location for pcb's m4 library directory
37 AC_MSG_CHECKING([For the default pcb m4 directory])
38 AC_ARG_WITH(pcbm4dir,
39         [  --with-pcbm4dir=path     Change where the PCB m4 files are installed [[default=${PCBDATADIR}/pcb/m4]]],
40         [PCBM4DIR=$withval],
41         [PCBM4DIR="${PCBDATADIR}/pcb/m4"]
43 AC_MSG_RESULT([${PCBM4DIR}])
44 AC_SUBST(PCBM4DIR)
46 # Change default location for pcb's newlib library directory
47 AC_ARG_WITH(pcb-newlib-path,
48         [  --with-pcb-newlib-path=path   Change the default search path for PCB newlib libraries [[default=${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib:]]],
49         [PCBLIBPATH=$withval],
50         [PCBLIBPATH="${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib"]
52 AC_SUBST(PCBLIBPATH)
54 # Change default location for pcb's m4 site configuration directory
55 AC_ARG_WITH(pcbconfdir,
56         [  --with-pcbconfdir=path     Change where the PCB site config files are installed [[default=${sysconfdir}/pcb]]],
57         [PCBCONFDIR=$withval],
58         [PCBCONFDIR="${sysconfdir}/pcb"]
60 AC_SUBST(PCBCONFDIR)
62 ## Added by SDB 3.3.2006
63 # Check for getopt_long
64 dnl check GNU getopt() - thanks libcmml!
65 HAVE_GETOPT_LONG="no"
66 GETOPT_LONG_LIBS=""
67 AC_CHECK_FUNC([getopt_long], [HAVE_GETOPT_LONG="yes"])
68 if test "x$HAVE_GETOPT_LONG" != xyes ; then
69         dnl FreeBSD has a gnugetopt library
70         AC_CHECK_LIB([gnugetopt], [getopt_long], [HAVE_GETOPT_LONG="yes"])
71         if test "x$HAVE_GETOPT_LONG" = xyes ; then
72                 GETOPT_LONG_LIBS="-lgnugetopt"
73         fi
75 if test "x$HAVE_GETOPT_LONG" = xyes ; then
76         AC_DEFINE(HAVE_GETOPT_LONG, [], [Define to 1 if you have the 'getopt_long' function])
78 AC_SUBST(GETOPT_LONG_LIBS)
81
82 # Command line flags end
83 #########################################################################
85 # Checks for programs.
86 AC_PROG_CC
87 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
88 AC_PROG_CPP
89 AC_PROG_MAKE_SET
90 AC_PATH_PROGS(AWK, nawk gawk mawk awk, )
91 AC_PATH_PROGS(M4, gm4 m4, m4)
93 ##############################################################3
94 # Test for __func__
97 AC_MSG_CHECKING([For a working C99 __func__])
98 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
99         [[const char *foo = __func__;]])],
100    [ac_cv_cpp_func=yes],
101    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
102                 [[const char *foo = __FUNCTION__;]])],
103                 [ac_cv_cpp_func=__FUNCTION__],
104                 [ac_cv_cpp_func="\"no\""])]
107 if test "X$ac_cv_cpp_func" = "X__FUNCTION__"; then
108         AC_MSG_RESULT([__FUNCTION__])
109 elif test "x$ac_cv_cpp_func" = "xyes" ; then
110         AC_MSG_RESULT([__func__])
111 else
112         AC_MSG_RESULT([no])
114 if test "X$ac_cv_cpp_func" != "Xyes" ; then
115         AC_DEFINE_UNQUOTED([__func__], [$ac_cv_cpp_func], [Define to be a __func__ replacement])
119 ##############################################################3
121 #########################################################################
123 # Misc win32 / mingw checks and variables start
124 AC_CANONICAL_HOST
126 # Figure out if we are building on win32 and what environment.
127 case $host_os in
128   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
129 esac
131 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
132    MINGW="yes"
133    PATHSEP=\\\\
134    OTHERPATHSEP=/
135 else
136    # Unix host
137    MINGW="no"
138    PATHSEP=/
139    OTHERPATHSEP=\\\\
143 # Misc win32 / mingw checks and variables end
144 #########################################################################
146 ############################################################################
147 # Check for mics things start
149 # Checking for rint in math library
150 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
152 # Checking for dynamic lib
153 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
155 # Check for mics things start
156 ############################################################################
158 ############################################################################
159 # Check for gtk+ 2.4 start
162 # Check for pkg-config
163 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
164 if test $PKG_CONFIG = no; then
165    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
168 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
170 # This next bit of code figures out what gtk we need to use.
171 if test "$GTK24" = "yes" 
172 then
174    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
175    GTK_CFLAGS=$GTK24_CFLAGS
176    GTK_LIBS=$GTK24_LIBS
177    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
179    # Search for glib
180    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
181    if test "$GLIB24" != "yes"
182    then
183        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
184    fi
185    GLIB_CFLAGS=$GLIB24_CFLAGS
186    GLIB_LIBS=$GLIB24_LIBS
187    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
189 else
190    GTK_VERSION=""
193 if test "$GTK_VERSION" = ""
194 then
195    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
199 # Check for gtk+ 2.4 end
200 ############################################################################
202 ############################################################################
203 # Check for libgeda start
205 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $VERSION, LIBGEDA="yes", 
206                   no_LIBGEDA="yes")
208 if test "$LIBGEDA" = "yes" 
209 then
210    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
211 else
212    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
216 # Check for libgeda end
217 ############################################################################
219 #########################################################################
220 # Checks for header files start
222 AC_HEADER_STDC
223 AC_HEADER_SYS_WAIT
224 AC_HEADER_DIRENT
225 AC_CHECK_HEADERS(unistd.h string.h strings.h stdlib.h \
226                  stdarg.h assert.h fcntl.h errno.h getopt.h)
228 # Checks for typedefs, structures, and compiler characteristics.
229 AC_C_CONST
231 # Checks for library functions.
232 AC_TYPE_SIGNAL
233 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf)
235 AC_MSG_CHECKING([for optarg in unistd.h])
236 AC_TRY_COMPILE(
237 [#include <unistd.h>],
238 [ char *string = optarg; int i = optind; ],
239 optarg_found=yes,
240 optarg_found=no)
241 AC_MSG_RESULT($optarg_found)
243 if test $optarg_found = yes; then
244     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
248 # Checks for header files start
249 #########################################################################
251 #########################################################################
254 # ------------- dmalloc -------------------
255 dnl dmalloc checks
256 with_dmalloc="no"
257 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
258 AC_ARG_ENABLE([dmalloc],
259 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
261 if test "X$enable_dmalloc" != "Xno" ; then
262         AC_MSG_RESULT([yes])
263         AC_CHECK_HEADER(dmalloc.h,,
264                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
265         AC_CHECK_LIB(dmalloc,main,,
266                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
267         DMALLOC_LIBS="-ldmalloc"
268         with_dmalloc="yes"
269 else
270         AC_MSG_RESULT([no])
271         DMALLOC_LIBS=""
275         AC_MSG_RESULT([no])
276         DMALLOC_LIBS=""
279 # ------------- ElectricFence -------------------
280 dnl ElectricFence checks
281 with_efence="no"
282 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
283 AC_ARG_ENABLE([efence],
284 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
286 if test "X$enable_efence" != "Xno" ; then
287         AC_MSG_RESULT([yes])
288         AC_CHECK_LIB(efence,main,,
289                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
290         with_efence="yes"
291 else
292         AC_MSG_RESULT([no])
296 AC_MSG_RESULT([no])
300 #########################################################################
301 #########################################################################
302 # Check for groff start
305 # search for groff
306 AC_PATH_PROG(GROFF, groff, no, ${PATH})
307 if test $GROFF = "no"; then
308         echo "Cannot find groff, some documentation will not be created."
312 # Check for groff end
313 #########################################################################
315 #########################################################################
316 # gEDA/gaf specify setup start
319 DATADIR=gEDA
320 GEDADATADIR=$datadir/$DATADIR
322 if eval "test x$opt_rcdir = x"; then
323         # path not was specified with --with-rcdir
324         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
325         GEDARCDIR=$GEDADATADIR
326 else
327         # path WAS specified with --with-rcdir
328         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
329         GEDARCDIR="$opt_rcdir"
332 # Expand the prefix variable
333 # I don't like the way this is done, but it works (I hope).
334 if eval "test x$prefix = xNONE"; then
335  dprefix=$ac_default_prefix
336 else
337  dprefix=$prefix
340 gedatopdir=$dprefix/share/$DATADIR
341 expandgedadatadir=`echo $gedatopdir`
343 gedadocdir=$dprefix/share/doc/geda-doc
344 # --with-docdir : tells where to store documentation if not default
345 AC_ARG_WITH(docdir,
346     [  --with-docdir      Where to store documentation if not default.],
347         gedadocdir=$withval)
348 expandgedadocdir=`echo $gedadocdir`
349 GEDADOCDIR=$expandgedadocdir
350 AC_SUBST(GEDADOCDIR)
352 # this has to be expanded ( no ${prefix} ) --
353 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
354 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Currently running version of gEDA/gaf])
357 # gEDA/gaf specify things which need to setup
358 #########################################################################
360 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
361 GNETLIST_CFLAGS="$LIBGEDA_CFLAGS"
362 GNETLIST_LDFLAGS="$LIBGEDA_LIBS $DMALLOC_LIBS"
364 # Makefile.in variable substitution
365 AC_SUBST(GNETLIST_CFLAGS)
366 AC_SUBST(GNETLIST_LDFLAGS)
367 AC_SUBST(GEDARCDIR)
368 AC_SUBST(GEDADATADIR)
369 AC_SUBST(PATHSEP)
370 AC_SUBST(OTHERPATHSEP)
372 # Create all the necessary derived files
373 AC_CONFIG_FILES([Makefile 
374                  src/Makefile 
375                  include/Makefile 
376                  scheme/Makefile 
377                  examples/Makefile 
378                  tests/Makefile 
379                  tests/hierarchy/Makefile 
380                  tests/drc2/Makefile
381                  tests/spice-sdb/Makefile
382                  tests/spice-sdb/inputs/Makefile
383                  tests/spice-sdb/inputs/sym/Makefile
384                  tests/spice-sdb/inputs/models/Makefile
385                  tests/spice-sdb/outputs/Makefile
386                  docs/Makefile 
387                  docs/vams/Makefile 
388                  examples/vams/Makefile 
389                  examples/vams/sch/Makefile 
390                  examples/vams/sym/Makefile 
391                  examples/vams/vhdl/Makefile 
392                  examples/vams/vhdl/basic-vhdl/Makefile 
393                  examples/vams/vhdl/new-vhdl/Makefile 
394                  examples/switcap/Makefile 
395                  lib/Makefile 
396                  utils/Makefile 
397                  scripts/Makefile
398                  scripts/sw2asc 
399                  lib/system-gnetlistrc ])
400 AC_CONFIG_COMMANDS([sw2asc-chmod],[[chmod +x scripts/sw2asc]],[[]])
402 AC_OUTPUT
404 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
405 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
406 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
407 expandedPCBM4DIR=`eval "echo $PCBM4DIR"`
409 AC_MSG_RESULT([
410 ** Configuration summary for $PACKAGE $VERSION:
412    GTK+ library version:             $GTK_VERSION
413    libgeda library version:          $LIBGEDA_VERSION
414    mingw build:                      $MINGW
415    data directory:                   $expandedGEDADATADIR
416    rc directory:                     $expandedGEDARCDIR
417    documentation directory:          $expandedGEDADOCDIR
418    default PCB m4 directory:         $expandedPCBM4DIR
419    dmalloc debugging:                $with_dmalloc
420    Electric Fence debugging:         $with_efence