2004-12-11 Hans Breuer <hans@breuer.org>
[dia.git] / configure.in
blob5db0693db0c009aaf17162253d89f06a0ec9c891
1 dnl Process this -*- autoconf -*- file with autoconf to produce a 
2 dnl configure script.
3 AC_INIT(dia, 0.94, 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.245 $)
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 AM_PATH_GLIB_2_0(2.0.0)
56 PKG_CHECK_MODULES(GMODULE, gmodule-2.0 gobject-2.0)
57 AC_SUBST(GMODULE_CFLAGS)
58 AC_SUBST(GMODULE_LIBS)
60 AM_PATH_GTK_2_0(2.4.0)
62 GTK_MODULES="gtk+-2.0 libxml-2.0 gdk-pixbuf-2.0 gthread-2.0"
63 PKG_CHECK_MODULES(PANGOVERSION, pango >= 1.1.5, , 
64                   AC_MSG_ERROR([Need Pango version 1.1.5 or higher]))
65 PKG_CHECK_MODULES(PANGOFT2,pangoft2,have_pangoft2=true,have_pangoft2=false)
66 if test "$have_pangoft2" = "true"; then
67   dnl On Solaris with Forte C, at least, need to link app/dia with -lfreetype.
68   dnl It's not enough that -lpangoft2 implicitly pulls it in.
69   have_freetype=false
70   AC_CHECK_LIB(freetype,FT_Init_FreeType,have_freetype=true,have_freetype=false,`freetype-config --libs`)
71   if test "$have_freetype" = "true"; then
72     dnl Need 2.0.9, as a bug was fixed for us there.
73     dnl However, freetype-config doesn't give a meaningful version, so we must
74     dnl do it like this.
75     AC_MSG_CHECKING([if FreeType version is 2.0.9 or higher])
76     old_CPPFLAGS="$CPPFLAGS"
77     CPPFLAGS="$CPPFLAGS `freetype-config --cflags`"
78     AC_TRY_CPP([#include <ft2build.h>
79 #include FT_FREETYPE_H
80 #if (FREETYPE_MAJOR*1000+FREETYPE_MINOR)*1000+FREETYPE_PATCH < 2000009
81 #error Freetype version too low.
82 #endif
84         [AC_MSG_RESULT(yes)
85          FREETYPE_LIBS=`freetype-config --libs`
86          AC_SUBST(FREETYPE_LIBS)
87          FREETYPE_CFLAGS=`freetype-config --cflags`
88          AC_SUBST(FREETYPE_CFLAGS)
89          GTK_MODULES="$GTK_MODULES pangoft2"
90          AC_DEFINE(HAVE_FREETYPE,1,[Define if you have the FreeType2 library])]
91     ,
92         [AC_MSG_ERROR([Need FreeType library version 2.0.9 or higher])])
93     CPPFLAGS="$old_CPPFLAGS"
94   else
95    AC_MSG_ERROR(Can't find FreeType library)
96   fi
97 else
98    AC_MSG_ERROR(Can't find PangoFT2 library)
101 CFLAGS="$FREETYPE_CFLAGS $CFLAGS"
103 dnl Try for libart
104 PKG_CHECK_MODULES(LIBART,libart-2.0,have_libart=yes,have_libart=no)
105 if test "$have_libart" = "yes" ; then
106    GTK_MODULES="$GTK_MODULES libart-2.0"
107    AC_DEFINE(HAVE_LIBART,1,[Define if building with LIBART support])
110 AC_MSG_CHECKING([whether GNOME specific code should be used])
111 AC_ARG_ENABLE(gnome,[  --enable-gnome          enable gnome code],
112               GNOME=$enableval, GNOME=no)
113 if test "$GNOME" = "yes" ; then
114     GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0"
115     AC_DEFINE(GNOME,1,[Define if building with GNOME support])
116     AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [GNOME icon directory])
117     have_gnome=true
118 else
119     have_gnome=false
121 AM_CONDITIONAL(HAVE_GNOME, $have_gnome)
122 AC_MSG_RESULT($GNOME)
124 dnl GTK2:     libgnomecanvas-2.0 ?
126 PKG_CHECK_MODULES(GTK,$GTK_MODULES)
127 AC_SUBST(GTK_CFLAGS)
128 AC_SUBST(GTK_LIBS)
130 AM_CONDITIONAL(HAVE_BONOBO,false)
132 dnl Look for Gnome Print
133 AC_ARG_WITH(gnomeprint,
134 [  --with-gnomeprint        compile *experimental* gnomeprint plug-in],,with_gnomeprint=no)
135 if test "x$with_gprint" != "xno"; then
136   PKG_CHECK_MODULES(GNOMEPRINT, libgnomeprint-2.2, have_gnomeprint=yes,have_gnomeprint=no)
137   AC_SUBST(GNOMEPRINT_LIBS)
138   AC_SUBST(GNOMEPRINT_CFLAGS)
139   AC_DEFINE(HAVE_GNOMEPRINT,1,[Define if building with Gnome Print support])
141 AM_CONDITIONAL(WITH_GNOMEPRINT, test "x$with_gnomeprint" != "xno")
143 dnl Look for Cairo
144 AC_ARG_WITH(cairo,
145 [  --with-cairo           compile *experimental* cairo plug-in],,with_cairo=no)
146 if test "x$with_cairo" != "xno"; then
147   PKG_CHECK_MODULES(CAIRO, cairo,have_cairo=yes,have_cairo=no)
148   AC_SUBST(CAIRO_LIBS)
149   AC_SUBST(CAIRO_CFLAGS)
150   AC_DEFINE(HAVE_CAIRO,1,[Define if building with Cairo support])
152 AM_CONDITIONAL(WITH_CAIRO, test "x$with_cairo" != "xno")
154 dnl XSLT
156 # Check if XSLT is available at all
157 XSLT_DIR=""
158 PKG_CHECK_MODULES(XSLT, libxslt, have_xslt=true, have_xslt=false)
159 AM_CONDITIONAL(HAVE_XSLT, $have_xslt)
160 if test "$have_xslt" = "true"; then
161   XSLT_DIR="xslt"
162   XSLT_LIBS="`$PKG_CONFIG --libs libxslt`"
163   XSLT_CFLAGS="`$PKG_CONFIG --cflags libxslt`"
166 AC_SUBST(XSLT_DIR)
167 AC_SUBST(XSLT_LIBS)
168 AC_SUBST(XSLT_CFLAGS)
170 # Figure out a prefix for where to find libxslt at runtime.
171 AC_ARG_WITH(xslt-prefix, 
172             [  --with-xslt-prefix=DIR     Specify where to find the optional XSLT libraries
173                              (default=/usr/lib)], 
174             libxslt_prefix=$withval,
175             libxslt_prefix=/usr/lib)
176 AC_DEFINE_UNQUOTED(LIBXSLT_PREFIX,"$libxslt_prefix", [Place to look for XSLT libs])
179 dnl Popt
182 AC_CHECK_LIB(popt, poptSetOtherOptionHelp, [
183                 AC_DEFINE(HAVE_LIBPOPT,,[popt library available])
184                    POPT_LIBS="-lpopt"])
185 AC_CHECK_HEADERS(popt.h)
186 AC_SUBST(POPT_LIBS)
187 APP_LIBS="$APP_LIBS $POPT_LIBS"
190 dnl libpng
192 dnl this likely already comes from GTK
194 dnl Something in here pollutes $LIBS with -lpng.  Make sure to
195 dnl avoid that.
197 old_LIBS="${LIBS}"
199 png_ok=no
200 AC_CHECK_HEADER(png.h, png_ok=yes, png_ok=no)
201 AC_CHECK_LIB(png, png_read_info, ,png_ok=no, -lz -lm)
202 if test "$png_ok" = yes; then
203   AC_MSG_CHECKING([for png_structp in png.h])
204   dnl Why can't AC_LINK_IFELSE take extra libs?
205   old_LDFLAGS="${LDFLAGS}"
206   LDFLAGS="${LDFLAGS} -lz -lm"
207   AC_LINK_IFELSE([#include <png.h>
208                   png_structp pp;
209                   png_infop info; 
210                   png_colorp cmap; 
211                   main() { void*foo = png_create_read_struct; }],
212                  png_ok=yes,
213                  png_ok=no)
214   LDFLAGS="${old_LDFLAGS}"
215   AC_MSG_RESULT($png_ok)
216   if test "$png_ok" = yes; then
217     PNG_LIBS='-lpng -lz -lm'
218     AC_DEFINE(HAVE_LIBPNG,,[PNG library available])
219   fi
221 AC_SUBST(PNG_LIBS)
223 LIBS="${old_LIBS} ${PNG_LIBS}"
226 dnl Debugging
228 AC_ARG_ENABLE(debug, 
229 [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],
230   ,
231   enable_debug=minimum)
233 if test "x$enable_debug" = "xyes"; then
234   DEBUG_FLAGS="-g -DENABLE_DEBUG"
235 else
236   if test "x$enable_debug" = "xno"; then
237     DEBUG_FLAGS=""
238   else
239     DEBUG_FLAGS=""
240   fi
242 AC_SUBST(DEBUG_FLAGS)
245 dnl i18n
248 GETTEXT_PACKAGE=dia
249 AC_SUBST(GETTEXT_PACKAGE)
250 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Needed for glib gettext])
251 ALL_LINGUAS="am az be bs ca cs da de el en_CA en_GB es fi fr ga gu hr hu is it ja ko mk mn ml ms nb nl nn no pl pt pt_BR ro ru sk sl sq sr sr@Latn sv tr uk vi zh_CN zh_TW"
252 AM_GLIB_GNU_GETTEXT
254 dnl INTLOBJS doesn't seem to always get subst'ed, but I believe it's
255 dnl idempotent
256 AC_SUBST(INTLOBJS)
258 localedir='${prefix}/${DATADIRNAME}/locale'
259 AC_SUBST(localedir)
262 dnl Locate the gnome-xml library
264 dnl GTK2: remove support for libxml1. move check for libxml2 in 
265 dnl AM_PATH_GTK_2_0's fourth argument (module is libxml-2.0)
267 found_libxml=false
268 if test $found_libxml = false; then
269   AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config)
270   if test "x$XML2_CONFIG" != x ; then
271     AC_MSG_CHECKING(for libxml >= 2.3.9)
272     vers=`$XML2_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
274     if test "$vers" -ge 2003009; then
275       AC_MSG_RESULT(found)
276       found_libxml=true
277       XML_LIBS="`$XML2_CONFIG --libs`"
278       XML_CFLAGS="`$XML2_CONFIG --cflags`"
280       if test "$enable_gnome_print" = "yes"
281       then
282           gnome-config --cflags print | \
283           grep gnome-xml 2>&1 >/dev/null && \
284           AC_MSG_ERROR(libxml2 found but gnome-print uses libxml1 ; this is a conflict.\nPlease do either provide libxml1 or disable gnome-print.)
285       fi
286       echo $GNOME_CFLAGS | \
287       grep gnome-xml 2>&1 >/dev/null && \
288       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.)
289         
290     else
291       AC_MSG_RESULT(not found)
292     fi
293   fi
296 if test $found_libxml = false; then
297 AC_CHECK_PROG(XML_CONFIG, xml-config, xml-config)
298 if test "x$XML_CONFIG" != x ; then
299   AC_MSG_CHECKING(for libxml >= 1.8.14)
300   vers=`$XML_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
302   dnl 1.18.14 is required for xmlUseNewParser()    
303   if test "$vers" -ge 1008014; then
304     AC_MSG_RESULT(found)
305     found_libxml=true
306     XML_LIBS="`$XML_CONFIG --libs`"
307     XML_CFLAGS="`$XML_CONFIG --cflags`"
308   else
309     AC_MSG_RESULT(not found)
310   fi
314 if test $found_libxml = false; then
315     AC_MSG_ERROR(Neither libxml1 or libxml2 found. You must install one (libxml1, preferably))
318 AC_SUBST(XML_LIBS)
319 AC_SUBST(XML_CFLAGS)
321 CFLAGS="$XML_CFLAGS $CFLAGS"
323 dnl LibZ
324 AC_CHECK_HEADERS(zlib.h,
325     AC_CHECK_LIB(z, gzread,[
326         AC_DEFINE(HAVE_LIBZ,, we have the libz compression library)
327         if test "x${Z_DIR}" != "x"; then
328             Z_CFLAGS="-I${Z_DIR}/include"
329             Z_LIBS="-L${Z_DIR}/lib -lz"
330         else
331             Z_LIBS="-lz"
332         fi]))
334 AC_SUBST(Z_LIBS)
336 CFLAGS="${CFLAGS} ${Z_CFLAGS}"
337 LIBS="${LIBS} ${Z_LIBS}"
339 dnl Platform-specific fixes.
340 dnl 
342 dnl Sun Forte C provides isinf() in the unbundled -lsunmath. Solaris
343 dnl declares finite() in ieeefp.h. It's preferrable not to link 
344 dnl to -lsunmath as it's not present on all machines.
345 have_isinf=no
346 AC_CHECK_HEADERS(math.h,
347         AC_CHECK_LIB(m,isinf,
348                 have_isinf=yes))
350 if test "$have_isinf" = "no"; then
351     AC_CHECK_HEADER(ieeefp.h,
352              [AC_CHECK_FUNC(finite, 
353                        AC_DEFINE(HAVE_IEEEFP_H,1,
354                                  [Define if finite() is defined in ieeefp.h]),
355                        AC_MSG_ERROR([Can't find a definition of neither 
356                                      finite nor isinf]))],
357              [AC_MSG_ERROR(Can't find neither a definition of
358                            isinf nor ieeefp.h)])
359 else
360     AC_DEFINE([HAVE_ISINF], 1, 
361               [Define if the isinf() function is available])
364 dnl Alpha needs -mieee or we get a segfault
365 dnl This shouldn't be needed but is here until a real solution is found
366 case "$host" in
367   alpha*-*-linux*)
368     CFLAGS="$CFLAGS -mieee"
369     ;;
370 esac
372 if test "$GCC" = yes; then
373   dnl Relieve register pressure on i386. Other architectures may become unable
374   dnl to debug, and usually have more registers anyway.
375   dnl case "$host" in 
376   dnl  i?86-pc-*)
377   dnl    DIA_CHECK_CFLAG(-fomit-frame-pointer)
378   dnl    ;;
379   dnl esac
380   dnl (it looks like gdb is very confused by this now even on x86. We might be
381   dnl getting poor stack traces with bug-buddy because of this)
383   DIA_CHECK_CFLAG(-Wall)
384   DIA_CHECK_CFLAG(-Wunused)
385   dnl Premature optimization is the root of all evil.  Uncomment this if
386   dnl you want ti figure out functions that should have been inlined but aint.
387   dnl DIA_CHECK_CFLAG(-Winline)
388   DIA_CHECK_CFLAG(-Wmissing-prototypes)
389   DIA_CHECK_CFLAG(-Wmissing-declarations)
390   DIA_CHECK_CFLAG(-finline-functions)
391   DIA_CHECK_CFLAG(-fstrict-aliasing)
394 AM_CONDITIONAL(HAVE_GCC, test "$GCC" = yes)
396 dnl Do we have the db2html script to build the documentation?
397 AC_ARG_ENABLE(db2html,
398 [  --enable-db2html        don't rebuild documentation],,enable_db2html=no)
399 AC_PATH_PROG(DB2HTML, db2html, no)
400 AM_CONDITIONAL(HAVE_DB2HTML, 
401                test "x$enable_db2html" != xno && test "x$DB2HTML" != xno)
403 dnl Only enable man page generation if we have db2man (in maintainer mode)
405 dnl Have to have the nwalsh docbook.xsl, which does manpages.
406 dnl RedHat installs it in a version-numbered place.  Grumpf.
407 db2man_file=
408 for file in \
409   /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl \
410   /usr/share/sgml/docbook/xsl-stylesheets-\*/manpages/docbook.xsl; do
411   if test -f $file; then db2man_file=$file; break; fi
412 done
413 AM_CONDITIONAL(HAVE_DB2MAN, test "x$db2man_file" != x)
414 AC_SUBST(DB2MAN, "$db2man_file")
416 dnl Handling for Python
417 AC_ARG_WITH(python,
418 [  --with-python           compile python plug-in],,with_python=no)
420 if test "x$with_python" != xno; then
421   AM_PATH_PYTHON(1.5.2)
422   AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(could not find pygtk module)])
423   AM_CHECK_PYTHON_HEADERS
424   AM_CHECK_PYTHON_LIB
426   if test -z "$PYTHON_INCLUDES" || test -z "$PYTHON_LIBS"; then
427     AC_MSG_ERROR([could not find files required to build python plugin])
428   fi
430 AM_CONDITIONAL(WITH_PYTHON, test "x$with_python" != "xno")
432 AC_OUTPUT(
433 Makefile
434 lib/Makefile
435 lib/pixmaps/Makefile
436 po/Makefile.in
437 objects/Makefile
438 dnl objects/sybase/Makefile
439 objects/bondgraph/Makefile
440 objects/chronogram/Makefile
441 objects/custom/Makefile
442 objects/ER/Makefile
443 objects/flowchart/Makefile
444 objects/FS/Makefile
445 objects/GRAFCET/Makefile
446 objects/Istar/Makefile
447 objects/Jackson/Makefile
448 objects/KAOS/Makefile
449 objects/Misc/Makefile
450 objects/network/Makefile
451 objects/SADT/Makefile
452 objects/standard/Makefile
453 objects/UML/Makefile
454 shapes/Makefile
455 shapes/Assorted/Makefile
456 shapes/ChemEng/Makefile
457 shapes/Circuit/Makefile
458 shapes/Cisco/Makefile
459 shapes/Civil/Makefile
460 shapes/Contact/Makefile
461 shapes/Cybernetics/Makefile
462 shapes/Electric/Makefile
463 shapes/flowchart/Makefile
464 shapes/jigsaw/Makefile
465 shapes/Logic/Makefile
466 shapes/Map/Makefile
467 shapes/Map/Isometric/Makefile
468 shapes/Misc/Makefile
469 shapes/MSE/Makefile
470 shapes/network/Makefile
471 shapes/Pneumatic/Makefile
472 shapes/RDP/Makefile
473 shapes/SDL/Makefile
474 shapes/sybase/Makefile
475 app/Makefile
476 app/pixmaps/Makefile
477 samples/Makefile
478 sheets/Makefile
479 sheets/ER/Makefile
480 sheets/GRAFCET/Makefile
481 sheets/Istar/Makefile
482 sheets/Jackson/Makefile
483 sheets/KAOS/Makefile
484 sheets/UML/Makefile
485 plug-ins/Makefile
486 plug-ins/cgm/Makefile
487 plug-ins/cairo/Makefile
488 plug-ins/dxf/Makefile
489 plug-ins/gprint/Makefile
490 plug-ins/hpgl/Makefile
491 plug-ins/metapost/Makefile
492 plug-ins/pixbuf/Makefile
493 plug-ins/pstricks/Makefile
494 plug-ins/python/Makefile
495 plug-ins/shape/Makefile
496 plug-ins/svg/Makefile
497 plug-ins/wmf/Makefile
498 plug-ins/wpg/Makefile
499 plug-ins/xfig/Makefile
500 plug-ins/xslt/Makefile
501 doc/Makefile
502 doc/en/Makefile
503 doc/pl/Makefile
506 dnl GTK2: simplify this, we will have much less options.
507 echo "
509 Configuration:
510         Source code location:   ${srcdir}
511         Compiler:               ${CC}
513         Gnome support:                          ${GNOME}
514         Python support:                         ${with_python}
515         Libart support (PNG export):            ${have_libart}
516         Cairo support (experimental):           ${have_cairo}
517         Gnome Print support (experimental):     ${have_gnomeprint}
520 echo "Now type make to build dia..."