fixed dia_image_rgb_data() for non-alpha images
[dia.git] / configure.in
blob6764bdcf98bc6a0992b1e12de2ca76fc7d5390a5
1 dnl Process this -*- autoconf -*- file with autoconf to produce a 
2 dnl configure script.
3 AC_INIT(dia, 0.90+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.176 $)
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 
16 dnl Initialize maintainer mode
17 AM_MAINTAINER_MODE
19 dnl Initialize libtool
20 AC_DISABLE_STATIC
21 AC_PROG_LIBTOOL
23 dnl Build time sanity check
24 AM_SANITY_CHECK
26 dnl Checks for programs.
27 dnl AC_PROG_CC # already done 
28 AC_PROG_INSTALL
29 AC_PROG_LN_S
30 AC_PROG_MAKE_SET
31 AC_ISC_POSIX
33 dnl Checks for header files.
34 AC_HEADER_DIRENT
35 AC_HEADER_STDC
36 AC_CHECK_HEADERS(stddef.h fcntl.h unistd.h utime.h)
38 dnl Checks for typedefs, structures, and compiler characteristics.
39 AC_C_CONST
41 dnl Checks for library functions.
42 AC_CHECK_FUNCS(select strcspn strdup strtol snprintf)
44 dnl stuff for intltool
45 AC_PROG_INTLTOOL(0.21) 
47 APP_LIBS=""
48 AC_SUBST(APP_LIBS)
51 dnl Checks for libraries
53 AM_PATH_GLIB_2_0(2.0.0)
54 AM_PATH_GTK_2_0(2.0.0)
56 GTK_MODULES="gtk+-2.0 libxml-2.0 gdk-pixbuf-2.0"
57 PKG_CHECK_MODULES(PANGOFT2,pangoft2,have_pangoft2=true,have_pangoft2=false)
58 if test "$have_pangoft2" = "true"; then
59   dnl On Solaris with Forte C, at least, need to link app/dia with -lfreetype.
60   dnl It's not enough that -lpangoft2 implicitly pulls it in.
61   have_freetype=false
62   AC_CHECK_LIB(freetype,FT_Init_FreeType,have_freetype=true)
63   if test "$have_freetype" = "true"; then
64     dnl Need 2.0.9, as a bug was fixed for us there.
65     dnl However, freetype-config doesn't give a meaningful version, so we must
66     dnl do it like this.
67     AC_MSG_CHECKING([for version of FreeType])
68     FREETYPE_INCLUDE=`freetype-config --cflags | cut -c3-`
69     FREETYPE_MAJOR=`grep '^#define FREETYPE_MAJOR' $FREETYPE_INCLUDE/freetype/freetype.h | cut -d' ' -f3`
70     FREETYPE_MINOR=`grep '^#define FREETYPE_MINOR' $FREETYPE_INCLUDE/freetype/freetype.h | cut -d' ' -f3`
71     FREETYPE_PATCH=`grep '^#define FREETYPE_PATCH' $FREETYPE_INCLUDE/freetype/freetype.h | cut -d' ' -f3`
72     FREETYPE_VERSION=`echo | awk "BEGIN { printf \"%d\", ($FREETYPE_MAJOR * 1000 + $FREETYPE_MINOR) * 1000 + $FREETYPE_PATCH;}"`
73     AC_MSG_RESULT([$FREETYPE_MAJOR.$FREETYPE_MINOR.$FREETYPE_PATCH])
74     if test "$FREETYPE_VERSION" -ge 2000009; then
75         FREETYPE_LIBS=-lfreetype
76         AC_SUBST(FREETYPE_LIBS)
77         GTK_MODULES="$GTK_MODULES pangoft2"
78         AC_DEFINE(HAVE_FREETYPE,1,[Define if you have the FreeType2 library])
79     else
80         AC_MSG_ERROR([Need FreeType library version 2.0.9 or higher, found $FREETYPE_MAJOR.$FREETYPE_MINOR.$FREETYPE_PATCH])
81     fi
82   else
83    AC_MSG_ERROR(Can't find FreeType library)
84   fi
85 else
86    AC_MSG_ERROR(Can't find PangoFT2 library)
89 dnl Try for libart
90 PKG_CHECK_MODULES(LIBART,libart-2.0,have_libart=yes,have_libart=no)
91 if test "$have_libart" = "yes" ; then
92    GTK_MODULES="$GTK_MODULES libart-2.0"
93    AC_DEFINE(HAVE_LIBART,1,[Define if building with LIBART support])
96 AC_MSG_CHECKING([whether GNOME specific code should be used])
97 AC_ARG_ENABLE(gnome,[  --enable-gnome          enable gnome code],
98               GNOME=$enableval, GNOME=no)
99 if test "$GNOME" = "yes" ; then
100     GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0"
101     AC_DEFINE(GNOME,1,[Define if building with GNOME support])
102     AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [GNOME icon directory])
103     have_gnome=true
104 else
105     have_gnome=false
107 AM_CONDITIONAL(HAVE_GNOME, $have_gnome)
108 AC_MSG_RESULT($GNOME)
110 dnl GTK2:     libgnomecanvas-2.0 ?
112 PKG_CHECK_MODULES(GTK,$GTK_MODULES)
113 AM_CONDITIONAL(HAVE_BONOBO,false)
115 dnl XSLT
117 XSLT_DIR=""
118 PKG_CHECK_MODULES(XSLT, libxslt, have_xslt=true, have_xslt=false)
119 AM_CONDITIONAL(HAVE_XSLT, $have_xslt)
120 if test "$have_xslt" = "true"; then
121   XSLT_DIR="xslt"
123 AC_SUBST(XSLT_DIR)
126 dnl Popt
129 AC_CHECK_LIB(popt, poptSetOtherOptionHelp, [
130                 AC_DEFINE(HAVE_LIBPOPT,,[popt library available])
131                    POPT_LIBS="-lpopt"])
132 AC_CHECK_HEADERS(popt.h)
133 AC_SUBST(POPT_LIBS)
134 APP_LIBS="$APP_LIBS $POPT_LIBS"
137 dnl libpng
139 dnl this likely already comes from GTK
140 png_ok=no
141 AC_CHECK_HEADER(png.h, png_ok=yes, png_ok=no)
142 AC_CHECK_LIB(png, png_read_info, ,png_ok=no, -lz -lm)
143 if test "$png_ok" = yes; then
144   AC_MSG_CHECKING([for png_structp in png.h])
145   AC_TRY_COMPILE([#include <png.h>],
146                  [png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
147                  png_ok=yes,
148                  png_ok=no)
149   AC_MSG_RESULT($png_ok)
150   if test "$png_ok" = yes; then
151     PNG_LIBS='-lpng -lz -lm'
152     AC_DEFINE(HAVE_LIBPNG,,[PNG library available])
153   fi
155 AC_SUBST(PNG_LIBS)
156 LIBS="${LIBS} ${PNG_LIBS}"
159 dnl Debugging
161 AC_ARG_ENABLE(debug, 
162 [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],
163   ,
164   enable_debug=minimum)
166 if test "x$enable_debug" = "xyes"; then
167   DEBUG_FLAGS="-g -DENABLE_DEBUG"
168 else
169   if test "x$enable_debug" = "xno"; then
170     DEBUG_FLAGS=""
171   else
172     DEBUG_FLAGS=""
173   fi
175 AC_SUBST(DEBUG_FLAGS)
178 dnl i18n
181 GETTEXT_PACKAGE=dia
182 AC_SUBST(GETTEXT_PACKAGE)
183 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Needed for glib gettext])
184 ALL_LINGUAS="az ca cs da de el en_GB es fi fr ga hu it ja ko nl nn no pl pt pt_BR ro ru sk sl sv tr uk vi zh_CN zh_TW"
185 AM_GLIB_GNU_GETTEXT
187 localedir='${prefix}/${DATADIRNAME}/locale'
188 AC_SUBST(localedir)
191 dnl Locate the gnome-xml library
193 dnl GTK2: remove support for libxml1. move check for libxml2 in 
194 dnl AM_PATH_GTK_2_0's fourth argument (module is libxml-2.0)
196 found_libxml=false
197 if test $found_libxml = false; then
198   AC_CHECK_PROG(XML2_CONFIG, xml2-config, xml2-config)
199   if test "x$XML2_CONFIG" != x ; then
200     AC_MSG_CHECKING(for libxml >= 2.3.9)
201     vers=`$XML2_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
203     if test "$vers" -ge 2003009; then
204       AC_MSG_RESULT(found)
205       found_libxml=true
206       XML_LIBS="`$XML2_CONFIG --libs`"
207       XML_CFLAGS="`$XML2_CONFIG --cflags`"
209       if test "$enable_gnome_print" = "yes"
210       then
211           gnome-config --cflags print | \
212           grep gnome-xml 2>&1 >/dev/null && \
213           AC_MSG_ERROR(libxml2 found but gnome-print uses libxml1 ; this is a conflict.\nPlease do either provide libxml1 or disable gnome-print.)
214       fi
215       echo $GNOME_CFLAGS | \
216       grep gnome-xml 2>&1 >/dev/null && \
217       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.)
218         
219     else
220       AC_MSG_RESULT(not found)
221     fi
222   fi
225 if test $found_libxml = false; then
226 AC_CHECK_PROG(XML_CONFIG, xml-config, xml-config)
227 if test "x$XML_CONFIG" != x ; then
228   AC_MSG_CHECKING(for libxml >= 1.8.14)
229   vers=`$XML_CONFIG --version | sed -e "s/libxml //" | awk 'BEGIN {FS=".";} { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
231   dnl 1.18.14 is required for xmlUseNewParser()    
232   if test "$vers" -ge 1008014; then
233     AC_MSG_RESULT(found)
234     found_libxml=true
235     XML_LIBS="`$XML_CONFIG --libs`"
236     XML_CFLAGS="`$XML_CONFIG --cflags`"
237   else
238     AC_MSG_RESULT(not found)
239   fi
243 if test $found_libxml = false; then
244     AC_MSG_ERROR(Neither libxml1 or libxml2 found. You must install one (libxml1, preferably))
247 AC_SUBST(XML_LIBS)
248 AC_SUBST(XML_CFLAGS)
250 CFLAGS="$XML_CFLAGS $CFLAGS"
252 dnl LibZ
253 AC_CHECK_HEADERS(zlib.h,
254     AC_CHECK_LIB(z, gzread,[
255         AC_DEFINE(HAVE_LIBZ,, we have the libz compression library)
256         if test "x${Z_DIR}" != "x"; then
257             Z_CFLAGS="-I${Z_DIR}/include"
258             Z_LIBS="-L${Z_DIR}/lib -lz"
259         else
260             Z_LIBS="-lz"
261         fi]))
263 AC_SUBST(Z_LIBS)
265 CFLAGS="${CFLAGS} ${Z_CFLAGS}"
266 LIBS="${LIBS} ${Z_LIBS}"
268 dnl Platform-specific fixes.
269 dnl 
271 dnl Sun Forte C provides isinf() in the unbundled -lsunmath. Solaris
272 dnl declares finite() in ieeefp.h. It's preferrable not to link 
273 dnl to -lsunmath as it's not present on all machines.
274 have_isinf=no
275 AC_CHECK_HEADERS(math.h,
276         AC_CHECK_LIB(m,isinf,
277                 have_isinf=yes))
279 if test "$have_isinf" = "no"; then
280         AC_CHECK_HEADERS(ieeefp.h,
281                 AC_CHECK_FUNC(finite, ,
282                         AC_MSG_ERROR(Can't find a definition of neither 
283                                      finite nor isinf)),
284                 AC_MSG_ERROR(Can't find a definition of neither finite 
285                              nor isinf))
286 else
287         AC_DEFINE([HAVE_ISINF], 1, 
288                   [Define if the isinf() function is available])
291 dnl Alpha needs -mieee or we get a segfault
292 dnl This shouldn't be needed but is here until a real solution is found
293 case "$host" in
294   alpha*-*-linux*)
295     CFLAGS="$CFLAGS -mieee"
296     ;;
297 esac
299 if test "$GCC" = yes; then
300   dnl Relieve register pressure on i386. Other architectures may become unable
301   dnl to debug, and usually have more registers anyway.
302   dnl case "$host" in 
303   dnl  i?86-pc-*)
304   dnl    DIA_CHECK_CFLAG(-fomit-frame-pointer)
305   dnl    ;;
306   dnl esac
307   dnl (it looks like gdb is very confused by this now even on x86. We might be
308   dnl getting poor stack traces with bug-buddy because of this)
310   DIA_CHECK_CFLAG(-Wall)
311   DIA_CHECK_CFLAG(-Wunused)
312   DIA_CHECK_CFLAG(-Winline)
313   DIA_CHECK_CFLAG(-Wmissing-prototypes)
314   DIA_CHECK_CFLAG(-Wmissing-declarations)
315   DIA_CHECK_CFLAG(-finline-functions)
316   DIA_CHECK_CFLAG(-fstrict-aliasing)
319 AM_CONDITIONAL(HAVE_GCC, test "$GCC" = yes)
321 dnl Do we have the db2html script to build the documentation?
322 AC_ARG_ENABLE(db2html,
323 [  --enable-db2html        don't rebuild documentation],,enable_db2html=no)
324 AC_PATH_PROG(DB2HTML, db2html, no)
325 AM_CONDITIONAL(HAVE_DB2HTML, 
326                test "x$enable_db2html" != xno && test "x$DB2HTML" != xno)
328 dnl Handling for Python
329 AC_ARG_WITH(python,
330 [  --with-python           compile python plug-in],,with_python=no)
332 if test "x$with_python" != xno; then
333   AM_PATH_PYTHON(1.5.2)
334   AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(could not find pygtk module)])
335   AM_CHECK_PYTHON_HEADERS
336   AM_CHECK_PYTHON_LIB
338   if test -z "$PYTHON_INCLUDES" || test -z "$PYTHON_LIBS"; then
339     AC_MSG_ERROR([could not find files required to build python plugin])
340   fi
342 AM_CONDITIONAL(WITH_PYTHON, test "x$with_python" != "xno")
344 AC_OUTPUT(
345 Makefile
346 lib/Makefile
347 po/Makefile.in
348 objects/Makefile
349 dnl objects/sybase/Makefile
350 objects/bondgraph/Makefile
351 objects/chronogram/Makefile
352 objects/custom/Makefile
353 objects/ER/Makefile
354 objects/flowchart/Makefile
355 objects/FS/Makefile
356 objects/GRAFCET/Makefile
357 objects/Misc/Makefile
358 objects/network/Makefile
359 objects/SADT/Makefile
360 objects/standard/Makefile
361 objects/UML/Makefile
362 shapes/Makefile
363 shapes/Assorted/Makefile
364 shapes/Circuit/Makefile
365 shapes/Cisco/Makefile
366 shapes/Civil/Makefile
367 shapes/Contact/Makefile
368 shapes/Electric/Makefile
369 shapes/flowchart/Makefile
370 shapes/jigsaw/Makefile
371 shapes/Logic/Makefile
372 shapes/Misc/Makefile
373 shapes/MSE/Makefile
374 shapes/network/Makefile
375 shapes/Pneumatic/Makefile
376 shapes/SDL/Makefile
377 shapes/sybase/Makefile
378 app/Makefile
379 samples/Makefile
380 sheets/Makefile
381 sheets/ER/Makefile
382 sheets/GRAFCET/Makefile
383 sheets/UML/Makefile
384 plug-ins/Makefile
385 plug-ins/cgm/Makefile
386 plug-ins/dxf/Makefile
387 plug-ins/hpgl/Makefile
388 plug-ins/metapost/Makefile
389 plug-ins/pstricks/Makefile
390 plug-ins/python/Makefile
391 plug-ins/shape/Makefile
392 plug-ins/svg/Makefile
393 plug-ins/wmf/Makefile
394 plug-ins/wpg/Makefile
395 plug-ins/xfig/Makefile
396 plug-ins/xslt/Makefile
397 doc/Makefile
398 doc/en/Makefile
399 doc/pl/Makefile
402 dnl GTK2: simplify this, we will have much less options.
403 echo "
405 Configuration:
406         Source code location:   ${srcdir}
407         Compiler:               ${CC}
409         Gnome support:                          ${GNOME}
410         Python support:                         ${with_python}
411         Libart support (PNG export):            ${have_libart}
414 echo "Now type make to build dia..."