Use temporary variable to avoid pointer chasing.
[geda-gaf/berndj.git] / gsymcheck / configure.ac
blobc2758e35c09fd117b169467ef204835c95d52219
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/gsymcheck.c])
4 AC_PREREQ(2.54)
6 PACKAGE=geda-gsymcheck
7 DOTTED_VERSION=1.5.0
8 DATE_VERSION=20080706
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
22 # Command line flags end
23 #########################################################################
25 # Checks for programs.
26 AC_PROG_CC
27 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
28 AC_PROG_CPP
29 AC_PROG_MAKE_SET
31 #########################################################################
32
33 # Misc win32 / mingw checks and variables start
34 AC_CANONICAL_HOST
36 # Figure out if we are building on win32 and what environment.
37 case $host_os in
38   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
39 esac
41 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
42    MINGW="yes"
43 else
44    # Unix host
45    MINGW="no"
48
49 # Misc win32 / mingw checks and variables end
50 #########################################################################
52 ############################################################################
53 # Check for guile start
55 # Check for pkg-config
56 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
57 if test $PKG_CONFIG = no; then
58    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
61 PKG_CHECK_MODULES(GUILE, guile-2.0, GUILE_PC="yes", no_GUILE_PC="yes")
63 if test "$GUILE_PC" = "yes" 
64 then
65    GUILE_VERSION=`$PKG_CONFIG guile-2.0 --modversion`
66 else
67    # Find about the installed guile
68    GUILE_FLAGS
69    GUILE_VERSION=`$GUILE_CONFIG info guileversion`
72 # Check Guile version
73 guile_need_major=1
74 guile_need_minor=6
75 guile_need_version="$guile_need_major[].$guile_need_minor.0"
77 AC_MSG_CHECKING([Guile version >= $guile_need_version])
79 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
80 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
81 AC_MSG_RESULT($GUILE_VERSION)
83 if test "$guile_need_major" -gt "$guile_major" \
84    || (test "$guile_need_major" -eq "$guile_major" \
85        && test "$guile_need_minor" -gt "$guile_minor"); then
86   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
89 # Guile 1.6 compatability
91 CFLAGS_temp_save="$CFLAGS"
92 CFLAGS="$CFLAGS $GUILE_CFLAGS"
93 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
94 scm_from_int,  scm_is_true,    scm_is_false,
95 scm_from_locale_string, scm_to_locale_string],,,
96 [#include <libguile.h>])
97 CFLAGS="$CFLAGS_temp_save"
99 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
100 #  define scm_is_string(x) SCM_STRINGP(x)
101 #endif])
102 AH_VERBATIM(SCM_IS_INTEGER, [#if !HAVE_DECL_SCM_IS_INTEGER
103 #  define scm_is_integer(x) SCM_INUMP(x)
104 #endif])
105 AH_VERBATIM(SCM_TO_INT, [#if !HAVE_DECL_SCM_TO_INT
106 #  define scm_to_int(x)     SCM_INUM(x)
107 #endif])
108 AH_VERBATIM(SCM_FROM_INT, [#if !HAVE_DECL_SCM_FROM_INT
109 #  define scm_from_int(x)   SCM_MAKINUM(x)
110 #endif])
111 AH_VERBATIM(SCM_IS_TRUE, [#if !HAVE_DECL_SCM_IS_TRUE
112 #  define scm_is_true(x)    SCM_NFALSEP(x)
113 #endif])
114 AH_VERBATIM(SCM_IS_FALSE, [#if !HAVE_DECL_SCM_IS_FALSE
115 #  define scm_is_false(x)   SCM_FALSEP(x)
116 #endif])
117 AH_VERBATIM(SCM_FROM_LOCALE_STRING, [#if !HAVE_DECL_SCM_FROM_LOCALE_STRING
118 #  define scm_from_locale_string(x) scm_makfrom0str(x)
119 #endif])
120 AH_VERBATIM(SCM_TO_LOCALE_STRING, [#if !HAVE_DECL_SCM_TO_LOCALE_STRING
121 #  define scm_to_locale_string(x)   strdup(SCM_STRING_CHARS(x))
122 #endif])
125 # Check for guile end
126 ############################################################################
128 ############################################################################
129 # Check for mics things start
131 # Checking for rint in math library
132 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
134 # Checking for dynamic lib
135 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
137 # Check for mics things start
138 ############################################################################
141 ############################################################################
142 # Check for gtk+ 2.4 start
145 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
147 # This next bit of code figures out what gtk we need to use.
148 if test "$GTK24" = "yes" 
149 then
151    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
152    GTK_CFLAGS=$GTK24_CFLAGS
153    GTK_LIBS=$GTK24_LIBS
154    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
156    # Search for glib
157    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
158    if test "$GLIB24" != "yes"
159    then
160        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
161    fi
162    GLIB_CFLAGS=$GLIB24_CFLAGS
163    GLIB_LIBS=$GLIB24_LIBS
164    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
166 else
167    GTK_VERSION=""
170 if test "$GTK_VERSION" = ""
171 then
172    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
176 # Check for gtk+ 2.4 end
177 ############################################################################
179 ############################################################################
180 # Check for libgeda start
182 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
183                   no_LIBGEDA="yes")
185 if test "$LIBGEDA" = "yes" 
186 then
187    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
188 else
189    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
193 # Check for libgeda end
194 ############################################################################
196 #########################################################################
197 # Checks for header files start
199 AC_HEADER_STDC
200 AC_HEADER_SYS_WAIT
201 AC_HEADER_DIRENT
202 AC_CHECK_HEADERS(regex.h sys/types.h unistd.h string.h stdlib.h \
203                  stdarg.h assert.h fcntl.h errno.h)
205 # Checks for typedefs, structures, and compiler characteristics.
206 AC_C_CONST
208 # Checks for library functions.
209 AC_TYPE_SIGNAL
210 AC_CHECK_FUNCS(strstr)
212 AC_MSG_CHECKING([for optarg in unistd.h])
213 AC_TRY_COMPILE(
214 [#include <unistd.h>],
215 [ char *string = optarg; int i = optind; ],
216 optarg_found=yes,
217 optarg_found=no)
218 AC_MSG_RESULT($optarg_found)
220 if test $optarg_found = yes; then
221     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
225 # Checks for header files start
226 #########################################################################
228 #########################################################################
229 # Check for groff start
232 # search for groff
233 AC_PATH_PROG(GROFF, groff, no, ${PATH})
234 if test $GROFF = "no"; then
235         echo "Cannot find groff, some documentation will not be created."
239 # Check for groff end
240 #########################################################################
242 #########################################################################
243 # gEDA/gaf specify setup start
246 DATADIR=gEDA
247 GEDADATADIR=$datadir/$DATADIR
249 if eval "test x$opt_rcdir = x"; then
250         # path not was specified with --with-rcdir
251         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
252         GEDARCDIR=$GEDADATADIR
253 else
254         # path WAS specified with --with-rcdir
255         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
256         GEDARCDIR="$opt_rcdir"
259 # Expand the prefix variable
260 # I don't like the way this is done, but it works (I hope).
261 if eval "test x$prefix = xNONE"; then
262  dprefix=$ac_default_prefix
263 else
264  dprefix=$prefix
267 gedatopdir=$dprefix/share/$DATADIR
268 expandgedadatadir=`echo $gedatopdir`
270 gedadocdir=$dprefix/share/doc/geda-doc
271 # --with-docdir : tells where to store documentation if not default
272 AC_ARG_WITH(docdir,
273     [  --with-docdir      Where to store documentation if not default.],
274         gedadocdir=$withval)
275 expandgedadocdir=`echo $gedadocdir`
276 GEDADOCDIR=$expandgedadocdir
277 AC_SUBST(GEDADOCDIR)
279 # this has to be expanded ( no ${prefix} ) --
280 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
281 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
282 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
283 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
286 # gEDA/gaf specify things which need to setup
287 #########################################################################
289 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
290 GSYMCHECK_CFLAGS="$LIBGEDA_CFLAGS"
291 GSYMCHECK_LDFLAGS="$LIBGEDA_LIBS"  
293 # Makefile.in variable substitution
294 AC_SUBST(DATE_VERSION)
295 AC_SUBST(DOTTED_VERSION)
296 AC_SUBST(GSYMCHECK_CFLAGS)
297 AC_SUBST(GSYMCHECK_LDFLAGS)
298 AC_SUBST(GEDARCDIR)
299 AC_SUBST(GEDADATADIR)
301 # Create all the necessary derived files
302 AC_CONFIG_FILES([Makefile 
303                  src/Makefile 
304                  include/Makefile 
305                  scheme/Makefile 
306                  examples/Makefile 
307                  lib/Makefile 
308                  docs/Makefile
309                  tests/Makefile
310                  lib/system-gsymcheckrc ])
312 AC_OUTPUT
314 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
315 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
316 expandedGEDADOCDIR=`eval "echo $GEDADOCDIR"`
318 AC_MSG_RESULT([
319 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION:
321    GTK+ library version:             $GTK_VERSION
322    libgeda library version:          $LIBGEDA_VERSION
323    mingw build:                      $MINGW
324    data directory:                   $expandedGEDADATADIR
325    rc directory:                     $expandedGEDARCDIR
326    documentation directory:          $expandedGEDADOCDIR