Use new text accessors.
[geda-gaf/berndj.git] / libgeda / configure.ac.in
blobac9ae201c8b2424a944cee5d6a7f3403053638e7
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/libgeda.c])
4 AC_PREREQ(2.54)
6 PACKAGE=libgeda
7 DOTTED_VERSION=1.5.0
8 DATE_VERSION=20080706
9 SHARED_LIBRARY_VERSION=34:0:0
10 echo Configuring $PACKAGE version $DOTTED_VERSION.$DATE_VERSION
12 # Init automake
13 AM_INIT_AUTOMAKE($PACKAGE, $DOTTED_VERSION, no-define)
14 AM_CONFIG_HEADER([config.h])
15 AC_SUBST([CONFIG_DEPENDENCIES], ['$(top_srcdir)/configure.ac.in'])
17 # Call this to make autoconf and friends happy
18 AC_GNU_SOURCE
20 # Init libtool
21 AM_PROG_LIBTOOL
23 #########################################################################
24 # Command line flags start
25
27 # Change default location for rc files
28 AC_ARG_WITH(rcdir, [  --with-rcdir=path       Change where the system-*rc files are installed], [opt_rcdir=$withval])
30 # Change default location for XDG files (MIME and Icons)
31 AC_ARG_WITH(xdgdatadir, [  --with-xdgdatadir=path  Change where the theme icons and mime registrations are installed [[DATADIR]]], [opt_xdgdatadir=$withval])
33 # Change default location for KDE data files (KDE MIME registrations)
34 AC_ARG_WITH(kdedatadir, [  --with-kdedatadir=path  Change where the KDE mime registrations are installed [[DATADIR]]], [opt_kdedatadir=$withval])
36
37 # Command line flags end
38 #########################################################################
40 # Checks for libraries.
41 #########################################################################
42
43 # Misc win32 / mingw checks and variables start
45 # Figure out if we are building on win32 and what environment.
46 case $host_os in
47   *mingw32* ) echo "Configuring for mingw"; MINGW=yes ;;
48 esac
50 if ! test "$MINGW" = "no" -o "$MINGW"x = x; then
51    MINGW_CFLAGS="-mms-bitfields -mwindows"
52    MINGW="yes"
53 else
54    # Unix host
55    MINGW_CFLAGS=
56    MINGW="no"
59
60 # Misc win32 / mingw checks and variables end
61 #########################################################################
63 # Checks for programs.
64 AC_PROG_CC
65 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")
66 AC_PROG_CPP
67 AC_PROG_MAKE_SET
69 ############################################################################
70 # Internationalisation start
72 # Set USE_NLS
73 AC_GEDA_MACRO_CHECK([AM_NLS], [nls.m4])
74 AM_NLS
76 # Set package name for translations
77 so_major=`echo "$SHARED_LIBRARY_VERSION" | sed 's/:.*//'`
78 GETTEXT_PACKAGE=$PACKAGE$so_major
79 AH_TEMPLATE([GETTEXT_PACKAGE], [Name of this program's gettext domain])
80 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"])
81 AC_SUBST(GETTEXT_PACKAGE)
83 # Initialise gettext
84 AC_GEDA_MACRO_CHECK([AM_GNU_GETTEXT], [gettext.m4])
85 AM_GNU_GETTEXT
86 AM_GNU_GETTEXT_VERSION([%INSTALLED_GETTEXT_VERSION%])
88 # Initialise intltool
89 AC_GEDA_MACRO_CHECK([IT_PROG_INTLTOOL], [intltool.m4])
90 IT_PROG_INTLTOOL(0.35.0)
92
93 # Internationalisation end
94 #########################################################################
96 ############################################################################
97 # Check for pkg-config start
100 # Check for pkg-config
101 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
102 if test $PKG_CONFIG = no; then
103     AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
107 # Check for pkg-config end
108 ############################################################################
110 ############################################################################
111 # Check for guile start
114 PKG_CHECK_MODULES(GUILE, guile-2.0, GUILE_PC="yes", no_GUILE_PC="yes")
116 if test "$GUILE_PC" = "yes" 
117 then
118    GUILE_LDFLAGS=$GUILE_LIBS
119    GUILE_VERSION=`$PKG_CONFIG guile-2.0 --modversion`
120 else
121    # Find about the installed guile
122    AC_GEDA_MACRO_CHECK([GUILE_FLAGS], [guile.m4])
123    GUILE_FLAGS
124    GUILE_VERSION=`$GUILE_CONFIG info guileversion`
127 # Check Guile version
128 guile_need_major=1
129 guile_need_minor=8
130 guile_need_version="$guile_need_major[].$guile_need_minor.0"
132 AC_MSG_CHECKING([Guile version >= $guile_need_version])
134 guile_major=`echo "$GUILE_VERSION" | sed 's/\([[^.]][[^.]]*\).*/\1/'`
135 guile_minor=`echo "$GUILE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
136 AC_MSG_RESULT($GUILE_VERSION)
138 if test "$guile_need_major" -gt "$guile_major" \
139    || (test "$guile_need_major" -eq "$guile_major" \
140        && test "$guile_need_minor" -gt "$guile_minor"); then
141   AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
144 # Guile 1.6 compatability
146 CFLAGS_temp_save="$CFLAGS"
147 CFLAGS="$CFLAGS $GUILE_CFLAGS"
148 AC_CHECK_DECLS([
149 scm_caddr,
150 scm_cadr,
151 scm_car,
152 scm_from_int,
153 scm_from_locale_string,
154 scm_from_locale_symbol,
155 scm_is_false,
156 scm_is_integer,
157 scm_is_string,
158 scm_is_true,
159 scm_to_int,
160 scm_to_locale_string],,,
161 [#include <libguile.h>])
162 CFLAGS="$CFLAGS_temp_save"
165 # Check for guile end
166 ############################################################################
168 ############################################################################
169 # Check for mics things start
171 # Checking for rint in math library
172 AC_CHECK_LIB(m, rint, AC_DEFINE(HAS_RINT, 1, [If your math library has rint in it, define this]), no_RINT="yes")
174 # An implementation of libuuid lives in e2fsprogs, of all places!
175 # FIXME: There are several hostilely incompatible uuid libraries.  Rather just
176 # use libaprutil to hide the porting complexity.
177 AC_CHECK_LIB(uuid, uuid_generate,
178              UUID_LDFLAGS="-luuid"
179              AC_DEFINE(HAVE_LIBUUID, 1, [Define to 1 if you have libuuid]),
180              UUID_LDFLAGS="")
182 # Checking for dynamic lib
183 AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl", DL_LIB="")
185 # Check for mics things end
186 ############################################################################
188 ############################################################################
189 # Check for X11 start
192 if test "$MINGW" = "no"
193 then
194    AC_PATH_X
195    AC_PATH_XTRA 
196     
197    X_EXTRA_LIBS="$X_EXTRA_LIBS"
198    X_LDFLAGS="$X_LDFLAGS $X_LIBS $X_EXTRA_LIBS $X_PRE_LIBS -lX11 -lm"
202 # Check for X11 end
203 ############################################################################
205 ############################################################################
206 # Check for glib 2.4 start
209 # Search for glib
210 PKG_CHECK_MODULES(GLIB24, glib-2.0 >= 2.4.0, GLIB24="yes", no_GLIB24="yes")
211 if test "$GLIB24" != "yes"
212 then
213     AC_MSG_ERROR([Cannot find glib 2.4.x, install it and rerun ./configure.
214 You may find the following error output (if any) useful:
215 $GLIB24_PKG_ERRORS
218 GLIB_CFLAGS=$GLIB24_CFLAGS
219 GLIB_LIBS=$GLIB24_LIBS
220 GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
223 # Check for glib 2.4 end
224 ############################################################################
226 ############################################################################
227 # Check for gdk 2.4 or later
230 PKG_CHECK_MODULES(GDK, gdk-2.0 >= 2.4.0, GDK="yes", no_GDK="yes")
232 # This next bit of code figures out what gtk we need to use.
233 if test "$GDK" = "yes" 
234 then
236    AC_DEFINE(HAS_GDK, 1, [If gdk has been installed, define this])
237    GDK_CFLAGS=$GDK_CFLAGS
238    GDK_LIBS=$GDK_LIBS
239    GDK_VERSION=`$PKG_CONFIG gdk-2.0 --modversion`
243 if test "$GDK_VERSION" = ""
244 then
245    AC_MSG_ERROR([Cannot find gdk, please make sure it is installed.])
249 # Check for gdk end
250 ############################################################################
252 ############################################################################
253 # Check for gdk-pixbuf 
256 PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0 >= 0.15.0, GDK_PIXBUF="yes", no_GDK_PIXBUF="yes")
258 # This next bit of code figures out what gtk we need to use.
259 if test "$GDK_PIXBUF" = "yes" 
260 then
262    AC_DEFINE(HAS_GDK_PIXBUF, 1, [If gdk-pixbuf has been installed, define this])
263    GDK_PIXBUF_CFLAGS=$GDK_PIXBUF_CFLAGS
264    GDK_PIXBUF_LIBS=$GDK_PIXBUF_LIBS
265    GDK_PIXBUF_VERSION=`$PKG_CONFIG gdk-pixbuf-2.0 --modversion`
269 if test "$GDK_PIXBUF_VERSION" = ""
270 then
271    AC_MSG_ERROR([Cannot find gdk-pixbuf, please make sure it is installed.])
275 # Check for gdk-pixbuf end
276 ############################################################################
280 ############################################################################
281 # Check for doxygen start
284 # Doxygen is a utility for generating html and latex documentation
285 # from c source code files.
287 # search for Doxygen 
288 AC_PATH_PROG(DOXYGEN, doxygen, no, ${PATH})
290 if test "$DOXYGEN" = "no"; then 
291    # doxygen is not available on the system
292    echo "** Cannot find Doxygen! **"
293    echo "**   Documentation creation disabled    **"
294    DOXYGEN=echo
296    # prevent from creating html and latex documents.
297    # but does not prevent from processing gschemdoc
298    builddoc=false
299 else 
300    # doxygen is available on the system.
301    # now checking if the tools for Texinfo files processing
302    # is installed.
303    # The docs can be either processed to produce dvi, html or info
304    # with texi2dvi, texi2html or makeinfo respectively
305    # Note : these tests on makeinfo and texi2dvi are no more 
306    #        needed as automake makes them for us
308    # enable the creation of html and latex documents.
309    builddoc=true
312 # depending on variable builddoc, weaving is performed or not
313 # using conditionnal in docs/Makefile.in
314 AM_CONDITIONAL(BUILDDOC, test x$builddoc = xtrue)
317 # Check for doxygen end
318 #########################################################################
320 #########################################################################
321 # Checks for header files start
324 AC_HEADER_STDC
325 AC_HEADER_SYS_WAIT
326 AC_HEADER_DIRENT
327 AC_CHECK_HEADERS(unistd.h string.h stdlib.h stdarg.h assert.h fcntl.h \
328                  errno.h libgen.h)
330 AC_MSG_CHECKING([for optarg in unistd.h])
331 AC_TRY_COMPILE(
332 [#include <unistd.h>],
333 [ char *string = optarg; int i = optind; ],
334 optarg_found=yes,
335 optarg_found=no)
336 AC_MSG_RESULT($optarg_found)
337 if test $optarg_found = yes; then
338    AC_DEFINE(OPTARG_IN_UNISTD, 1, [Define if you have optarg in unistd.h])
341 # Checks for typedefs, structures, and compiler characteristics.
342 AC_C_CONST
344 # Checks for library functions.
345 AC_TYPE_SIGNAL
346 AC_CHECK_FUNCS(strstr chown getlogin)
347 save_CFLAGS=$CFLAGS
348 CFLAGS="$GLIB_CFLAGS $CFLAGS"
349 AC_CHECK_DECLS([g_date_time_format],,,[#include <glib.h>])
350 CFLAGS=$save_CFLAGS
353 # Checks for header files end
354 #########################################################################
356 #########################################################################
359 # ------------- dmalloc -------------------
360 dnl dmalloc checks
361 with_dmalloc="no"
362 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
363 AC_ARG_ENABLE([dmalloc],
364 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [[default=no]]],
366 if test "X$enable_dmalloc" != "Xno" ; then
367         AC_MSG_RESULT([yes])
368         AC_CHECK_HEADER(dmalloc.h,,
369                 AC_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
370         AC_CHECK_LIB(dmalloc,main,,
371                 AC_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
372         DMALLOC_LIBS="-ldmalloc"
373         with_dmalloc="yes"
374 else
375         AC_MSG_RESULT([no])
376         DMALLOC_LIBS=""
380         AC_MSG_RESULT([no])
381         DMALLOC_LIBS=""
384 # ------------- ElectricFence -------------------
385 dnl ElectricFence checks
386 with_efence="no"
387 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
388 AC_ARG_ENABLE([efence],
389 [  --enable-efence         Link with ElectricFence for malloc debugging [[default=no]]],
391 if test "X$enable_efence" != "Xno" ; then
392         AC_MSG_RESULT([yes])
393         AC_CHECK_LIB(efence,main,,
394                 AC_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
395         with_efence="yes"
396 else
397         AC_MSG_RESULT([no])
401 AC_MSG_RESULT([no])
405 #########################################################################
407 #########################################################################
408 # gEDA/gaf specific setup start
411 DATADIR=gEDA
412 GEDADATADIR=$datadir/$DATADIR
414 if eval "test x$opt_rcdir = x"; then
415         # path was not specified with --with-rcdir
416         AC_DEFINE_UNQUOTED(GEDARCDIR, "none", [gEDA/gaf's rc directory])
417         GEDARCDIR=$GEDADATADIR
418 else
419         # path WAS specified with --with-rcdir
420         AC_DEFINE_UNQUOTED(GEDARCDIR, "$opt_rcdir", [gEDA/gaf's rc directory])
421         GEDARCDIR="$opt_rcdir"
424 if test x$opt_xdgdatadir = x; then
425         # path was not specified with --with-xdgdatadir
426         XDGDATADIR='${datadir}'
427 else
428         # path WAS specified with --with-xdgdatadir
429         XDGDATADIR="$opt_xdgdatadir"
431 AC_SUBST(XDGDATADIR)
433 if test x$opt_kdedatadir = x; then
434         # path was not specified with --with-kdedatadir
435         KDEDATADIR='${datadir}'
436 else
437         # path WAS specified with --with-kdedatadir
438         KDEDATADIR="$opt_kdedatadir"
440 AC_SUBST(KDEDATADIR)
442 # Defs for libary symbol files
444 # Expand the prefix variable
445 if eval "test x$prefix = xNONE"; then
446  dprefix=$ac_default_prefix
447 else
448  dprefix=$prefix
451 gedatopdir=$dprefix/share/$DATADIR
452 expandgedadatadir=`echo $gedatopdir`
454 # this has to be expanded ( no ${prefix} ) --
455 AC_DEFINE_UNQUOTED(GEDADATADIR, "$gedatopdir", [gEDA/gaf's data directory])
456 AC_DEFINE_UNQUOTED(DATE_VERSION, "$DATE_VERSION", [Currently running date version of gEDA/gaf])
457 AC_DEFINE_UNQUOTED(DOTTED_VERSION, "$DOTTED_VERSION", [Currently running dotted version of gEDA/gaf])
458 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this program's package])
461 # gEDA/gaf specify things which need to setup
462 #########################################################################
464 #########################################################################
465 # Update mime database utility start
467 # Adapted from gnome-control-center.
470 AC_ARG_ENABLE(update-mime-database,
471    AC_HELP_STRING([--disable-update-mime-database],
472                    [do not update mime database after installation]),,
473                    enable_update_mime_database=yes)
475 AM_CONDITIONAL(ENABLE_UPDATE_MIME_DATABASE,
476                test x$enable_update_mime_database = xyes)
478 if test x$enable_update_mime_database = xyes ; then
479   AC_PATH_PROG(UPDATE_MIME_DATABASE, [update-mime-database], no)
480   if test $UPDATE_MIME_DATABASE = no; then
481      AC_MSG_ERROR([Cannot find update-mime-database, make sure it is installed and in your PATH, or configure with --disable-update-mime-database])
482   fi
486 # Update mime database utility end
487 #########################################################################
489 # Finally create the final CFLAGS and LDFLAGS for use in the makefiles
490 LIBGEDA_CFLAGS="$MINGW_CFLAGS $GUILE_CFLAGS $GLIB_CFLAGS $X_CFLAGS $GDK_PIXBUF_CFLAGS $GDK_CFLAGS"
491 LIBGEDA_LDFLAGS="$GUILE_LDFLAGS $GLIB_LIBS $DMALLOC_LIBS $GDK_PIXBUF_LIBS $GDK_LIBS $UUID_LDFLAGS"
492 LIBTOOL_FLAGS="-version-info $SHARED_LIBRARY_VERSION"
494 # Makefile.in variable substitution
495 AC_SUBST(DATE_VERSION)
496 AC_SUBST(DOTTED_VERSION)
497 AC_SUBST(LIBGEDA_CFLAGS)
498 AC_SUBST(LIBGEDA_LDFLAGS)
499 AC_SUBST(LIBTOOL_FLAGS)
500 AC_SUBST(GEDADATADIR)
501 AC_SUBST(GEDARCDIR)
502 AC_SUBST(PATHSEP)
503 AC_SUBST(OTHERPATHSEP)
504 AC_SUBST(GUILEINTERP)
505 AC_SUBST(INDENT)
507 # Create all the necessary derived files
508 AC_CONFIG_FILES([Makefile
509                  src/Makefile
510                  include/Makefile
511                  docs/Makefile
512                  data/Makefile
513                  intl/Makefile
514                  po/Makefile.in
515                  po/Makefile
516                  libgeda.pc
517                  share/Makefile
518                  lib/Makefile
519                  scheme/Makefile
520                  tests/Makefile])
522 AC_OUTPUT
524 expandedGEDADATADIR=`eval "echo $GEDADATADIR"`
525 expandedGEDARCDIR=`eval "echo $GEDARCDIR"`
526 expandedXDGDATADIR=`eval "echo $XDGDATADIR"`
527 expandedKDEDATADIR=`eval "echo $KDEDATADIR"`
529 AC_MSG_RESULT([
530 ** Configuration summary for $PACKAGE $DOTTED_VERSION.$DATE_VERSION
532    GLIB library version:             $GLIB_VERSION
533    GDK library version:              $GDK_VERSION
534    GDK-PIXBUF (png output):          $GDK_PIXBUF_VERSION
535    GUILE library version:            $GUILE_VERSION
536    mingw build:                      $MINGW
537    data directory:                   $expandedGEDADATADIR
538    rc directory:                     $expandedGEDARCDIR
539    xdg data directory:               $expandedXDGDATADIR
540    KDE data directory:               $expandedKDEDATADIR
541    LIBGEDA .so version:              $SHARED_LIBRARY_VERSION
542    dmalloc debugging:                $with_dmalloc
543    ElectricFence debugging:          $with_efence