Updated all version strings to 1.1.0 and 20070705
[geda-gaf.git] / utils / configure.ac
blobd0ca0cea1a4901c667c2c70c3aa0c77763a96cea
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/gmk_sym.c])
4 AC_PREREQ(2.54)
6 PACKAGE=geda-utils
7 DOTTED_VERSION=1.1.0
8 DATE_VERSION=20070705
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 # --with-docdir : tells where to store documentation if not default
22 # defined below 
23
24 # Command line flags end
25 #########################################################################
27 # Checks for programs.
28 AC_PROG_CC
29 AM_PROG_CC_C_O
30 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")
31 AC_PROG_CPP
32 AC_PROG_MAKE_SET
33 AM_PROG_LEX
35 AC_PATH_PROG(PERL, perl, [notfound])
36 AM_CONDITIONAL(MISSING_PERL, test x$PERL = xnotfound)
38 ##############################################################3
39 # Test for __func__
42 AC_MSG_CHECKING([For a working C99 __func__])
43 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
44         [[const char *foo = __func__;]])],
45    [ac_cv_cpp_func=yes],
46    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
47                 [[const char *foo = __FUNCTION__;]])],
48                 [ac_cv_cpp_func=__FUNCTION__],
49                 [ac_cv_cpp_func="\"no\""])]
52 if test "X$ac_cv_cpp_func" = "X__FUNCTION__"; then
53         AC_MSG_RESULT([__FUNCTION__])
54 elif test "x$ac_cv_cpp_func" = "xyes" ; then
55         AC_MSG_RESULT([__func__])
56 else
57         AC_MSG_RESULT([no])
59 if test "X$ac_cv_cpp_func" != "Xyes" ; then
60         AC_DEFINE_UNQUOTED([__func__], [$ac_cv_cpp_func], [Define to be a __func__ replacement])
64 ##############################################################3
66 #########################################################################
67
68 # Misc win32 / mingw checks and variables start
69 AC_CANONICAL_HOST
71 # Figure out if we are building on win32 and what environment.
72 case $host_os in
73   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
74 esac
76 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
77    MINGW_CFLAGS="-mms-bitfields -mwindows"
78    MINGW_LIBS="-lregex -liberty"
79    MINGW="yes"
80    PATHSEP=\\\\
81    OTHERPATHSEP=/
82 else
83    # Unix host
84    MINGW_CFLAGS=
85    MINGW_LIBS=
86    MINGW="no"
87    PATHSEP=/
88    OTHERPATHSEP=\\\\
91
92 # Misc win32 / mingw checks and variables end
93 #########################################################################
95 ############################################################################
96 # Check for mics things start
97
98 # Checking for rint in math library
99 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
101 # Checking for dynamic lib
102 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
104 # Check for mics things start
105 ############################################################################
107 ############################################################################
108 # Check for libgeda start
110 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
111                   no_LIBGEDA="yes")
113 if test "$LIBGEDA" = "yes" 
114 then
115    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
116 else
117    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
121 # Check for libgeda end
122 ############################################################################
124 ############################################################################
125 # Check for gtk+ 2.4 start
128 # Check for pkg-config
129 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
130 if test $PKG_CONFIG = no; then
131    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
134 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
136 # This next bit of code figures out what gtk we need to use.
137 if test "$GTK24" = "yes"
138 then
140    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
141    GTK_CFLAGS=$GTK24_CFLAGS
142    GTK_LIBS=$GTK24_LIBS
143    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
145    # Search for glib
146    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
147    if test "$GLIB24" != "yes"
148    then
149        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
150    fi
151    GLIB_CFLAGS=$GLIB24_CFLAGS
152    GLIB_LIBS=$GLIB24_LIBS
153    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
155 else
156    GTK_VERSION=""
159 if test "$GTK_VERSION" = ""
160 then
161    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
165 # Check for gtk+ 2.4 end
166 ############################################################################
168 ############################################################################
169 # Check for glib 2.4 start
172 # Check for pkg-config
173 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
174 if test $PKG_CONFIG = no; then
175    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
178 # Search for glib 2.4.x first (only if we are not forcing the glib to 1.2)
179 if test "$opt_gtkver" != "1.2"
180 then
181    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
184 # This next bit of code figures out what glib we need to use.
185 if test "$GLIB24" = "yes" -a "$opt_gtkver" != "1.2"
186 then
187    GLIB_CFLAGS=$GLIB24_CFLAGS
188    GLIB_LIBS=$GLIB24_LIBS
189    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
190 else
191    GLIB_VERSION=""
194 if test "$GLIB_VERSION" = ""
195 then
196    AC_MSG_ERROR([Cannot find glib 2.4.x, install one of them.])
200 # Check for glib 2.4 end
201 ############################################################################
203 #########################################################################
204 # Checks for header files start
206 AC_HEADER_STDC
207 AC_HEADER_SYS_WAIT
208 AC_HEADER_DIRENT
209 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
210                  stdarg.h assert.h fcntl.h errno.h \
211                  getopt.h)
213 # Checks for typedefs, structures, and compiler characteristics.
214 AC_C_CONST
216 # Checks for library functions.
217 AC_TYPE_SIGNAL
218 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf getopt_long)
219 AC_CHECK_FUNCS(strcasecmp strncasecmp stricmp strnicmp)
221 AC_MSG_CHECKING([for optarg in unistd.h])
222 AC_TRY_COMPILE(
223 [#include <unistd.h>],
224 [ char *string = optarg; int i = optind; ],
225 optarg_found=yes,
226 optarg_found=no)
227 AC_MSG_RESULT($optarg_found)
229 if test $optarg_found = yes; then
230     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
234 # Checks for header files start
235 #########################################################################
237 #########################################################################
240 # ------------- dmalloc -------------------
241 dnl dmalloc checks
242 with_dmalloc="no"
243 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
244 AC_ARG_ENABLE([dmalloc],
245 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
247 if test "X$enable_dmalloc" != "Xno" ; then
248         AC_MSG_RESULT([yes])
249         AC_CHECK_HEADER(dmalloc.h,,
250                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
251         AC_CHECK_LIB(dmalloc,main,,
252                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
253         DMALLOC_LIBS="-ldmalloc"
254         with_dmalloc="yes"
255 else
256         AC_MSG_RESULT([no])
257         DMALLOC_LIBS=""
261         AC_MSG_RESULT([no])
262         DMALLOC_LIBS=""
265 # ------------- ElectricFence -------------------
266 dnl ElectricFence checks
267 with_efence="no"
268 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
269 AC_ARG_ENABLE([efence],
270 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
272 if test "X$enable_efence" != "Xno" ; then
273         AC_MSG_RESULT([yes])
274         if test "X$with_dmalloc" = "Xyes" ; then
275                 AC_ERROR([You have requested both dmalloc and Electric Fence, however only 1 is allowed.])
276         fi
277         AC_CHECK_LIB(efence,main,,
278                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
279         with_efence="yes"
280 else
281         AC_MSG_RESULT([no])
285 AC_MSG_RESULT([no])
289 #########################################################################
291 #########################################################################
293 # Change default location for pcb's newlib library directory
295 # Used by gsch2pcb
297 AC_MSG_CHECKING([For the default pcb installation data directory])
298 AC_ARG_WITH(pcb-datadir,
299         [  --with-pcb-datadir=path
300                           Change the default location for an installed pcb.  This is used
301                           to set the default search path for pcb newlib libraries.
302                           [[default=${datadir}]]],
303         [PCBDATADIR=$withval],
304         [PCBDATADIR="${datadir}"]
306 AC_MSG_RESULT([${PCBDATADIR}])
307 CPPFLAGS="$CPPFLAGS -DPCBDATADIR=\\\"${PCBDATADIR}\\\""
309 AC_MSG_CHECKING([For the default pcb newlib search path])
310 AC_ARG_WITH(pcb-newlib-path,
311         [  --with-pcb-newlib-path=path
312                           Change the default search path for PCB newlib libraries
313                           [[default=${datadir}/pcb/pcblib-newlib:${datadir}/pcb/newlib]]],
314         [PCBLIBPATH=$withval],
315         [PCBLIBPATH="${PCBDATADIR}/pcb/pcblib-newlib:${PCBDATADIR}/pcb/newlib"]
317 AC_MSG_RESULT([${PCBLIBPATH}])
318 CPPFLAGS="$CPPFLAGS -DPCBLIBPATH=\\\"${PCBLIBPATH}\\\""
321 #########################################################################
323 #########################################################################
324 # Check for groff start
327 # search for groff
328 AC_PATH_PROG(GROFF, groff, no, ${PATH})
329 if test $GROFF = "no"; then
330         echo "Cannot find groff, some documentation will not be created."
334 # Check for groff end
335 #########################################################################
337 #########################################################################
338 # gEDA/gaf specify setup start
341 DATADIR=gEDA
342 GEDADATADIR=$datadir/$DATADIR
344 if eval "test x$opt_rcdir = x"; then
345         # path not was specified with --with-rcdir
346         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
347         GEDARCDIR=$GEDADATADIR
348 else
349         # path WAS specified with --with-rcdir
350         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
351         GEDARCDIR="$opt_rcdir"
354 # Expand the prefix variable
355 # I don't like the way this is done, but it works (I hope).
356 if eval "test x$prefix = xNONE"; then
357  dprefix=$ac_default_prefix
358 else
359  dprefix=$prefix
362 gedatopdir=$dprefix/share/$DATADIR
363 expandgedadatadir=`echo $gedatopdir`
365 gedadocdir=$dprefix/share/doc/geda-doc
366 # --with-docdir : tells where to store documentation if not default
367 AC_ARG_WITH(docdir,
368     [  --with-docdir      Where to store documentation if not default.],
369         gedadocdir=$withval)
370 expandgedadocdir=`echo $gedadocdir`
371 GEDADOCDIR=$expandgedadocdir
373 # this has to be expanded ( no ${prefix} ) --
374 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
375 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
376 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
377 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
380 # gEDA/gaf specify things which need to setup
381 #########################################################################
383 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
384 GSCHLAS_CFLAGS="$LIBGEDA_CFLAGS"
385 GSCHLAS_LDFLAGS="$LIBGEDA_LIBS $GTK_LIBS"  
386 GSCH2PCB_CFLAGS="$GLIB_CFLAGS $MINGW_CFLAGS"
387 GSCH2PCB_LDFLAGS="$GLIB_LIBS $MINGW_LIBS"  
388 GRENUM_CFLAGS="$LIBGEDA_CFLAGS"
389 GRENUM_LDFLAGS="$GLIB_LIBS"  
391 # Makefile.in variable substitution
392 AC_SUBST(DATE_VERSION)
393 AC_SUBST(DOTTED_VERSION)
394 AC_SUBST(GSCHLAS_CFLAGS)
395 AC_SUBST(GSCHLAS_LDFLAGS)
396 AC_SUBST(GSCH2PCB_CFLAGS)
397 AC_SUBST(GSCH2PCB_LDFLAGS)
398 AC_SUBST(GRENUM_CFLAGS)
399 AC_SUBST(GRENUM_LDFLAGS)
400 AC_SUBST(MINGW_CFLAGS)
401 AC_SUBST(MINGW_LIBS)
402 AC_SUBST(GEDARCDIR)
403 AC_SUBST(GEDADATADIR)
404 AC_SUBST(GEDADOCDIR)
405 AC_SUBST(PATHSEP)
406 AC_SUBST(OTHERPATHSEP)
408 # Create all the necessary derived files
409 AC_CONFIG_FILES([Makefile 
410                  examples/Makefile 
411                  examples/gmk_sym/Makefile 
412                  examples/tragesym/Makefile 
413                  examples/gsch2pcb/Makefile 
414                  include/Makefile 
415                  scripts/Makefile 
416                  docs/Makefile 
417                  man/Makefile 
418                  lib/Makefile 
419                  lib/system-gschlasrc 
420                  gschlas/Makefile 
421                  src/Makefile
422                  tests/Makefile
423                  tests/refdes_renum/Makefile
424                  tests/refdes_renum/inputs/Makefile
425                  tests/refdes_renum/outputs/Makefile
428 AC_OUTPUT
430 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
431 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
432 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
433 expandedPCBLIBPATH=`eval "echo $PCBLIBPATH"`
435 AC_MSG_RESULT([
436 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION:
438    GTK+ library version:             $GTK_VERSION
439    GLIB library version:             $GLIB_VERSION
440    libgeda library version:          $LIBGEDA_VERSION
441    mingw build:                      $MINGW
442    data directory:                   $expandedGEDADATADIR
443    rc directory:                     $expandedGEDARCDIR
444    documentation directory:          $expandedGEDADOCDIR
445    default pcb newlib path:          $expandedPCBLIBPATH
446    dmalloc debugging:                $with_dmalloc
447    Electric Fence debugging:         $with_efence