#ifdef'd xmlerror.h
[dia.git] / configure.in
blobae7ff74ad42ee75282f542cda84a3490b4805f9d
1 dnl Process this -*- m4 -*- file with autoconf to produce a configure script.
2 AC_INIT(app/diagram.c)
4 dnl AC_PREREQ(2.50)
5 dnl AC_REVISION($Revision: 1.147 $)
7 AM_INIT_AUTOMAKE(dia, 0.90.RC1)
9 dnl Specify a header configuration file
10 AM_CONFIG_HEADER(config.h)
12 dnl do this check now, to keep autogen quiet.
13 AC_PROG_CC 
15 dnl Initialize maintainer mode
16 AM_MAINTAINER_MODE
18 dnl Initialize libtool
19 AC_DISABLE_STATIC
20 AC_PROG_LIBTOOL
22 dnl Build time sanity check
23 AM_SANITY_CHECK
25 dnl Checks for programs.
26 dnl AC_PROG_CC # already done 
27 AC_PROG_INSTALL
28 AC_PROG_LN_S
29 AC_PROG_MAKE_SET
30 AC_ISC_POSIX
32 dnl stuff for xml-i18n-tools
33 AC_PROG_INTLTOOL(0.12) 
35 dnl Checks for libraries.
36 dnl AM_PATH_GLIB(1.2.9) dnl (for g_critical)
37 AM_PATH_GTK(1.2.0)
39 dnl XIM support (on by default)
40 AC_ARG_ENABLE(xim,
41 [  --disable-xim           enable gnome code],,enable_xim=yes)
42 AC_MSG_CHECKING([whether to enable XIM support])
43 if test "x$enable_xim" != xno; then
44   AC_DEFINE(USE_XIM)
46 AC_MSG_RESULT($enable_xim)
48 APP_LIBS=""
49 AC_SUBST(APP_LIBS)
51 dnl
52 dnl GNOME
53 dnl
55 AC_MSG_CHECKING([whether GNOME specific code should be used])
56 AC_ARG_ENABLE(gnome,
57 [  --enable-gnome          enable gnome code],
58     GNOME=$enableval,
59     GNOME=no)
60 AC_ARG_ENABLE(gnome-print,
61 [  --enable-gnome-print    enable gnome-print support],,enable_gnome_print=no)
62 AC_ARG_ENABLE(bonobo,
63 [  --enable-bonobo         enable bonobo support],,enable_bonobo=no)
64 AC_MSG_RESULT($GNOME)
65 GNOME_CFLAGS=""
66 GNOME_LIBS=""
67 BONOBO_LIBS=""
68 bonobo_msg=no
69 have_gnome=false
70 have_bonobo=false
71 if test "$GNOME" = "yes"; then
72   AC_DEFINE(GNOME)
73   have_gnome=true
74   components="gnomeui"
75   hcomponents=""
76   if test "$enable_gnome_print" = "yes"; then
77     AC_DEFINE(GNOME_PRINT)
78     components="$components print"
79   fi
80   if test "$enable_bonobo" = "yes"; then
82     AC_MSG_CHECKING(for Bonobo >= 0.31)
84     if gnome-config --libs bonobox_print > /dev/null 2>&1; then
85       vers=`gnome-config --modversion bonobo | sed -e "s/bonobo-//" | \
86         awk 'BEGIN { FS = "."; } { printf "%d", $1 * 1000 + $2;}'`
87       if test "$vers" -ge 31; then
88         bonobo_ok=true
89       else
90         bonobo_ok=false
91       fi
92     else
93       bonobo_ok=false
94     fi
95         
96     if $bonobo_ok; then
97       AC_MSG_RESULT([found ("$vers")])
98       have_bonobo=true
99       bonobo_msg=yes
100     else
101       AC_MSG_RESULT([not found])
102     fi
104     hcomponents="$hcomponents bonobox_print"
105     BONOBO_LIBS=`gnome-config bonobox_print $components --libs`
106   fi
107   GNOME_CFLAGS=`gnome-config $hcomponents $components --cflags`
108   GNOME_LIBS=`gnome-config $components --libs`
110 AM_CONDITIONAL(HAVE_GNOME, $have_gnome)
111 AM_CONDITIONAL(HAVE_GNOME_PRINT,
112         $have_gnome && test "$enable_gnome_print" = "yes")
113 AM_CONDITIONAL(HAVE_BONOBO, $have_bonobo)
115 AC_SUBST(GNOME_CFLAGS)
116 AC_SUBST(GNOME_LIBS)
117 AC_SUBST(BONOBO_LIBS)
119 dnl Check if this Gnome has Bonobo
120 OLDCPPFLAGS=$CPPFLAGS
121 CPPFLAGS="$CPPFLAGS `glib-config --cflags`"
123 dnl This is required to play character set games
124 AM_LANGINFO_CODESET
125 AM_ICONV
127 dnl check for libunicode 
128 UNICODE_CFLAGS=
129 UNICODE_LIBS=
130 have_unicode=false
131 yn_have_unicode=no
133   AC_MSG_CHECKING(for libunicode)
134   if unicode-config --libs > /dev/null 2>&1; then
135     vers=`unicode-config --version`
136     have_unicode=true     
137     yn_have_unicode=yes        
138     UNICODE_CFLAGS=`unicode-config --cflags`
139     UNICODE_LIBS=`unicode-config --libs`
140     AC_DEFINE(HAVE_UNICODE,, Unicode support library available)
141     AC_MSG_RESULT([found, version $vers])
142   else
143     AC_MSG_RESULT([not found])
144   fi
145 AC_SUBST(UNICODE_CFLAGS)
146 AC_SUBST(UNICODE_LIBS)
147 AM_CONDITIONAL(HAVE_UNICODE,$have_unicode)
149 CPPFLAGS=$OLDCPPFLAGS
151 dnl check for libfreetype
152 AC_ARG_ENABLE(freetype, 
153 [  --enable-freetype       enable (LIMITED, EXPERIMENTAL) freetype support],,
154         freetype=yes)
155 FREETYPE_CFLAGS=
156 FREETYPE_LIBS=
157 have_freetype=false
158 yn_have_freetype=no
160 if test "$enable_freetype" = "yes"; then
161   AC_CHECK_FT2(2.0.5,
162     [have_freetype=true
163      FREETYPE_CFLAGS=$FT2_CFLAGS
164      FREETYPE_LIBS=$FT2_LIBS
165      AC_DEFINE(HAVE_FREETYPE,, Freetype support library available)
166      yn_have_freetype=yes])
168 AC_SUBST(FREETYPE_CFLAGS)
169 AC_SUBST(FREETYPE_LIBS)
170 AM_CONDITIONAL(HAVE_FREETYPE,$have_freetype)
172 CPPFLAGS=$OLDCPPFLAGS
175 dnl Popt
178 AC_CHECK_LIB(popt, poptSetOtherOptionHelp, [AC_DEFINE(HAVE_LIBPOPT)
179                    APP_LIBS="$APP_LIBS -lpopt"])
180 AC_CHECK_HEADERS(popt.h)
182 dnl libart_lgpl
185 AM_PATH_LIBART(2.1.0,dnl
186  [have_libart=yes
187   AC_DEFINE(HAVE_LIBART)],
188  [have_libart=no])
191 dnl gdk_pixbuf
194 AM_PATH_GDK_PIXBUF(0.7.0,,AC_MSG_ERROR([gdk-pixbuf >= 0.7.0 is required]))
197 dnl libpng
200 png_ok=no
201 AC_CHECK_HEADER(png.h, png_ok=yes, png_ok=no)
202 AC_CHECK_LIB(png, png_read_info, ,png_ok=no, -lz -lm)
203 if test "$png_ok" = yes; then
204   AC_MSG_CHECKING([for png_structp in png.h])
205   AC_TRY_COMPILE([#include <png.h>],
206                  [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
207                  png_ok=yes,
208                  png_ok=no)
209   AC_MSG_RESULT($png_ok)
210   if test "$png_ok" = yes; then
211     PNG_LIBS='-lpng -lz -lm'
212     AC_DEFINE(HAVE_LIBPNG)
213   fi
215 AC_SUBST(PNG_LIBS)
219 dnl Debugging
222 AC_ARG_ENABLE(debug, 
223 [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],
224   ,
225   enable_debug=minimum)
227 if test "x$enable_debug" = "xyes"; then
228   DEBUG_FLAGS="-g -DENABLE_DEBUG"
229 else
230   if test "x$enable_debug" = "xno"; then
231     DEBUG_FLAGS=""
232   else
233     DEBUG_FLAGS=""
234   fi
236 AC_SUBST(DEBUG_FLAGS)
239 dnl i18n
242 ALL_LINGUAS="az ca da de el en_GB es fi fr ga hu it ja ko nl nn no pl pt pt_BR ru sk sl sv tr uk vi zh_CN zh_TW"
244 AM_GNU_GETTEXT
246 localedir='${prefix}/${DATADIRNAME}/locale'
247 AC_SUBST(localedir)
249 dnl     
250 dnl Locate the gnome-xml library
253 found_libxml=false
254 AC_CHECK_PROG(XML_CONFIG, xml-config, xml-config)
255 if test "x$XML_CONFIG" != x ; then
256   AC_MSG_CHECKING(for libxml >= 1.8.14)
257   vers=`$XML_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
259   dnl 1.18.14 is required for xmlUseNewParser()    
260   if test "$vers" -ge 1008014; then
261     AC_MSG_RESULT(found)
262     found_libxml=true
263     XML_LIBS="`$XML_CONFIG --libs`"
264     XML_CFLAGS="`$XML_CONFIG --cflags`"
265   else
266     AC_MSG_RESULT(not found)
267   fi
270 if ! $found_libxml; then
271   AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config)
272   if test "x$XML2_CONFIG" != x ; then
273     AC_MSG_CHECKING(for libxml >= 2.3.9)
274     vers=`$XML2_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
276     if test "$vers" -ge 2003009; then
277       AC_MSG_RESULT(found)
278       found_libxml=true
279       XML_LIBS="`$XML2_CONFIG --libs`"
280       XML_CFLAGS="`$XML2_CONFIG --cflags`"
282       if test "$enable_gnome_print" = "yes"
283       then
284           gnome-config --cflags print | \
285           grep gnome-xml 2>&1 >/dev/null && \
286           AC_MSG_ERROR(libxml2 found but gnome-print uses libxml1 ; this is a conflict.\nPlease do either provide libxml1 or disable gnome-print.)
287       fi
288       echo $GNOME_CFLAGS | \
289       grep gnome-xml 2>&1 >/dev/null && \
290       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.)
291         
292     else
293       AC_MSG_RESULT(not found)
294     fi
295   fi
298 if ! $found_libxml; then
299     AC_MSG_ERROR(Neither libxml1 or libxml2 found. You must install one (libxml1, preferably))
302 AC_SUBST(XML_LIBS)
303 AC_SUBST(XML_CFLAGS)
305 CFLAGS="$XML_CFLAGS $CFLAGS"
307 dnl LibZ
309 AC_CHECK_HEADERS(zlib.h,
310     AC_CHECK_LIB(z, gzread,[
311         AC_DEFINE(HAVE_LIBZ,, we have the libz compression library)
312         if test "x${Z_DIR}" != "x"; then
313             Z_CFLAGS="-I${Z_DIR}/include"
314             Z_LIBS="-L${Z_DIR}/lib -lz"
315         else
316             Z_LIBS="-lz"
317         fi]))
318 CFLAGS="${CPPFLAGS} ${Z_CFLAGS}"
319 LIBS="${LIBS} ${Z_LIBS}"
321 dnl Checks for header files.
322 AC_HEADER_DIRENT
323 AC_HEADER_STDC
324 AC_CHECK_HEADERS(stddef.h fcntl.h unistd.h utime.h)
326 dnl Checks for typedefs, structures, and compiler characteristics.
327 AC_C_CONST
329 dnl Checks for library functions.
330 AC_CHECK_FUNCS(select strcspn strdup strtol snprintf)
332 dnl Set some variables we'll need for the UTF-8 transition.
333 gtk_advancement=dia_talks_utf8
335 if test "$gtk_advancement" = "initial"; then
336    AC_DEFINE(GTK_DOESNT_SPEAK_UTF8_NEITHER_DO_WE,,
337           We haven't begun the transition yet)
338 elif test "$gtk_advancement" = "dia_talks_utf8"; then
339    AC_DEFINE(UNICODE_WORK_IN_PROGRESS,,Cyrille's work towards UTF-8)
340    AC_DEFINE(GTK_DOESNT_TALK_UTF8_WE_DO,,...)
341    AC_DEFINE(GTK_CHARSET_MISMATCH,,     
342              Mismatch between the charset dia uses and the charset GTK uses)
343 elif test "$gtk_advancement" = "dia_under_win32"; then
344    dnl please check this with Hans. I believe this is true -- CC
345    AC_DEFINE(GTK_TALKS_UTF8,,...)
346    AC_DEFINE(GTK_TALKS_UTF8_WE_DONT,,...)
347    AC_DEFINE(GTK_CHARSET_MISMATCH,,     
348              Mismatch between the charset dia uses and the charset GTK uses)
349 elif test "$gtk_advancement" = "gtk2"; then
350    AC_DEFINE(GTK_TALKS_UTF8,,...)
351    AC_DEFINE(UNICODE_WORK_IN_PROGRESS,,Cyrille's work towards UTF-8)
352    dnl the latter shouldn't appear anymore by then (manually compiled)
355 dnl Solaris provides isinf() in -lsunmath and defines finite() in math.h
356   AC_CHECK_HEADERS(ieeefp.h sunmath.h)
357   AC_CHECK_LIB(sunmath,isinf)
359 dnl Alpha needs -mieee or we get a segfault
360 dnl This shouldn't be needed but is here until a real solution is found
361 case "$host" in
362   alpha*-*-linux*)
363     CFLAGS="$CFLAGS -mieee"
364     ;;
365 esac
367 DIA_CHECK_CFLAG(-Wall)
368 DIA_CHECK_CFLAG(-Wunused)
369 DIA_CHECK_CFLAG(-Winline)
370 DIA_CHECK_CFLAG(-Wmissing-prototypes)
371 DIA_CHECK_CFLAG(-Wmissing-declarations)
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(-finline-functions)
384 DIA_CHECK_CFLAG(-fstrict-aliasing)
386 dnl Do we have the db2html script to build the documentation?
387 AC_ARG_ENABLE(db2html,
388 [  --enable-db2html        don't rebuild documentation],,enable_db2html=no)
389 AC_PATH_PROG(DB2HTML, db2html, no)
390 AM_CONDITIONAL(HAVE_DB2HTML, test "x$enable_db2html" != xno && test "x$DB2HTML" != xno)
392 dnl Handling for Python
393 AC_ARG_WITH(python,
394 [  --with-python           compile python plug-in],,with_python=no)
396 #hello
397 if test "x$with_python" != xno; then
398   AM_PATH_PYTHON(1.5.2)
399   AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(could not find pygtk module)])
400   AM_CHECK_PYTHON_HEADERS
401   AM_CHECK_PYTHON_LIB
403   if test -z "$PYTHON_INCLUDES" || test -z "$PYTHON_LIBS"; then
404     AC_MSG_ERROR([could not find files required to build python plugin])
405   fi
407 AM_CONDITIONAL(WITH_PYTHON, test "x$with_python" != "xno")
409 AC_OUTPUT(
410 Makefile
411 lib/Makefile
412  po/Makefile.in intl/Makefile
413 objects/Makefile
414 objects/standard/Makefile
415 objects/network/Makefile
416 objects/UML/Makefile
417 objects/ER/Makefile
418 objects/FS/Makefile
419 dnl objects/sybase/Makefile
420 objects/flowchart/Makefile
421 objects/custom/Makefile
422 objects/GRAFCET/Makefile
423 objects/chronogram/Makefile
424 objects/SADT/Makefile
425 shapes/Makefile
426 shapes/Circuit/Makefile
427 shapes/flowchart/Makefile
428 shapes/Contact/Makefile
429 shapes/network/Makefile
430 shapes/Pneumatic/Makefile
431 shapes/Electric/Makefile
432 shapes/Civil/Makefile
433 shapes/jigsaw/Makefile
434 shapes/MSE/Makefile
435 shapes/SDL/Makefile
436 shapes/Logic/Makefile
437 shapes/sybase/Makefile
438 shapes/Misc/Makefile
439 app/Makefile
440 samples/Makefile
441 sheets/Makefile
442 sheets/UML/Makefile
443 sheets/ER/Makefile
444 sheets/GRAFCET/Makefile
445 plug-ins/Makefile
446 plug-ins/cgm/Makefile
447 plug-ins/pstricks/Makefile
448 plug-ins/dxf/Makefile
449 plug-ins/hpgl/Makefile
450 plug-ins/wpg/Makefile
451 plug-ins/wmf/Makefile
452 plug-ins/metapost/Makefile
453 plug-ins/svg/Makefile
454 plug-ins/shape/Makefile
455 plug-ins/xfig/Makefile
456 plug-ins/python/Makefile
457 doc/Makefile
458 doc/en/Makefile
461 echo "
463 Configuration:
464         Source code location:   ${srcdir}
465         Compiler:               ${CC}
467         Libart (AA rendering, png export):      ${have_libart}
469         Gnome support:                          ${GNOME}
470         Build bonobo component (not supported): ${bonobo_msg}
471         Gnome-print support (not recommended):  ${enable_gnome_print}
473         Python support:                         ${with_python}
474         (LIMITED) Freetype support:             ${yn_have_freetype}
476 if test "$yn_have_unicode" != "yes" ; then
477   echo "Unicode not present. This will NOT build."
480 echo "Now type make to build dia."