* lib/libdia.def: added color_new_rgb(), focus_previous(),focus_next(),
[dia.git] / configure.in
blob74c9debc7ad76b06996c6483b14f5462d85b0b9a
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.241 $)
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 AM_PATH_GTK_2_0(2.0.0)
58 GTK_MODULES="gtk+-2.0 libxml-2.0 gdk-pixbuf-2.0"
59 PKG_CHECK_MODULES(PANGOVERSION, pango >= 1.1.5, , 
60                   AC_MSG_ERROR([Need Pango version 1.1.5 or higher]))
61 PKG_CHECK_MODULES(PANGOFT2,pangoft2,have_pangoft2=true,have_pangoft2=false)
62 if test "$have_pangoft2" = "true"; then
63   dnl On Solaris with Forte C, at least, need to link app/dia with -lfreetype.
64   dnl It's not enough that -lpangoft2 implicitly pulls it in.
65   have_freetype=false
66   AC_CHECK_LIB(freetype,FT_Init_FreeType,have_freetype=true,have_freetype=false,`freetype-config --libs`)
67   if test "$have_freetype" = "true"; then
68     dnl Need 2.0.9, as a bug was fixed for us there.
69     dnl However, freetype-config doesn't give a meaningful version, so we must
70     dnl do it like this.
71     AC_MSG_CHECKING([if FreeType version is 2.0.9 or higher])
72     old_CPPFLAGS="$CPPFLAGS"
73     CPPFLAGS="$CPPFLAGS `freetype-config --cflags`"
74     AC_TRY_CPP([#include <ft2build.h>
75 #include FT_FREETYPE_H
76 #if (FREETYPE_MAJOR*1000+FREETYPE_MINOR)*1000+FREETYPE_PATCH < 2000009
77 #error Freetype version too low.
78 #endif
80         [AC_MSG_RESULT(yes)
81          FREETYPE_LIBS=`freetype-config --libs`
82          AC_SUBST(FREETYPE_LIBS)
83          FREETYPE_CFLAGS=`freetype-config --cflags`
84          AC_SUBST(FREETYPE_CFLAGS)
85          GTK_MODULES="$GTK_MODULES pangoft2"
86          AC_DEFINE(HAVE_FREETYPE,1,[Define if you have the FreeType2 library])]
87     ,
88         [AC_MSG_ERROR([Need FreeType library version 2.0.9 or higher])])
89     CPPFLAGS="$old_CPPFLAGS"
90   else
91    AC_MSG_ERROR(Can't find FreeType library)
92   fi
93 else
94    AC_MSG_ERROR(Can't find PangoFT2 library)
97 CFLAGS="$FREETYPE_CFLAGS $CFLAGS"
99 dnl Try for libart
100 PKG_CHECK_MODULES(LIBART,libart-2.0,have_libart=yes,have_libart=no)
101 if test "$have_libart" = "yes" ; then
102    GTK_MODULES="$GTK_MODULES libart-2.0"
103    AC_DEFINE(HAVE_LIBART,1,[Define if building with LIBART support])
106 AC_MSG_CHECKING([whether GNOME specific code should be used])
107 AC_ARG_ENABLE(gnome,[  --enable-gnome          enable gnome code],
108               GNOME=$enableval, GNOME=no)
109 if test "$GNOME" = "yes" ; then
110     GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0"
111     AC_DEFINE(GNOME,1,[Define if building with GNOME support])
112     AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [GNOME icon directory])
113     have_gnome=true
114 else
115     have_gnome=false
117 AM_CONDITIONAL(HAVE_GNOME, $have_gnome)
118 AC_MSG_RESULT($GNOME)
120 dnl GTK2:     libgnomecanvas-2.0 ?
122 PKG_CHECK_MODULES(GTK,$GTK_MODULES)
123 AM_CONDITIONAL(HAVE_BONOBO,false)
125 dnl Look for Cairo
126 AC_ARG_WITH(cairo,
127 [  --with-cairo           compile cairo plug-in],,with_cairo=no)
128 if test "x$with_cairo" != "xno"; then
129   PKG_CHECK_MODULES(CAIRO, cairo,have_cairo=yes,have_cairo=no)
130   AC_SUBST(CAIRO_LIBS)
131   AC_SUBST(CAIRO_CFLAGS)
132   AC_DEFINE(HAVE_CAIRO,1,[Define if building with Cairo support])
134 AM_CONDITIONAL(WITH_CAIRO, test "x$with_cairo" != "xno")
136 dnl XSLT
138 # Check if XSLT is available at all
139 XSLT_DIR=""
140 PKG_CHECK_MODULES(XSLT, libxslt, have_xslt=true, have_xslt=false)
141 AM_CONDITIONAL(HAVE_XSLT, $have_xslt)
142 if test "$have_xslt" = "true"; then
143   XSLT_DIR="xslt"
144   XSLT_LIBS="`$PKG_CONFIG --libs libxslt`"
145   XSLT_CFLAGS="`$PKG_CONFIG --cflags libxslt`"
148 AC_SUBST(XSLT_DIR)
149 AC_SUBST(XSLT_LIBS)
150 AC_SUBST(XSLT_CFLAGS)
152 # Figure out a prefix for where to find libxslt at runtime.
153 AC_ARG_WITH(xslt-prefix, 
154             [  --with-xslt-prefix=DIR     Specify where to find the optional XSLT libraries
155                              (default=/usr/lib)], 
156             libxslt_prefix=$withval,
157             libxslt_prefix=/usr/lib)
158 AC_DEFINE_UNQUOTED(LIBXSLT_PREFIX,"$libxslt_prefix", [Place to look for XSLT libs])
161 dnl Popt
164 AC_CHECK_LIB(popt, poptSetOtherOptionHelp, [
165                 AC_DEFINE(HAVE_LIBPOPT,,[popt library available])
166                    POPT_LIBS="-lpopt"])
167 AC_CHECK_HEADERS(popt.h)
168 AC_SUBST(POPT_LIBS)
169 APP_LIBS="$APP_LIBS $POPT_LIBS"
172 dnl libpng
174 dnl this likely already comes from GTK
176 dnl Something in here pollutes $LIBS with -lpng.  Make sure to
177 dnl avoid that.
179 old_LIBS="${LIBS}"
181 png_ok=no
182 AC_CHECK_HEADER(png.h, png_ok=yes, png_ok=no)
183 AC_CHECK_LIB(png, png_read_info, ,png_ok=no, -lz -lm)
184 if test "$png_ok" = yes; then
185   AC_MSG_CHECKING([for png_structp in png.h])
186   dnl Why can't AC_LINK_IFELSE take extra libs?
187   old_LDFLAGS="${LDFLAGS}"
188   LDFLAGS="${LDFLAGS} -lz -lm"
189   AC_LINK_IFELSE([#include <png.h>
190                   png_structp pp;
191                   png_infop info; 
192                   png_colorp cmap; 
193                   main() { void*foo = png_create_read_struct; }],
194                  png_ok=yes,
195                  png_ok=no)
196   LDFLAGS="${old_LDFLAGS}"
197   AC_MSG_RESULT($png_ok)
198   if test "$png_ok" = yes; then
199     PNG_LIBS='-lpng -lz -lm'
200     AC_DEFINE(HAVE_LIBPNG,,[PNG library available])
201   fi
203 AC_SUBST(PNG_LIBS)
205 LIBS="${old_LIBS} ${PNG_LIBS}"
208 dnl Debugging
210 AC_ARG_ENABLE(debug, 
211 [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],
212   ,
213   enable_debug=minimum)
215 if test "x$enable_debug" = "xyes"; then
216   DEBUG_FLAGS="-g -DENABLE_DEBUG"
217 else
218   if test "x$enable_debug" = "xno"; then
219     DEBUG_FLAGS=""
220   else
221     DEBUG_FLAGS=""
222   fi
224 AC_SUBST(DEBUG_FLAGS)
227 dnl i18n
230 GETTEXT_PACKAGE=dia
231 AC_SUBST(GETTEXT_PACKAGE)
232 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Needed for glib gettext])
233 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"
234 AM_GLIB_GNU_GETTEXT
236 dnl INTLOBJS doesn't seem to always get subst'ed, but I believe it's
237 dnl idempotent
238 AC_SUBST(INTLOBJS)
240 localedir='${prefix}/${DATADIRNAME}/locale'
241 AC_SUBST(localedir)
244 dnl Locate the gnome-xml library
246 dnl GTK2: remove support for libxml1. move check for libxml2 in 
247 dnl AM_PATH_GTK_2_0's fourth argument (module is libxml-2.0)
249 found_libxml=false
250 if test $found_libxml = false; then
251   AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config)
252   if test "x$XML2_CONFIG" != x ; then
253     AC_MSG_CHECKING(for libxml >= 2.3.9)
254     vers=`$XML2_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
256     if test "$vers" -ge 2003009; then
257       AC_MSG_RESULT(found)
258       found_libxml=true
259       XML_LIBS="`$XML2_CONFIG --libs`"
260       XML_CFLAGS="`$XML2_CONFIG --cflags`"
262       if test "$enable_gnome_print" = "yes"
263       then
264           gnome-config --cflags print | \
265           grep gnome-xml 2>&1 >/dev/null && \
266           AC_MSG_ERROR(libxml2 found but gnome-print uses libxml1 ; this is a conflict.\nPlease do either provide libxml1 or disable gnome-print.)
267       fi
268       echo $GNOME_CFLAGS | \
269       grep gnome-xml 2>&1 >/dev/null && \
270       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.)
271         
272     else
273       AC_MSG_RESULT(not found)
274     fi
275   fi
278 if test $found_libxml = false; then
279 AC_CHECK_PROG(XML_CONFIG, xml-config, xml-config)
280 if test "x$XML_CONFIG" != x ; then
281   AC_MSG_CHECKING(for libxml >= 1.8.14)
282   vers=`$XML_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
284   dnl 1.18.14 is required for xmlUseNewParser()    
285   if test "$vers" -ge 1008014; then
286     AC_MSG_RESULT(found)
287     found_libxml=true
288     XML_LIBS="`$XML_CONFIG --libs`"
289     XML_CFLAGS="`$XML_CONFIG --cflags`"
290   else
291     AC_MSG_RESULT(not found)
292   fi
296 if test $found_libxml = false; then
297     AC_MSG_ERROR(Neither libxml1 or libxml2 found. You must install one (libxml1, preferably))
300 AC_SUBST(XML_LIBS)
301 AC_SUBST(XML_CFLAGS)
303 CFLAGS="$XML_CFLAGS $CFLAGS"
305 dnl LibZ
306 AC_CHECK_HEADERS(zlib.h,
307     AC_CHECK_LIB(z, gzread,[
308         AC_DEFINE(HAVE_LIBZ,, we have the libz compression library)
309         if test "x${Z_DIR}" != "x"; then
310             Z_CFLAGS="-I${Z_DIR}/include"
311             Z_LIBS="-L${Z_DIR}/lib -lz"
312         else
313             Z_LIBS="-lz"
314         fi]))
316 AC_SUBST(Z_LIBS)
318 CFLAGS="${CFLAGS} ${Z_CFLAGS}"
319 LIBS="${LIBS} ${Z_LIBS}"
321 dnl Platform-specific fixes.
322 dnl 
324 dnl Sun Forte C provides isinf() in the unbundled -lsunmath. Solaris
325 dnl declares finite() in ieeefp.h. It's preferrable not to link 
326 dnl to -lsunmath as it's not present on all machines.
327 have_isinf=no
328 AC_CHECK_HEADERS(math.h,
329         AC_CHECK_LIB(m,isinf,
330                 have_isinf=yes))
332 if test "$have_isinf" = "no"; then
333     AC_CHECK_HEADER(ieeefp.h,
334              [AC_CHECK_FUNC(finite, 
335                        AC_DEFINE(HAVE_IEEEFP_H,1,
336                                  [Define if finite() is defined in ieeefp.h]),
337                        AC_MSG_ERROR([Can't find a definition of neither 
338                                      finite nor isinf]))],
339              [AC_MSG_ERROR(Can't find neither a definition of
340                            isinf nor ieeefp.h)])
341 else
342     AC_DEFINE([HAVE_ISINF], 1, 
343               [Define if the isinf() function is available])
346 dnl Alpha needs -mieee or we get a segfault
347 dnl This shouldn't be needed but is here until a real solution is found
348 case "$host" in
349   alpha*-*-linux*)
350     CFLAGS="$CFLAGS -mieee"
351     ;;
352 esac
354 if test "$GCC" = yes; then
355   dnl Relieve register pressure on i386. Other architectures may become unable
356   dnl to debug, and usually have more registers anyway.
357   dnl case "$host" in 
358   dnl  i?86-pc-*)
359   dnl    DIA_CHECK_CFLAG(-fomit-frame-pointer)
360   dnl    ;;
361   dnl esac
362   dnl (it looks like gdb is very confused by this now even on x86. We might be
363   dnl getting poor stack traces with bug-buddy because of this)
365   DIA_CHECK_CFLAG(-Wall)
366   DIA_CHECK_CFLAG(-Wunused)
367   dnl Premature optimization is the root of all evil.  Uncomment this if
368   dnl you want ti figure out functions that should have been inlined but aint.
369   dnl DIA_CHECK_CFLAG(-Winline)
370   DIA_CHECK_CFLAG(-Wmissing-prototypes)
371   DIA_CHECK_CFLAG(-Wmissing-declarations)
372   DIA_CHECK_CFLAG(-finline-functions)
373   DIA_CHECK_CFLAG(-fstrict-aliasing)
376 AM_CONDITIONAL(HAVE_GCC, test "$GCC" = yes)
378 dnl Do we have the db2html script to build the documentation?
379 AC_ARG_ENABLE(db2html,
380 [  --enable-db2html        don't rebuild documentation],,enable_db2html=no)
381 AC_PATH_PROG(DB2HTML, db2html, no)
382 AM_CONDITIONAL(HAVE_DB2HTML, 
383                test "x$enable_db2html" != xno && test "x$DB2HTML" != xno)
385 dnl Only enable man page generation if we have db2man (in maintainer mode)
387 dnl Have to have the nwalsh docbook.xsl, which does manpages.
388 dnl RedHat installs it in a version-numbered place.  Grumpf.
389 db2man_file=
390 for file in \
391   /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl \
392   /usr/share/sgml/docbook/xsl-stylesheets-\*/manpages/docbook.xsl; do
393   if test -f $file; then db2man_file=$file; break; fi
394 done
395 AM_CONDITIONAL(HAVE_DB2MAN, test "x$db2man_file" != x)
396 AC_SUBST(DB2MAN, "$db2man_file")
398 dnl Handling for Python
399 AC_ARG_WITH(python,
400 [  --with-python           compile python plug-in],,with_python=no)
402 if test "x$with_python" != xno; then
403   AM_PATH_PYTHON(1.5.2)
404   AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(could not find pygtk module)])
405   AM_CHECK_PYTHON_HEADERS
406   AM_CHECK_PYTHON_LIB
408   if test -z "$PYTHON_INCLUDES" || test -z "$PYTHON_LIBS"; then
409     AC_MSG_ERROR([could not find files required to build python plugin])
410   fi
412 AM_CONDITIONAL(WITH_PYTHON, test "x$with_python" != "xno")
414 AC_OUTPUT(
415 Makefile
416 lib/Makefile
417 lib/pixmaps/Makefile
418 po/Makefile.in
419 objects/Makefile
420 dnl objects/sybase/Makefile
421 objects/bondgraph/Makefile
422 objects/chronogram/Makefile
423 objects/custom/Makefile
424 objects/ER/Makefile
425 objects/flowchart/Makefile
426 objects/FS/Makefile
427 objects/GRAFCET/Makefile
428 objects/Istar/Makefile
429 objects/Jackson/Makefile
430 objects/KAOS/Makefile
431 objects/Misc/Makefile
432 objects/network/Makefile
433 objects/SADT/Makefile
434 objects/standard/Makefile
435 objects/UML/Makefile
436 shapes/Makefile
437 shapes/Assorted/Makefile
438 shapes/ChemEng/Makefile
439 shapes/Circuit/Makefile
440 shapes/Cisco/Makefile
441 shapes/Civil/Makefile
442 shapes/Contact/Makefile
443 shapes/Cybernetics/Makefile
444 shapes/Electric/Makefile
445 shapes/flowchart/Makefile
446 shapes/jigsaw/Makefile
447 shapes/Logic/Makefile
448 shapes/Map/Makefile
449 shapes/Map/Isometric/Makefile
450 shapes/Misc/Makefile
451 shapes/MSE/Makefile
452 shapes/network/Makefile
453 shapes/Pneumatic/Makefile
454 shapes/RDP/Makefile
455 shapes/SDL/Makefile
456 shapes/sybase/Makefile
457 app/Makefile
458 app/pixmaps/Makefile
459 samples/Makefile
460 sheets/Makefile
461 sheets/ER/Makefile
462 sheets/GRAFCET/Makefile
463 sheets/Istar/Makefile
464 sheets/Jackson/Makefile
465 sheets/KAOS/Makefile
466 sheets/UML/Makefile
467 plug-ins/Makefile
468 plug-ins/cgm/Makefile
469 plug-ins/cairo/Makefile
470 plug-ins/dxf/Makefile
471 plug-ins/hpgl/Makefile
472 plug-ins/metapost/Makefile
473 plug-ins/pixbuf/Makefile
474 plug-ins/pstricks/Makefile
475 plug-ins/python/Makefile
476 plug-ins/shape/Makefile
477 plug-ins/svg/Makefile
478 plug-ins/wmf/Makefile
479 plug-ins/wpg/Makefile
480 plug-ins/xfig/Makefile
481 plug-ins/xslt/Makefile
482 doc/Makefile
483 doc/en/Makefile
484 doc/pl/Makefile
487 dnl GTK2: simplify this, we will have much less options.
488 echo "
490 Configuration:
491         Source code location:   ${srcdir}
492         Compiler:               ${CC}
494         Gnome support:                          ${GNOME}
495         Python support:                         ${with_python}
496         Libart support (PNG export):            ${have_libart}
497         Cairo support (experimental):           ${have_cairo}
500 echo "Now type make to build dia..."