Fixed a few Makefiles to allow make distcheck to work again. Bumped version
[geda-gaf/peter-b.git] / gattrib / configure.ac
blob3d2044405d4c0b42cfaffd41087eae7b46a81026
1 dr Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/gattrib.c])
4 AC_PREREQ(2.53)
6 PACKAGE=geda-gattrib
7 GEDA_VERSION=20060824
8 GATTRIB_VERSION=20060824
9 echo Configuring $PACKAGE version $GATTRIB_VERSION
10 echo Part of gEDA version $GEDA_VERSION
12 # Initialize automake -- use base gEDA version here
13 AM_INIT_AUTOMAKE($PACKAGE, $GEDA_VERSION)
14 AM_CONFIG_HEADER([config.h])
16 # Initialize maintainer mode
17 AM_MAINTAINER_MODE
19 # Create option to debug
20 AC_ARG_ENABLE(debug,
21 [ --enable-debug  Sets the DEBUG flag which causes lots of debug spew to be generated],
22 [ AC_DEFINE(DEBUG, 1, DEBUG) ]
25 #########################################################################
26 # Command line flags start
27
28 # Change default location for rc files
29 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
31
32 # Command line flags end
33 #########################################################################
35 # Checks for programs.
36 AC_PROG_CC
37 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
38 AC_PROG_MAKE_SET
39 AC_PATH_PROGS(AWK, nawk gawk mawk awk, )
41 #########################################################################
42
43 #  Misc win32 / mingw checks and variables start
44 #  Win32 stuff currently unsupported by SDB.  I left it in because we need
45 #  to set the PATHSEP var.
46 AC_CANONICAL_HOST
48 # Figure out if we are building on win32 and what environment.
49 case $host_os in
50   *cygwin*  ) AC_MSG_ERROR([Building gEDA/gaf under cygwin is not supported]) ;;
51   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
52 esac
54 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
55    MINGW="yes"
56    PATHSEP=\\\\
57    OTHERPATHSEP=/
58 else
59    # Unix host
60    MINGW="no"
61    PATHSEP=/
62    OTHERPATHSEP=\\\\
65
66 # Misc win32 / mingw checks and variables end
67 #########################################################################
70 ############################################################################
71 # Check for misc things. . . .
72
73 # Checking for rint in math library
74 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
76 # Checking for dynamic lib
77 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
79 ############################################################################
82 ############################################################################
83 ##  This is looks for GTK2.2.
84 #                                                                                      
85 # Check for pkg-config
86 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
87 if test $PKG_CONFIG = no; then
88    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
91 # Search for gtk+ 2.2.x 
92 PKG_CHECK_MODULES(GTK22, gtk+-2.0 >= 2.2.0, GTK22="yes", no_GTK22="yes")
94 # This next bit of code figures out what gtk we need to use.
95 if test "$GTK22" = "yes" 
96 then
98    AC_DEFINE(HAS_GTK22, 1, [If gtk+ 2.2.x has been installed, define this])
99    GTK_CFLAGS=$GTK22_CFLAGS
100    GTK_LIBS=$GTK22_LIBS
101    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
103    # Search for glib
104    PKG_CHECK_MODULES(GLIB22, glib-2.0 >= 2.2.0, GLIB22="yes", no_GLIB22="yes")
105    if test "$GLIB22" != "yes"
106    then
107        AC_MSG_ERROR([Cannot find glib 2.2.x, install it and rerun ./configure.])
108    fi
109    GLIB_CFLAGS=$GLIB22_CFLAGS
110    GLIB_LIBS=$GLIB22_LIBS
111    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
113 ##   GTKITEMENTRY_SOURCE=gtkitementry_2_2.c gtkitementry_2_2.h
114     
115 else
116    GTK_VERSION=""
119                                                                                       
120 if test "$GTK_VERSION" = ""
121 then
122    AC_MSG_ERROR([Cannot find gtk+ 2.2.x or later, please install gtk+.])
125 ##  These tell Makefile.am which package to compile
126 AM_CONDITIONAL(GTK22_SOURCE, test "$GLIB22" = "yes")
127                                                                                       
129 # Check for gtk+ 2.2 end
130 ############################################################################
131                                                                                       
133 ############################################################################
134 # Check for libgeda start
136 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $GEDA_VERSION, LIBGEDA="yes", 
137                   no_LIBGEDA="yes")
139 if test "$LIBGEDA" = "yes" 
140 then
141    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
142 else
143    AC_MSG_ERROR([Cannot find libgeda>=$GEDA_VERSION (or libgeda.pc), please install libgeda-$GEDA_VERSION])
147 # Check for libgeda end
148 ############################################################################
150 #########################################################################
151 # Checks for header files start
153 AC_HEADER_STDC
154 AC_HEADER_SYS_WAIT
155 AC_HEADER_DIRENT
156 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
157                  stdarg.h assert.h fcntl.h errno.h \
158                  dirent.h sys/param.h getopt.h)
160 # Checks for typedefs, structures, and compiler characteristics.
161 AC_C_CONST
163 # Checks for library functions.
164 AC_TYPE_SIGNAL
165 AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf getopt_long)
168 AC_MSG_CHECKING([for optarg in unistd.h])
169 AC_TRY_COMPILE(
170 [#include <unistd.h>],
171 [ char *string = optarg; int i = optind; ],
172 optarg_found=yes,
173 optarg_found=no)
174 AC_MSG_RESULT($optarg_found)
176 if test $optarg_found = yes; then
177     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
181 # Checks for header files end
182 #########################################################################
184 #########################################################################
187 # ------------- dmalloc -------------------
188 dnl dmalloc checks
189 with_dmalloc="no"
190 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
191 AC_ARG_ENABLE([dmalloc],
192 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
194 if test "X$enable_dmalloc" != "Xno" ; then
195         AC_MSG_RESULT([yes])
196         AC_CHECK_HEADER(dmalloc.h,,
197                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
198         AC_CHECK_LIB(dmalloc,main,,
199                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
200         DMALLOC_LIBS="-ldmalloc"
201         with_dmalloc="yes"
202 else
203         AC_MSG_RESULT([no])
204         DMALLOC_LIBS=""
208         AC_MSG_RESULT([no])
209         DMALLOC_LIBS=""
212 # ------------- ElectricFence -------------------
213 dnl ElectricFence checks
214 with_efence="no"
215 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
216 AC_ARG_ENABLE([efence],
217 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
219 if test "X$enable_efence" != "Xno" ; then
220         AC_MSG_RESULT([yes])
221         if test "X$with_dmalloc" = "Xyes" ; then
222                 AC_ERROR([You have requested both dmalloc and Electric Fence, however only 1 is allowed.])
223         fi
224         AC_CHECK_LIB(efence,main,,
225                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
226         with_efence="yes"
227 else
228         AC_MSG_RESULT([no])
232 AC_MSG_RESULT([no])
236 #########################################################################
238 #########################################################################
239 # gEDA/gaf specify setup start
242 DATADIR=gEDA
243 GEDADATADIR=$datadir/$DATADIR
245 if eval "test x$opt_rcdir = x"; then
246         # path not was specified with --with-rcdir
247         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
248         GEDARCDIR=$GEDADATADIR
249 else
250         # path WAS specified with --with-rcdir
251         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
252         GEDARCDIR="$opt_rcdir"
255 # Expand the prefix variable
256 # I don't like the way this is done, but it works (I hope).
257 if eval "test x$prefix = xNONE"; then
258  dprefix=$ac_default_prefix
259 else
260  dprefix=$prefix
263 gedatopdir=$dprefix/share/$DATADIR
264 expandgedadatadir=`echo $gedatopdir`
266 # this has to be expanded ( no ${prefix} ) --
267 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
268 AC_DEFINE_UNQUOTED(VERSION, "$GEDA_VERSION", [Currently running version of gEDA/gaf])
271 # gEDA/gaf specify things which need to setup
272 #########################################################################
274 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
275 GATTRIB_CFLAGS="$GTK_CFLAGS $GLIB_CFLAGS $LIBGEDA_CFLAGS"
276 GATTRIB_LDFLAGS="$GTK_LIBS $GLIB_LIBS $LIBGEDA_LIBS"
278 # Makefile.in variable substitution
279 AC_SUBST(GATTRIB_CFLAGS)
280 AC_SUBST(GATTRIB_LDFLAGS)
281 AC_SUBST(GEDARCDIR)
282 AC_SUBST(GEDADATADIR)
283 AC_SUBST(PATHSEP)
284 AC_SUBST(OTHERPATHSEP)
286 # Create all the necessary derived files
287 AC_CONFIG_FILES([Makefile 
288                  src/Makefile
289                  lib/Makefile 
290                  design/Makefile
291                  include/Makefile 
292                  lib/system-gattribrc
293                 ])
295 AC_OUTPUT
297 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
298 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
300 AC_MSG_RESULT([
301 ***** Configuration summary for $PACKAGE $GATTRIB_VERSION *****
303 == gattrib version:                  $GATTRIB_VERSION
304 == base gEDA version:                $GEDA_VERSION
305 == libgeda library version:          $LIBGEDA_VERSION
306 == data directory:                   $expandedGEDADATADIR
307 == rc directory:                     $expandedGEDARCDIR
308 == compiler flags:                   $GATTRIB_CFLAGS
309 == linker flags:                     $GATTRIB_LDFLAGS
310 == glib compiler flags:              $GLIB_CFLAGS
311 == glib linker libs:                 $GLIB_LIBS
312 == glib library version:             $GLIB_VERSION
313 == gtk compiler flags:               $GTK_CFLAGS
314 == gtk linker libs:                  $GTK_LIBS
315 == gtk library version:              $GTK_VERSION
316 == dmalloc debugging:                $with_dmalloc
317 == Electric Fence debugging:         $with_efence
319 ************************************************************