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