2006-12-05 David Lodge <dave@cirt.net>
[dia.git] / configure.in
blobfcc7b5e95f2f9681de66e65c532936bfaa489d50
1 dnl Process this -*- autoconf -*- file with autoconf to produce a 
2 dnl configure script.
3 AC_INIT(dia, 0.95+cvs, http://bugzilla.gnome.org/enter_bug.cgi?product=dia)
4 AC_CONFIG_SRCDIR(app/diagram.c)
5 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION)
7 AC_PREREQ(2.50)
8 AC_REVISION($Revision: 1.287 $)
10 dnl Specify a header configuration file
11 AM_CONFIG_HEADER(config.h)
13 dnl do this check now, to keep autogen quiet.
14 AC_PROG_CC 
15 dnl also c++
16 AC_PROG_CXX
18 dnl Initialize maintainer mode
19 AM_MAINTAINER_MODE
21 dnl Initialize libtool
22 AC_DISABLE_STATIC
23 AC_PROG_LIBTOOL
25 dnl Build time sanity check
26 AM_SANITY_CHECK
28 dnl Checks for programs.
29 dnl AC_PROG_CC # already done 
30 AC_PROG_INSTALL
31 AC_PROG_LN_S
32 AC_PROG_MAKE_SET
33 AC_ISC_POSIX
35 dnl Checks for header files.
36 AC_HEADER_DIRENT
37 AC_HEADER_STDC
38 AC_CHECK_HEADERS(stddef.h fcntl.h unistd.h utime.h)
40 dnl Checks for typedefs, structures, and compiler characteristics.
41 AC_C_CONST
43 dnl Checks for library functions.
44 AC_CHECK_FUNCS(select strcspn strdup strtol snprintf)
46 dnl stuff for intltool
47 AC_PROG_INTLTOOL(0.21) 
49 APP_LIBS=""
50 AC_SUBST(APP_LIBS)
53 dnl Checks for libraries
55 PKG_CHECK_MODULES(GMODULE, gmodule-2.0 gobject-2.0)
56 AC_SUBST(GMODULE_CFLAGS)
57 AC_SUBST(GMODULE_LIBS)
58 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
60 GTK_MODULES="gtk+-2.0 >= 2.6.0 glib-2.0 >= 2.6.0 libxml-2.0 gdk-pixbuf-2.0 gthread-2.0"
61 PKG_CHECK_MODULES(PANGOVERSION, pango >= 1.1.5, , 
62                   AC_MSG_ERROR([Need Pango version 1.1.5 or higher]))
64 AC_ARG_WITH(freetype,
65 [  --without-freetype        compile without FreeType support],,with_freetype=yes)
66 if test "x$with_freetype" == "xyes"; then
67 PKG_CHECK_MODULES(PANGOFT2,pangoft2,have_pangoft2=true,have_pangoft2=false)
68 if test "$have_pangoft2" = "true"; then
69   dnl On Solaris with Forte C, at least, need to link app/dia with -lfreetype.
70   dnl It's not enough that -lpangoft2 implicitly pulls it in.
71   have_freetype=false
72   AC_CHECK_LIB(freetype,FT_Init_FreeType,have_freetype=true,have_freetype=false,`freetype-config --libs`)
73   if test "$have_freetype" = "true"; then
74     dnl Need 2.0.9, as a bug was fixed for us there.
75     dnl However, freetype-config doesn't give a meaningful version, so we must
76     dnl do it like this.
77     AC_MSG_CHECKING([if FreeType version is 2.0.9 or higher])
78     old_CPPFLAGS="$CPPFLAGS"
79     CPPFLAGS="$CPPFLAGS `freetype-config --cflags`"
80     AC_TRY_CPP([#include <ft2build.h>
81 #include FT_FREETYPE_H
82 #if (FREETYPE_MAJOR*1000+FREETYPE_MINOR)*1000+FREETYPE_PATCH < 2000009
83 #error Freetype version too low.
84 #endif
86         [AC_MSG_RESULT(yes)
87          FREETYPE_LIBS=`freetype-config --libs`
88          AC_SUBST(FREETYPE_LIBS)
89          FREETYPE_CFLAGS=`freetype-config --cflags`
90          AC_SUBST(FREETYPE_CFLAGS)
91          GTK_MODULES="$GTK_MODULES pangoft2"
92          AC_DEFINE(HAVE_FREETYPE,1,[Define if you have the FreeType2 library])]
93     ,
94         [AC_MSG_ERROR([Need FreeType library version 2.0.9 or higher])])
95     CPPFLAGS="$old_CPPFLAGS"
96   else
97     AC_MSG_ERROR(Can't find FreeType library)
98   fi
99 else
100   AC_MSG_ERROR(Can't find PangoFT2 library)
103 AM_CONDITIONAL(WITH_FREETYPE, test "x$with_freetype" != "xno")
105 CFLAGS="$FREETYPE_CFLAGS $CFLAGS"
107 dnl Try for libart
108 PKG_CHECK_MODULES(LIBART,libart-2.0,have_libart=yes,have_libart=no)
109 if test "$have_libart" = "yes" ; then
110    GTK_MODULES="$GTK_MODULES libart-2.0"
111    AC_DEFINE(HAVE_LIBART,1,[Define if building with LIBART support])
114 AC_MSG_CHECKING([whether GNOME specific code should be used])
115 AC_ARG_ENABLE(gnome,[  --enable-gnome          enable gnome code],
116               GNOME=$enableval, GNOME=no)
117 if test "$GNOME" = "yes" ; then
118     GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0"
119     AC_DEFINE(GNOME,1,[Define if building with GNOME support])
120     AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [GNOME icon directory])
121     have_gnome=true
122 else
123     have_gnome=false
125 AM_CONDITIONAL(HAVE_GNOME, $have_gnome)
126 AC_MSG_RESULT($GNOME)
128 dnl GTK2:     libgnomecanvas-2.0 ?
130 PKG_CHECK_MODULES(GTK,$GTK_MODULES)
131 AC_SUBST(GTK_CFLAGS)
132 AC_SUBST(GTK_LIBS)
134 AM_CONDITIONAL(HAVE_BONOBO,false)
136 dnl Look for Gnome Print
137 AC_ARG_WITH(gnomeprint,
138 [  --with-gnomeprint        compile *experimental* gnomeprint plug-in],,with_gnomeprint=no)
139 if test "x$with_gnomeprint" == "xyes"; then
140   PKG_CHECK_MODULES(GNOMEPRINT, libgnomeprint-2.2, have_gnomeprint=yes,have_gnomeprint=no)
141   AC_SUBST(GNOMEPRINT_LIBS)
142   AC_SUBST(GNOMEPRINT_CFLAGS)
143   AC_DEFINE(HAVE_GNOMEPRINT,1,[Define if building with Gnome Print support])
145 AM_CONDITIONAL(WITH_GNOMEPRINT, test "x$with_gnomeprint" != "xno")
147 dnl Look for Cairo
148 AC_ARG_WITH(cairo,
149 [  --with-cairo           compile *experimental* cairo plug-in],,with_cairo=no)
150 if test "x$with_cairo" != "xno"; then
151   PKG_CHECK_MODULES(CAIROVERSION, cairo >= 0.6.0, , 
152                     AC_MSG_ERROR([Need Cairo version 0.6.0 or higher]))
153   PKG_CHECK_MODULES(CAIRO, cairo,have_cairo=yes,have_cairo=no)
154   AC_SUBST(CAIRO_LIBS)
155   AC_SUBST(CAIRO_CFLAGS)
156   AC_DEFINE(HAVE_CAIRO,1,[Define if building with Cairo support])
158 AM_CONDITIONAL(WITH_CAIRO, test "x$with_cairo" != "xno")
160 dnl XSLT
162 # Check if XSLT is available at all
163 XSLT_DIR=""
164 PKG_CHECK_MODULES(XSLT, libxslt, have_xslt=true, have_xslt=false)
165 AM_CONDITIONAL(HAVE_XSLT, $have_xslt)
166 if test "$have_xslt" = "true"; then
167   XSLT_DIR="xslt"
168   XSLT_LIBS="`$PKG_CONFIG --libs libxslt`"
169   XSLT_CFLAGS="`$PKG_CONFIG --cflags libxslt`"
172 AC_SUBST(XSLT_DIR)
173 AC_SUBST(XSLT_LIBS)
174 AC_SUBST(XSLT_CFLAGS)
176 # Figure out a prefix for where to find libxslt at runtime.
177 AC_ARG_WITH(xslt-prefix, 
178             [  --with-xslt-prefix=DIR     Specify where to find the optional XSLT libraries
179                              (default=/usr/lib)], 
180             libxslt_prefix=$withval,
181             libxslt_prefix=/usr/lib)
182 AC_DEFINE_UNQUOTED(LIBXSLT_PREFIX,"$libxslt_prefix", [Place to look for XSLT libs])
185 dnl Popt
188 AC_CHECK_LIB(popt, poptSetOtherOptionHelp, [
189                 AC_DEFINE(HAVE_LIBPOPT,,[popt library available])
190                    POPT_LIBS="-lpopt"])
191 AC_CHECK_HEADERS(popt.h)
192 AC_SUBST(POPT_LIBS)
193 APP_LIBS="$APP_LIBS $POPT_LIBS"
196 dnl libpng
198 dnl this likely already comes from GTK
200 dnl Something in here pollutes $LIBS with -lpng.  Make sure to
201 dnl avoid that.
203 old_LIBS="${LIBS}"
205 png_ok=no
206 AC_CHECK_HEADER(png.h, png_ok=yes, png_ok=no)
207 AC_CHECK_LIB(png, png_read_info, ,png_ok=no, -lz -lm)
208 if test "$png_ok" = yes; then
209   AC_MSG_CHECKING([for png_structp in png.h])
210   dnl Why can't AC_LINK_IFELSE take extra libs?
211   old_LDFLAGS="${LDFLAGS}"
212   LDFLAGS="${LDFLAGS} -lz -lm"
213   AC_LINK_IFELSE([#include <png.h>
214                   png_structp pp;
215                   png_infop info; 
216                   png_colorp cmap; 
217                   main() { void*foo = png_create_read_struct; }],
218                  png_ok=yes,
219                  png_ok=no)
220   LDFLAGS="${old_LDFLAGS}"
221   AC_MSG_RESULT($png_ok)
222   if test "$png_ok" = yes; then
223     PNG_LIBS='-lpng -lz -lm'
224     AC_DEFINE(HAVE_LIBPNG,,[PNG library available])
225   fi
227 AC_SUBST(PNG_LIBS)
229 LIBS="${old_LIBS} ${PNG_LIBS}"
232 dnl Debugging
234 AC_ARG_ENABLE(debug, 
235 [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],
236   ,
237   enable_debug=minimum)
239 if test "x$enable_debug" = "xyes"; then
240   DEBUG_FLAGS="-g -DENABLE_DEBUG"
241 else
242   if test "x$enable_debug" = "xno"; then
243     DEBUG_FLAGS=""
244   else
245     DEBUG_FLAGS=""
246   fi
248 AC_SUBST(DEBUG_FLAGS)
251 dnl i18n
254 GETTEXT_PACKAGE=dia
255 AC_SUBST(GETTEXT_PACKAGE)
256 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Needed for glib gettext])
257 ALL_LINGUAS="am ar az be bg bs ca cs da de el en_CA en_GB es eu fi fr ga gl gu hr hu id is it ja ko lt mk ml mn ms nb ne nl nn pl pt pt_BR ro ru rw sk sl sq sr sr@Latn sv th tr uk vi zh_CN zh_TW"
259 AC_CHECK_PROG(XGETTEXT, xgettext, xgettext, none)
260 if test "$XGETTEXT" == none ; then
261    AC_MSG_ERROR([xgettext program not found: $XGETTEXT.])
264 AM_GLIB_GNU_GETTEXT
267 dnl INTLOBJS doesn't seem to always get subst'ed, but I believe it's
268 dnl idempotent
269 AC_SUBST(INTLOBJS)
271 localedir='${prefix}/${DATADIRNAME}/locale'
272 AC_SUBST(localedir)
275 dnl Locate the gnome-xml library
277 dnl GTK2: remove support for libxml1. move check for libxml2 in 
278 dnl AM_PATH_GTK_2_0's fourth argument (module is libxml-2.0)
280 found_libxml=false
281 if test $found_libxml = false; then
282   AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config)
283   if test "x$XML2_CONFIG" != x ; then
284     AC_MSG_CHECKING(for libxml >= 2.3.9)
285     vers=`$XML2_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
287     if test "$vers" -ge 2003009; then
288       AC_MSG_RESULT(found)
289       found_libxml=true
290       XML_LIBS="`$XML2_CONFIG --libs`"
291       XML_CFLAGS="`$XML2_CONFIG --cflags`"
293       if test "$enable_gnome_print" = "yes"; then
294           gnome-config --cflags print | \
295           grep gnome-xml 2>&1 >/dev/null && \
296           AC_MSG_ERROR(libxml2 found but gnome-print uses libxml1 ; this is a conflict.\nPlease do either provide libxml1 or disable gnome-print.)
297       fi
298       echo $GNOME_CFLAGS | \
299       grep gnome-xml 2>&1 >/dev/null && \
300       AC_MSG_ERROR(libxml2 found but one GNOME component uses libxml1 ; this is a conflict.\nPlease do either provide libxml1 or disable the offending GNOME component.)
301         
302     else
303       AC_MSG_RESULT(not found)
304     fi
305   fi
308 if test $found_libxml = false; then
309 AC_CHECK_PROG(XML_CONFIG, xml-config, xml-config)
310 if test "x$XML_CONFIG" != x ; then
311   AC_MSG_CHECKING(for libxml >= 1.8.14)
312   vers=`$XML_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
314   dnl 1.18.14 is required for xmlUseNewParser()    
315   if test "$vers" -ge 1008014; then
316     AC_MSG_RESULT(found)
317     found_libxml=true
318     XML_LIBS="`$XML_CONFIG --libs`"
319     XML_CFLAGS="`$XML_CONFIG --cflags`"
320   else
321     AC_MSG_RESULT(not found)
322   fi
326 if test $found_libxml = false; then
327     AC_MSG_ERROR(Neither libxml1 or libxml2 found. You must install one (libxml1, preferably))
330 AC_SUBST(XML_LIBS)
331 AC_SUBST(XML_CFLAGS)
333 CFLAGS="$XML_CFLAGS $CFLAGS"
335 dnl LibZ
336 AC_CHECK_HEADERS(zlib.h,
337     AC_CHECK_LIB(z, gzread,[
338         AC_DEFINE(HAVE_LIBZ,, we have the libz compression library)
339         if test "x${Z_DIR}" != "x"; then
340             Z_CFLAGS="-I${Z_DIR}/include"
341             Z_LIBS="-L${Z_DIR}/lib -lz"
342         else
343             Z_LIBS="-lz"
344         fi]))
346 AC_SUBST(Z_LIBS)
348 CFLAGS="${CFLAGS} ${Z_CFLAGS}"
349 LIBS="${LIBS} ${Z_LIBS}"
352 dnl Path to UI resources
353 AC_SUBST(uidatadir, '${pkgdatadir}/ui')
356 dnl Platform-specific fixes.
357 dnl 
359 dnl Sun Forte C provides isinf() in the unbundled -lsunmath. Solaris
360 dnl declares finite() in ieeefp.h. It's preferrable not to link 
361 dnl to -lsunmath as it's not present on all machines.
362 have_isinf=no
363 AC_CHECK_HEADERS(math.h,
364         AC_CHECK_LIB(m,isinf,
365                 have_isinf=yes))
367 if test "$have_isinf" = "no"; then
368     AC_CHECK_HEADER(ieeefp.h,
369              [AC_CHECK_FUNC(finite, 
370                        AC_DEFINE(HAVE_IEEEFP_H,1,
371                                  [Define if finite() is defined in ieeefp.h]),
372                        AC_MSG_ERROR([Can't find a definition of neither 
373                                      finite nor isinf]))],
374              [AC_MSG_ERROR(Can't find neither a definition of
375                            isinf nor ieeefp.h)])
376 else
377     AC_DEFINE([HAVE_ISINF], 1, 
378               [Define if the isinf() function is available])
381 dnl Alpha needs -mieee or we get a segfault
382 dnl This shouldn't be needed but is here until a real solution is found
383 case "$host" in
384   alpha*-*-linux*)
385     CFLAGS="$CFLAGS -mieee"
386     ;;
387 esac
389 if test "$GCC" = yes; then
390   dnl Relieve register pressure on i386. Other architectures may become unable
391   dnl to debug, and usually have more registers anyway.
392   dnl case "$host" in 
393   dnl  i?86-pc-*)
394   dnl    DIA_CHECK_CFLAG(-fomit-frame-pointer)
395   dnl    ;;
396   dnl esac
397   dnl (it looks like gdb is very confused by this now even on x86. We might be
398   dnl getting poor stack traces with bug-buddy because of this)
400   DIA_CHECK_CFLAG(-Wall)
401   DIA_CHECK_CFLAG(-Wunused)
402   DIA_CHECK_CFLAG(--std=c89)
403   DIA_CHECK_CFLAG(-Wdeclaration-after-statement)
404   dnl I'd rather like to enable this but it fails on isnan() with -std=c89
405   dnl DIA_CHECK_CFLAG(-Werror-implicit-function-declaration)
406   dnl Premature optimization is the root of all evil.  Uncomment this if
407   dnl you want ti figure out functions that should have been inlined but aint.
408   dnl DIA_CHECK_CFLAG(-Winline)
409   DIA_CHECK_CFLAG(-Wmissing-prototypes)
410   DIA_CHECK_CFLAG(-Wmissing-declarations)
411   DIA_CHECK_CFLAG(-finline-functions)
412   DIA_CHECK_CFLAG(-fstrict-aliasing)
415 AM_CONDITIONAL(HAVE_GCC, test "$GCC" = yes)
417 dnl Do we have the db2html script to build the documentation?
418 AC_ARG_ENABLE(db2html,
419 [  --enable-db2html        don't rebuild documentation],,enable_db2html=no)
420 AC_PATH_PROG(DB2HTML, db2html, no)
421 AM_CONDITIONAL(HAVE_DB2HTML, 
422                test "x$enable_db2html" != xno && test "x$DB2HTML" != xno)
424 dnl Only enable man page generation if we have db2man (in maintainer mode)
427 dnl Have to have the nwalsh docbook.xsl, which does manpages.
428 dnl RedHat installs it in a version-numbered place.  Grumpf.
429 AC_PATH_PROG(XSLTPROC, xsltproc, no)
430 AM_CONDITIONAL(HAVE_DB2MAN, test "x$XSLTPROC" != xno)
431 AC_SUBST(DB2MAN, "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl")
433 dnl Handling for Python
434 AC_ARG_WITH(python,
435 [  --with-python           compile python plug-in],,with_python=no)
437 if test "x$with_python" != xno; then
438   AM_PATH_PYTHON(1.5.2)
439   AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(could not find pygtk module)])
440   AM_CHECK_PYTHON_HEADERS
441   AM_CHECK_PYTHON_LIB
443   if test -z "$PYTHON_INCLUDES" || test -z "$PYTHON_LIBS"; then
444     AC_MSG_ERROR([could not find files required to build python plugin])
445   fi
447 AM_CONDITIONAL(WITH_PYTHON, test "x$with_python" != "xno")
449 AC_OUTPUT(
450 Makefile
451 lib/Makefile
452 lib/pixmaps/Makefile
453 po/Makefile.in
454 objects/Makefile
455 dnl objects/sybase/Makefile
456 objects/AADL/Makefile
457 objects/bondgraph/Makefile
458 objects/chronogram/Makefile
459 objects/custom/Makefile
460 objects/ER/Makefile
461 objects/flowchart/Makefile
462 objects/FS/Makefile
463 objects/GRAFCET/Makefile
464 objects/Istar/Makefile
465 objects/Jackson/Makefile
466 objects/KAOS/Makefile
467 objects/Misc/Makefile
468 objects/network/Makefile
469 objects/SADT/Makefile
470 objects/standard/Makefile
471 objects/UML/Makefile
472 shapes/Makefile
473 shapes/Assorted/Makefile
474 shapes/BPMN/Makefile
475 shapes/ChemEng/Makefile
476 shapes/Circuit/Makefile
477 shapes/Cisco/Makefile
478 shapes/Civil/Makefile
479 shapes/Contact/Makefile
480 shapes/Cybernetics/Makefile
481 shapes/Electric/Makefile
482 shapes/flowchart/Makefile
483 shapes/Gane_and_Sarson/Makefile
484 shapes/jigsaw/Makefile
485 shapes/Logic/Makefile
486 shapes/Map/Makefile
487 shapes/Map/Isometric/Makefile
488 shapes/Misc/Makefile
489 shapes/MSE/Makefile
490 shapes/network/Makefile
491 shapes/Pneumatic/Makefile
492 shapes/RDP/Makefile
493 shapes/SDL/Makefile
494 shapes/sybase/Makefile
495 app/Makefile
496 app/pixmaps/Makefile
497 samples/Makefile
498 sheets/Makefile
499 sheets/ER/Makefile
500 sheets/GRAFCET/Makefile
501 sheets/Istar/Makefile
502 sheets/Jackson/Makefile
503 sheets/KAOS/Makefile
504 sheets/UML/Makefile
505 plug-ins/Makefile
506 plug-ins/cgm/Makefile
507 plug-ins/cairo/Makefile
508 plug-ins/dxf/Makefile
509 plug-ins/gprint/Makefile
510 plug-ins/hpgl/Makefile
511 plug-ins/metapost/Makefile
512 plug-ins/pixbuf/Makefile
513 plug-ins/pstricks/Makefile
514 plug-ins/pgf/Makefile
515 plug-ins/python/Makefile
516 plug-ins/shape/Makefile
517 plug-ins/svg/Makefile
518 plug-ins/vdx/Makefile
519 plug-ins/wmf/Makefile
520 plug-ins/wpg/Makefile
521 plug-ins/xfig/Makefile
522 plug-ins/xslt/Makefile
523 tests/Makefile
524 tests/exports/Makefile
525 data/Makefile
526 doc/Makefile
527 doc/en/Makefile
528 doc/eu/Makefile
529 doc/pl/Makefile
532 dnl GTK2: simplify this, we will have much less options.
533 echo "
535 Configuration:
536         Source code location:   ${srcdir}
537         Compiler:               ${CC}
539         Gnome support:                          ${GNOME}
540         Python support:                         ${with_python}
541         Libart support (PNG export):            ${have_libart}
542         Cairo support (experimental):           ${with_cairo}
543         Gnome Print support (experimental):     ${with_gnomeprint}
546 echo "Now type make to build dia..."