Use a text object as context for calculating size.
[geda-gaf/berndj.git] / gattrib / configure.ac
blob83024724835adf18de5a7c68724bf394745c8b8b
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([geda-gattrib], [1.5.0], [bernd@bpj-code.co.za])
3 AM_INIT_AUTOMAKE([no-define])
4 AC_CONFIG_SRCDIR([src/gattrib.c])
5 AC_PREREQ(2.54)
7 DATE_VERSION=20080706
8 echo Configuring $PACKAGE version $PACKAGE_VERSION.$DATE_VERSION
10 AM_CONFIG_HEADER([config.h])
12 # Create option to debug
13 AC_ARG_ENABLE(debug,
14 [ --enable-debug  Sets the DEBUG flag which causes lots of debug spew to be generated],
15 [ AC_DEFINE(DEBUG, 1, DEBUG) ]
19 #########################################################################
20 # Command line flags start
21
22 # Change default location for rc files
23 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
25 # Change default location for XDG files (.desktop and icons)
26 AC_ARG_WITH(xdgdatadir, [  --with-xdgdatadir=path  Change where the .desktop file and theme icons are installed [[DATADIR]]], [opt_xdgdatadir=$withval])
28
29 # Command line flags end
30 #########################################################################
32 # Checks for programs.
33 AC_PROG_CC
34 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
35 AC_PROG_MAKE_SET
36 AC_PATH_PROGS(AWK, nawk gawk mawk awk, )
37 IT_PROG_INTLTOOL(0.35.0)
39 # Work around weird bug involving GUILE_FLAGS:
40 # http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23034
41 AC_PROG_CPP
43 ############################################################################
44 # Update desktop database utility start
47 AC_ARG_ENABLE(update-desktop-database,
48    AC_HELP_STRING([--disable-update-desktop-database],
49                    [do not update desktop file database after installation]),,
50                    enable_update_desktop_database=yes)
52 AM_CONDITIONAL(ENABLE_UPDATE_DESKTOP_DATABASE,
53                test x$enable_update_desktop_database = xyes)
55 if test x$enable_update_desktop_database = xyes ; then
56   AC_PATH_PROG(UPDATE_DESKTOP_DATABASE, [update-desktop-database], no)
57   if test $UPDATE_DESKTOP_DATABASE = no; then
58      AC_MSG_ERROR([Cannot find update-desktop-database, make sure it is installed and in your PATH, or configure with --disable-update-desktop-database])
59   fi
63 # Update desktop database utility end
64 ############################################################################
66 # Set USE_NLS
67 AM_NLS
69 # Set package name for translations
70 GETTEXT_PACKAGE=$PACKAGE
71 AC_SUBST(GETTEXT_PACKAGE)
73 # Check pre-requsites for the PO dir.
74 # (Needed without explicitly initialising gettext)
75 AM_PO_SUBDIRS
77 #########################################################################
78
79 #  Misc win32 / mingw checks and variables start
80 #  Win32 stuff currently unsupported by SDB.
81 AC_CANONICAL_HOST
83 # Figure out if we are building on win32 and what environment.
84 case $host_os in
85   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
86 esac
88 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
89    MINGW="yes"
90 else
91    # Unix host
92    MINGW="no"
95
96 # Misc win32 / mingw checks and variables end
97 #########################################################################
99 ############################################################################
100 # Check for guile start
102 # Check for pkg-config
103 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
104 if test $PKG_CONFIG = no; then
105    AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
108 PKG_CHECK_MODULES(GUILE, guile-2.0, GUILE_PC="yes", no_GUILE_PC="yes")
110 if test "$GUILE_PC" = "yes" 
111 then
112    GUILE_VERSION=`$PKG_CONFIG guile-2.0 --modversion`
113 else
114    # Find about the installed guile
115    GUILE_FLAGS
116    GUILE_VERSION=`$GUILE_CONFIG info guileversion`
119 # Check Guile version
120 guile_need_major=1
121 guile_need_minor=6
122 guile_need_version="$guile_need_major[].$guile_need_minor.0"
124 AC_MSG_CHECKING([Guile version >= $guile_need_version])
126 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
127 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
128 AC_MSG_RESULT($GUILE_VERSION)
130 if test "$guile_need_major" -gt "$guile_major" \
131    || (test "$guile_need_major" -eq "$guile_major" \
132        && test "$guile_need_minor" -gt "$guile_minor"); then
133   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
136 # Guile 1.6 compatability
138 CFLAGS_temp_save="$CFLAGS"
139 CFLAGS="$CFLAGS $GUILE_CFLAGS"
140 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
141 scm_from_int,  scm_is_true,    scm_is_false,
142 scm_from_locale_string, scm_to_locale_string],,,
143 [#include <libguile.h>])
144 CFLAGS="$CFLAGS_temp_save"
146 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
147 #  define scm_is_string(x) SCM_STRINGP(x)
148 #endif])
149 AH_VERBATIM(SCM_IS_INTEGER, [#if !HAVE_DECL_SCM_IS_INTEGER
150 #  define scm_is_integer(x) SCM_INUMP(x)
151 #endif])
152 AH_VERBATIM(SCM_TO_INT, [#if !HAVE_DECL_SCM_TO_INT
153 #  define scm_to_int(x)     SCM_INUM(x)
154 #endif])
155 AH_VERBATIM(SCM_FROM_INT, [#if !HAVE_DECL_SCM_FROM_INT
156 #  define scm_from_int(x)   SCM_MAKINUM(x)
157 #endif])
158 AH_VERBATIM(SCM_IS_TRUE, [#if !HAVE_DECL_SCM_IS_TRUE
159 #  define scm_is_true(x)    SCM_NFALSEP(x)
160 #endif])
161 AH_VERBATIM(SCM_IS_FALSE, [#if !HAVE_DECL_SCM_IS_FALSE
162 #  define scm_is_false(x)   SCM_FALSEP(x)
163 #endif])
164 AH_VERBATIM(SCM_FROM_LOCALE_STRING, [#if !HAVE_DECL_SCM_FROM_LOCALE_STRING
165 #  define scm_from_locale_string(x) scm_makfrom0str(x)
166 #endif])
167 AH_VERBATIM(SCM_TO_LOCALE_STRING, [#if !HAVE_DECL_SCM_TO_LOCALE_STRING
168 #  define scm_to_locale_string(x)   strdup(SCM_STRING_CHARS(x))
169 #endif])
172 # Check for guile end
173 ############################################################################
175 ############################################################################
176 # Check for misc things. . . .
178 # Checking for rint in math library
179 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
181 # Checking for dynamic lib
182 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
184 ############################################################################
187 ############################################################################
188 ##  This is looks for GTK2.4.
189 #                                                                                      
190 # Search for gtk+ 2.4.x 
191 PKG_CHECK_MODULES(GTK24, gtk+-2.0 >= 2.4.0, GTK24="yes", no_GTK24="yes")
193 # This next bit of code figures out what gtk we need to use.
194 if test "$GTK24" = "yes" 
195 then
197    AC_DEFINE(HAS_GTK24, 1, [If gtk+ 2.4.x has been installed, define this])
198    GTK_CFLAGS=$GTK24_CFLAGS
199    GTK_LIBS=$GTK24_LIBS
200    GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
202    # Search for glib
203    PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
204    if test "$GLIB24" != "yes"
205    then
206        AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.])
207    fi
208    GLIB_CFLAGS=$GLIB24_CFLAGS
209    GLIB_LIBS=$GLIB24_LIBS
210    GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
212 ##   GTKITEMENTRY_SOURCE=gtkitementry_2_2.c gtkitementry_2_2.h
214    # Search for gthread
215    PKG_CHECK_MODULES(GTHREAD, gthread-2.0, GTHREAD="yes", no_GTHREAD="yes")
216    if test "$GTHREAD" = "yes"
217    then
218        AC_DEFINE(HAVE_GTHREAD, 1, [If gthread support is installed, define this])
219    fi
221 else
222    GTK_VERSION=""
225                                                                                       
226 if test "$GTK_VERSION" = ""
227 then
228    AC_MSG_ERROR([Cannot find gtk+ 2.4.x or later, please install gtk+.])
231 ##  These tell Makefile.am which package to compile
232 AM_CONDITIONAL(GTK24_SOURCE, test "$GLIB24" = "yes")
233                                                                                       
235 # Check for gtk+ 2.4 end
236 ############################################################################
237                                                                                       
239 ############################################################################
240 # Check for libgeda start
242 PKG_CHECK_MODULES(LIBGEDA, libgeda >= $DATE_VERSION, LIBGEDA="yes", 
243                   no_LIBGEDA="yes")
245 if test "$LIBGEDA" = "yes" 
246 then
247    LIBGEDA_VERSION=`$PKG_CONFIG libgeda --modversion`
248 else
249    AC_MSG_ERROR([libgeda detection error: $LIBGEDA_PKG_ERRORS])
253 # Check for libgeda end
254 ############################################################################
256 ############################################################################
257 # Check for doxygen start
260 # Doxygen is a utility for generating html and latex documentation
261 # from c source code files.
263 # search for Doxygen
264 AC_PATH_PROG(DOXYGEN, doxygen, no, ${PATH})
266 if test "$DOXYGEN" = "no"; then
267    # doxygen is not available on the system
268    echo "** Cannot find Doxygen! **"
269    echo "**   Documentation creation disabled    **"
270    DOXYGEN=echo
272    # prevent from creating html and latex documents.
273    # but does not prevent from processing gschemdoc
274    builddoc=false
275 else
276    # doxygen is available on the system.
277    # now checking if the tools for Texinfo files processing
278    # is installed.
279    # The docs can be either processed to produce dvi, html or info
280    # with texi2dvi, texi2html or makeinfo respectively
281    # Note : these tests on makeinfo and texi2dvi are no more
282    #        needed as automake makes them for us
284    # enable the creation of html and latex documents.
285    builddoc=true
288 # depending on variable builddoc, weaving is performed or not
289 # using conditionnal in docs/Makefile.in
290 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
293 # Check for doxygen end
294 #########################################################################
297 #########################################################################
298 # Checks for header files start
300 AC_HEADER_STDC
301 AC_HEADER_SYS_WAIT
302 AC_HEADER_DIRENT
303 AC_CHECK_HEADERS(unistd.h string.h stdlib.h \
304                  stdarg.h assert.h fcntl.h errno.h \
305                  dirent.h sys/param.h getopt.h)
307 # Checks for typedefs, structures, and compiler characteristics.
308 AC_C_CONST
310 # Checks for library functions.
311 AC_TYPE_SIGNAL
312 AC_CHECK_FUNCS(getopt_long)
315 AC_MSG_CHECKING([for optarg in unistd.h])
316 AC_TRY_COMPILE(
317 [#include <unistd.h>],
318 [ char *string = optarg; int i = optind; ],
319 optarg_found=yes,
320 optarg_found=no)
321 AC_MSG_RESULT($optarg_found)
323 if test $optarg_found = yes; then
324     AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
328 # Checks for header files end
329 #########################################################################
331 #########################################################################
334 # ------------- dmalloc -------------------
335 dnl dmalloc checks
336 with_dmalloc="no"
337 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
338 AC_ARG_ENABLE([dmalloc],
339 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
341 if test "X$enable_dmalloc" != "Xno" ; then
342         AC_MSG_RESULT([yes])
343         AC_CHECK_HEADER(dmalloc.h,,
344                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
345         AC_CHECK_LIB(dmalloc,main,,
346                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
347         DMALLOC_LIBS="-ldmalloc"
348         with_dmalloc="yes"
349 else
350         AC_MSG_RESULT([no])
351         DMALLOC_LIBS=""
355         AC_MSG_RESULT([no])
356         DMALLOC_LIBS=""
359 # ------------- ElectricFence -------------------
360 dnl ElectricFence checks
361 with_efence="no"
362 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
363 AC_ARG_ENABLE([efence],
364 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
366 if test "X$enable_efence" != "Xno" ; then
367         AC_MSG_RESULT([yes])
368         if test "X$with_dmalloc" = "Xyes" ; then
369                 AC_ERROR([You have requested both dmalloc and Electric Fence, however only 1 is allowed.])
370         fi
371         AC_CHECK_LIB(efence,main,,
372                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
373         with_efence="yes"
374 else
375         AC_MSG_RESULT([no])
379 AC_MSG_RESULT([no])
383 #########################################################################
385 #########################################################################
386 # gEDA/gaf specify setup start
389 DATADIR=gEDA
390 GEDADATADIR=$datadir/$DATADIR
392 if eval "test x$opt_rcdir = x"; then
393         # path not was specified with --with-rcdir
394         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
395         GEDARCDIR=$GEDADATADIR
396 else
397         # path WAS specified with --with-rcdir
398         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
399         GEDARCDIR="$opt_rcdir"
402 if test x$opt_xdgdatadir = x; then
403         # path was not specified with --with-xdgdatadir
404         XDGDATADIR='${datadir}'
405 else
406         # path WAS specified with --with-xdgdatadir
407         XDGDATADIR="$opt_xdgdatadir"
409 AC_SUBST(XDGDATADIR)
411 # Expand the prefix variable
412 # I don't like the way this is done, but it works (I hope).
413 if eval "test x$prefix = xNONE"; then
414  dprefix=$ac_default_prefix
415 else
416  dprefix=$prefix
419 gedatopdir=$dprefix/share/$DATADIR
420 expandgedadatadir=`echo $gedatopdir`
422 # this has to be expanded ( no ${prefix} ) --
423 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
424 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
427 # gEDA/gaf specify things which need to setup
428 #########################################################################
430 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
431 GATTRIB_CFLAGS="$GTK_CFLAGS $GLIB_CFLAGS $LIBGEDA_CFLAGS $GTHREAD_CFLAGS"
432 GATTRIB_LDFLAGS="$GTK_LIBS $GLIB_LIBS $LIBGEDA_LIBS $GTHREAD_LIBS"
434 # Makefile.in variable substitution
435 AC_SUBST(DATE_VERSION)
436 AC_SUBST(DOTTED_VERSION)
437 AC_SUBST(GATTRIB_CFLAGS)
438 AC_SUBST(GATTRIB_LDFLAGS)
439 AC_SUBST(GEDARCDIR)
440 AC_SUBST(GEDADATADIR)
442 # Create all the necessary derived files
443 AC_CONFIG_FILES([Makefile 
444                  src/Makefile
445                  lib/Makefile 
446                  docs/Makefile
447                  design/Makefile
448                  include/Makefile 
449                  data/Makefile
450                  po/Makefile.in
451                  po/Makefile
452                  lib/system-gattribrc
453                 ])
455 AC_OUTPUT
457 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
458 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
459 expandedXDGDATADIR=`eval "echo $XDGDATADIR"`
461 AC_MSG_RESULT([
462 ***** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION *****
464 == libgeda library version:          $LIBGEDA_VERSION
465 == data directory:                   $expandedGEDADATADIR
466 == rc directory:                     $expandedGEDARCDIR
467 == xdg directory:                    $expandedXDGDATADIR
468 == compiler flags:                   $GATTRIB_CFLAGS
469 == linker flags:                     $GATTRIB_LDFLAGS
470 == glib compiler flags:              $GLIB_CFLAGS
471 == glib linker libs:                 $GLIB_LIBS
472 == glib library version:             $GLIB_VERSION
473 == gtk compiler flags:               $GTK_CFLAGS
474 == gtk linker libs:                  $GTK_LIBS
475 == gtk library version:              $GTK_VERSION
476 == dmalloc debugging:                $with_dmalloc
477 == Electric Fence debugging:         $with_efence
479 ************************************************************