"Initial commit to Gerrit"
[profile/ivi/libgsf.git] / configure.in
1 -*- mode: m4 -*-
2 dnl We require Automake 1.7.1, which requires Autoconf 2.54.
3 AC_PREREQ(2.54)
4
5 m4_define([libgsf_version_major], [1])
6 m4_define([libgsf_version_minor], [14])
7 m4_define([libgsf_version_micro], [21])
8 m4_define([libgsf_version_extra], [])
9 m4_define([libgsf_full_version],
10     [libgsf_version_major.libgsf_version_minor.libgsf_version_micro[]libgsf_version_extra])
11
12 AC_INIT(libgsf, [libgsf_full_version],
13         [http://bugzilla.gnome.org/enter_bug.cgi?product=libgsf])
14 AC_CONFIG_SRCDIR(gsf/gsf.h)
15 AC_CONFIG_MACRO_DIR([m4])
16 AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS -I m4")
17
18 AC_SUBST(LIBGSF_MAJOR_VERSION, libgsf_version_major)
19 AC_SUBST(LIBGSF_MINOR_VERSION, libgsf_version_minor)
20 AC_SUBST(LIBGSF_MICRO_VERSION, libgsf_version_micro)
21
22 dnl Version info for libraries = CURRENT:REVISION:AGE
23 dnl
24 dnl Within each x.y.*, ABI is maintained backward compatible.
25 dnl We strive for forward compatibility too, except that we sometimes
26 dnl add new functions.
27 dnl
28 m4_define([version_iface],
29         m4_eval(100 * libgsf_version_major + libgsf_version_minor))
30
31 AC_SUBST([VERSION_INFO], [version_iface:libgsf_version_micro:0])
32 AC_SUBST([CURRENT_MINUS_AGE], m4_eval(version_iface - 0))
33
34 AM_INIT_AUTOMAKE(dist-bzip2)
35
36 AC_CONFIG_HEADERS(gsf-config.h)
37 AM_MAINTAINER_MODE
38
39 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
40
41 dnl Propagate Gnome-specific variable ACLOCAL_FLAGS to Makefile.
42 AC_SUBST(ACLOCAL_AMFLAGS, $ACLOCAL_FLAGS)
43
44 dnl Checks for programs.
45 AC_PROG_CC
46 AC_PROG_MAKE_SET
47 AC_LIBTOOL_WIN32_DLL
48 AM_PROG_LIBTOOL
49
50 AC_FUNC_FSEEKO
51 AC_SYS_LARGEFILE
52 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
53
54 dnl Gettext/i18n stuff
55
56 IT_PROG_INTLTOOL([0.35.0])
57
58 AM_GLIB_GNU_GETTEXT
59
60 GETTEXT_PACKAGE=AC_PACKAGE_NAME
61 AC_SUBST(GETTEXT_PACKAGE)
62 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
63
64 dnl Checks for libraries.
65 ifelse([
66   If we defined the module lists on the M4 level, we could have problems
67   with PKG_CHECK_MODULES from pkgconfig 0.16.0, which double quotes its
68   second argument (the module list).
69   As a handy workaround, we use shell variables.
70 ])
71 dnl Modules common to libgsf and libgsf-gnome
72 common_reqs="
73     gobject-2.0 >= 2.6.0
74     glib-2.0 >= 2.8.0
75 "
76 dnl Modules required for libgsf
77 libgsf_reqs="
78     $common_reqs
79     libxml-2.0 >= 2.4.16
80 "
81 dnl Modules required for libgsf-gnome
82 libgsf_gnome_reqs="
83     $common_reqs
84 "
85 PKG_CHECK_MODULES(LIBGSF, $libgsf_reqs)
86
87 ## this should come after `AC_PROG_CC'
88 ifdef([GNOME_COMPILE_WARNINGS],[GNOME_COMPILE_WARNINGS],)
89 CFLAGS="$CFLAGS $WARN_CFLAGS -DG_DISABLE_DEPRECATED"
90 if test "$GCC" = "yes"; then
91         for option in -Wno-system-headers -Wfloat-equal -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Wnested-externs -Winline -Wdeclaration-after-statement -Wundef -W -Wmissing-noreturn -Wmissing-format-attribute -Wno-pointer-sign \
92         -Wbitwise -Wcast-to-as -Wdefault-bitfield-sign -Wdo-while -Wparen-string -Wptr-subtraction-blows -Wreturn-void -Wtypesign ; do
93                 SAVE_CFLAGS="$CFLAGS"
94                 CFLAGS="$CFLAGS $option"
95                 AC_MSG_CHECKING([whether gcc understands $option])
96                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
97                         has_option=yes,
98                         has_option=no)
99                 if test $has_option = no; then
100                   CFLAGS="$SAVE_CFLAGS"
101                 fi
102                 AC_MSG_RESULT($has_option)
103                 unset has_option
104                 unset SAVE_CFLAGS
105         done
106         unset option
107 fi
108
109 AC_CHECK_DECL(fdopen, fdopen_works=yes, fdopen_works=no)
110 if test $fdopen_works = no ; then
111         unset ac_cv_have_decl_fdopen
112         CFLAGS="$CFLAGS -D_POSIX_SOURCE"
113         AC_MSG_NOTICE([adding -D_POSIX_SOURCE to CFLAGS])
114         AC_CHECK_DECL(fdopen, fdopen_works=yes, fdopen_works=no)
115         if test $fdopen_works = no ; then
116                 AC_MSG_ERROR([fdopen is not available])
117         fi
118 fi
119
120 # Unfortunately, -D_POSIX_SOURCE turns off struct timeval on Solaris
121 AC_MSG_CHECKING([whether struct timeval is available])
122 for try in 1 2; do
123         AC_COMPILE_IFELSE(
124                 [AC_LANG_PROGRAM(
125                         [[#include <sys/time.h>]],
126                         [[struct timeval tv;]])],
127                 struct_timeval_works=yes,
128                 struct_timeval_works=no)
129         test $struct_timeval_works = yes && break
130         # Try this for the second attempt:
131         test $try = 1 && CFLAGS="$CFLAGS -D__EXTENSIONS__"
132 done
133 AC_MSG_RESULT($struct_timeval_works)
134 if test $struct_timeval_works = no ; then
135         AC_MSG_ERROR([struct timeval is not available])
136 fi
137
138 AC_MSG_CHECKING([whether -D_BSD_SOURCE is needed for caddr_t])
139 AC_COMPILE_IFELSE(
140         [AC_LANG_PROGRAM([[#include <sys/types.h>]], [[caddr_t ca]])],
141         need_bsd1=no,
142         need_bsd1=yes)
143 AC_MSG_RESULT($need_bsd1)
144
145 AC_MSG_CHECKING([whether -D_BSD_SOURCE is needed for lstat])
146 AC_LINK_IFELSE([AC_LANG_PROGRAM(
147 [[#include <sys/types.h>
148 #include <sys/stat.h>
149 #include <unistd.h>]],
150 [[void *ptr = &lstat]])],
151 need_bsd2=no, need_bsd2=yes)
152 AC_MSG_RESULT($need_bsd2)
153 if test $need_bsd1 = yes -o $need_bsd2 = yes; then
154         CFLAGS="$CFLAGS -D_BSD_SOURCE"
155 fi
156
157 AC_TYPE_MODE_T
158 AC_CHECK_HEADERS(fcntl.h malloc.h unistd.h io.h sys/statfs.h sys/param.h sys/mount.h)
159 AC_FUNC_MMAP
160
161 AC_MSG_CHECKING([form of statfs])
162 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
163 [[#ifdef HAVE_SYS_STATFS_H
164 #include <sys/statfs.h>
165 #endif
166 #ifdef HAVE_SYS_PARAM_H
167 #include <sys/param.h>
168 #endif
169 #ifdef HAVE_SYS_MOUNT_H
170 #include <sys/mount.h>
171 #endif]],
172 [[struct statfs buf; (void)(2*statfs("xyz",&buf));]])],
173         [AC_MSG_RESULT([2-arg, linux-style])
174 AC_DEFINE(HAVE_2ARG_STATFS, 1, [Define is you have two-argument statfs like linux])],
175         [AC_MSG_RESULT([none, or unknown])])
176
177 AC_CHECK_FUNCS(chown setrlimit)
178
179 AC_CHECK_FUNCS(gmtime_r, [],
180                [AC_CHECK_FUNCS(gmtime,
181                                [AC_MSG_WARN(*** Please note that gmtime_r() is missing and I will use gmtime() which is not thread safe ***)],
182                                [AC_MSG_ERROR([Neither gmtime_r or gmtime is available])])])
183
184 AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,,
185 [#include <time.h>])
186
187 SAVE_CFLAGS=$CFLAGS
188 SAVE_LIBS=$LIBS
189 CFLAGS="$CFLAGS $LIBGSF_CFLAGS"
190 LIBS="$LIBGSF_LIBS $LIBS"
191 AC_CHECK_FUNCS(g_base64_encode)
192 AC_MSG_CHECKING([for g_chmod])
193 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_chmod("/xxx",0777);]])],
194                [AC_DEFINE(HAVE_G_CHMOD, 1, [Define if g_chmod is available as macro or function])
195                 AC_MSG_RESULT(yes)],
196                [AC_MSG_RESULT(no)])
197 AC_MSG_CHECKING([for g_access])
198 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_access("/xxx",0777);]])],
199                [AC_DEFINE(HAVE_G_ACCESS, 1, [Define if g_access is available as macro or function])
200                 AC_MSG_RESULT(yes)],
201                [AC_MSG_RESULT(no)])
202 CFLAGS=$SAVE_CFLAGS
203 LIBS=$SAVE_LIBS
204
205 AC_MSG_CHECKING([whether macro S_ISREG is available])
206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
207 [[#include <sys/types.h>
208 #include <sys/stat.h>]],
209 [[S_ISREG(S_IFMT);]])],
210         [macro_s_isreg=yes],
211         [AH_TEMPLATE([S_ISREG], [Define S_ISREG if stat.h doesn't])
212          AC_DEFINE([S_ISREG(m)], [(((m) & S_IFMT) == S_IFREG)])
213          macro_s_isreg=no])
214 AC_MSG_RESULT($macro_s_isreg)
215
216 AC_MSG_CHECKING([for Win32 platform])
217 with_win32=no
218 case $host_os in
219   mingw* | pw32* | cygwin*)
220     with_win32=yes
221     AC_ARG_VAR(WINDRES, [The windres executable (used by win32 builds only).])
222     AC_CHECK_TOOL(WINDRES, windres)
223     AC_ARG_VAR(LIBEXE, [The lib.exe executable (used by win32 builds only).])
224     AC_CHECK_PROG(LIBEXE, lib.exe, yes, no)
225     ;;
226 esac
227 AC_MSG_RESULT($with_win32)
228 AM_CONDITIONAL(WITH_WIN32, test $with_win32 = yes)
229 AM_CONDITIONAL(HAVE_LIBEXE, test x$LIBEXE = xyes)
230 AM_CONDITIONAL(CROSS_COMPILING, test x"$cross_compiling" != "xno")
231
232 ##################################################
233 # Checks for gtk-doc and docbook-tools
234 ##################################################
235 gtk_doc_installed=true
236 #ifdef([GTK_DOC_CHECK],[GTK_DOC_CHECK([1.0])],[gtk_doc_installed=false])
237 # I would have liked to conditionalize this, but 
238 # that appears to break other things http://bugzilla.gnome.org/show_bug.cgi?id=156399
239 GTK_DOC_CHECK([1.0])
240 AM_CONDITIONAL(GTK_DOC_INSTALLED, $gtk_doc_installed)
241
242 dnl ***********************************************************************************
243 # Check for zlib.
244 _cppflags=$CPPFLAGS
245 _ldflags=$LDFLAGS
246
247 Z_DIR= Z_LIBS= Z_CPPFLAGS=
248
249 AC_ARG_WITH(zlib,
250         [[  --with-zlib=DIR       use libz in DIR]],
251         [case $withval in
252          yes|no) ;;
253          *)     Z_DIR=$withval
254                 CPPFLAGS="${CPPFLAGS} -I$withval/include"
255                 LDFLAGS="${LDFLAGS} -L$withval/lib"
256                 ;;
257          esac])
258
259 if test "x$with_zlib" != xno; then
260         with_zlib=no
261         AC_CHECK_HEADER(zlib.h, [AC_CHECK_LIB(z, gzread, [with_zlib=yes])])
262 fi
263 if test "$with_zlib" = no; then
264         AC_MSG_ERROR([*** zlib is required])
265 fi
266 if test "x$Z_DIR" != "x"; then
267         Z_CPPFLAGS="-I$Z_DIR/include"
268         case $host in
269         *-*-solaris*)   Z_LIBS="-L$Z_DIR/lib -R$Z_DIR/lib -lz" ;;
270         *)              Z_LIBS="-L$Z_DIR/lib -lz" ;;
271         esac
272 else
273         Z_LIBS="-lz"
274 fi
275 AC_SUBST(Z_CPPFLAGS)
276 AC_SUBST(Z_LIBS)
277
278 CPPFLAGS=${_cppflags}
279 LDFLAGS=${_ldflags}
280
281 dnl ***********************************************************************************
282
283 test_python=true
284 AC_ARG_WITH(python,
285         [--{with,without}-python   Build with the python support],
286         if test "x$withval" = xno; then
287                 test_python=false
288         fi
289 )
290
291 if test "x$test_python" = xtrue ; then
292     pygobject_msg=test
293     AM_PATH_PYTHON
294
295     AM_CHECK_PYTHON_HEADERS(,[pygobject_msg="NO.  Missing python headers"])
296
297     dnl check for pygtk
298     if test "$pygobject_msg" = test; then
299         PKG_CHECK_MODULES(PYGTK, pygobject-2.0 >= 2.10.0,
300                   [],
301                   [pygobject_msg="NO.  pygtk problem"])
302         AC_SUBST(PYGTK_CFLAGS)
303     fi
304     if test "$pygobject_msg" = test; then
305         AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no)
306         if test "$PYGTK_CODEGEN" = no; then
307             pygobject_msg="NO.  Missing pygtk-codegen-2.0"
308         fi
309     fi
310
311     if test "$pygobject_msg" = test; then
312         pygobject_msg=yes
313     fi
314     AC_MSG_RESULT($pygobject_msg)
315 else
316     pygobject_msg=no
317 fi
318
319 AM_CONDITIONAL(WITH_PYTHON, [test "$pygobject_msg" = yes])
320
321 dnl ***********************************************************************************
322
323 dnl bz2
324 dnl
325 BZ2_LIBS=
326 test_bz2=true
327 AC_ARG_WITH(bz2,
328         [--{with,without}-bz2   Build additional wrappers for BZ2],
329         if test "x$withval" = xno; then
330                 test_bz2=false
331         fi
332 )
333
334 with_bz2=false
335 if test "x$test_bz2" = xtrue ; then
336    AC_MSG_CHECKING([usable libbz2])
337
338    dnl AC_CHECK_LIB doesn't work with the Windows port of libbz2 because
339    dnl it uses the __stdcall calling convention where the callee cleans
340    dnl up the stack.  You have to include <bzlib.h> in order to get the
341    dnl right calling convention, and the link fails if not.  Since we
342    dnl require both -lbz2 and <bzlib.h>, just test if a program which
343    dnl uses both can be compiled.
344
345    old_LIBS="$LIBS"
346    LIBS="-lbz2 $LIBS"
347    AC_LINK_IFELSE(
348      [AC_LANG_SOURCE(
349         [[#include <stdio.h>
350           #undef PACKAGE
351           #undef VERSION
352           #undef HAVE_STDLIB_H
353           #include <bzlib.h>
354           main ()
355           {
356             return BZ2_bzDecompressInit (NULL, 0, 0);
357           }
358         ]])],
359      bz2_ok=yes,
360      bz2_ok=no)
361    LIBS="$old_LIBS"
362
363    if test "$bz2_ok" = yes; then
364         AC_DEFINE(HAVE_BZ2, 1, [Is bzip2 available and enabled])
365         BZ2_LIBS="-lbz2"
366         AC_MSG_RESULT($bz2_ok)
367    else
368         AC_MSG_WARN(*** BZ2 support disabled (BZ2 header or library not found) ***)
369    fi
370 else
371    AC_MSG_WARN([BZ2 support disabled, as requested (Use --with-bz2 to enable)])
372 fi
373
374 AC_SUBST(BZ2_LIBS)
375
376 dnl ****************************************************************************
377
378 dnl gio
379 dnl
380 want_gio=auto
381 AC_ARG_WITH(gio,
382         [--{with,without}-gio   Build additional wrappers for GIO],
383         [case $withval in
384         yes) want_gio=yes;;
385         no) want_gio=no;;
386         esac[]dnl
387 ])
388
389 have_gio=no
390 if test $want_gio = no ; then 
391     AC_MSG_WARN([GIO support disabled, as requested (Use --with-gio to enable)])
392 else
393     PKG_CHECK_MODULES(LIBGSF_GIO, gio-2.0,
394         [have_gio=yes],
395         [if test $want_gio = yes; then
396             AC_MSG_ERROR([GIO support requested, but not available.])
397          else
398             AC_MSG_WARN([GIO support disabled, unable to find required version of GIO])
399          fi])
400 fi
401 AM_CONDITIONAL(WITH_GIO, test $have_gio = yes)
402 want_gio=$have_gio
403
404 dnl ****************************************************************************
405
406 dnl gnome
407 dnl
408
409 want_gnome=no
410
411 want_gnome_vfs=auto
412 AC_ARG_WITH(gnome_vfs,
413         [--{with,without}-gnome-vfs   Build wrappers for GNOME-VFS],
414         [case $withval in
415         yes) want_gnome_vfs=yes;;
416         no) want_gnome_vfs=no;;
417         esac[]dnl
418 ])
419 if test $want_gnome_vfs = auto -a "$want_gio" = yes; then
420         want_gnome_vfs=yes
421 fi
422 GNOMEVFS_REQ=
423 if test $want_gnome_vfs = yes; then
424         if test "$want_gio" = yes; then
425                 CFLAGS="$CFLAGS -DLIBGSF_GNOMEVFS_VIA_GIO"
426         else
427                 GNOMEVFS_REQ="gnome-vfs-2.0 >= 2.2.0 gnome-vfs-module-2.0 >= 2.2.0"
428                 libgsf_gnome_reqs="$libgsf_gnome_reqs $GNOMEVFS_REQ"
429                 want_gnome=yes
430         fi
431 fi
432 AC_SUBST(GNOMEVFS_REQ)
433
434 want_bonobo=no
435 dnl check for bonobo
436 AC_ARG_WITH(bonobo,
437     AC_HELP_STRING([--without-bonobo],[disable the use of bonobo]),
438     [case "${withval}" in
439     yes) want_bonobo=yes ;;
440     no) want_bonobo=no ;;
441     *) AC_MSG_ERROR(bad value ${withval} for --with-bonobo) ;;
442     esac],
443     [want_bonobo=auto]) dnl Default value
444
445 BONOBO_REQ="libbonobo-2.0 >= 2.0.0"
446 have_bonobo=no
447 if test $want_bonobo = no ; then 
448     AC_MSG_WARN([Bonobo support disabled, as requested (Use --with-bonobo to enable)])
449 else
450     PKG_CHECK_MODULES(LIBGSF_BONOBO, $BONOBO_REQ,
451         [have_bonobo=yes],
452         [if test $want_bonobo = yes; then
453             AC_MSG_ERROR([Bonobo support requested, but not available.])
454          else
455             AC_MSG_WARN([Bonobo support disabled, unable to find required version])
456          fi])
457 fi
458
459 if test $have_bonobo = yes; then
460     libgsf_gnome_reqs="$libgsf_gnome_reqs $BONOBO_REQ"   
461     want_gnome=yes
462 else
463     BONOBO_REQ=
464 fi
465 AC_SUBST(BONOBO_REQ)
466
467 want_gdk_pixbuf=no
468 dnl check for gdk_pixbuf
469 AC_ARG_WITH(gdk_pixbuf,
470     AC_HELP_STRING([--without-gdk-pixbuf],[disable the use of gdk-pixbuf]),
471     [case "${withval}" in
472     yes) want_gdk_pixbuf=yes ;;
473     no) want_gdk_pixbuf=no ;;
474     *) AC_MSG_ERROR(bad value ${withval} for --with-gdk-pixbuf) ;;
475     esac],
476     [want_gdk_pixbuf=auto]) dnl Default value
477
478 if test $want_gdk_pixbuf = no ; then
479     AC_MSG_WARN([gdk-pixbuf support disabled, as requested (Use --with-gdk-pixbuf to enable)])
480 else
481     PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0,
482         [AC_DEFINE(HAVE_GDK_PIXBUF, 1, [Define if gdk-pixbuf is available])],
483         [if test $want_gdk_pixbuf = yes; then
484             AC_MSG_ERROR([gdk-pixbuf support requested, but not available.])
485          else
486             AC_MSG_WARN([gdk-pixbuf support disabled, unable to find required version])
487          fi])
488 fi
489
490 have_gnome=no
491 if test $want_gnome = no ; then 
492     AC_MSG_WARN([GNOME support disabled, as requested (Use --with-gnome-vfs and/or --with-bonobo to enable)])
493 else
494     PKG_CHECK_MODULES(LIBGSF_GNOME, $libgsf_gnome_reqs,
495         [have_gnome=yes],
496         [AC_MSG_ERROR([GNOME support requested, but not available.])])
497 fi
498 AM_CONDITIONAL(WITH_LIBGSF_GNOME, test $have_gnome = yes)
499 AM_CONDITIONAL(WITH_LIBGSF_GNOMEVFS, test $want_gnome_vfs = yes)
500 AM_CONDITIONAL(WITH_LIBGSF_BONOBO, test $have_bonobo = yes)
501
502 # ===================
503 # GConf configuration
504 AC_ARG_WITH([gconf],
505     AC_HELP_STRING([--without-gconf],[disable the use of gconf (default: auto)]),
506     [],
507     [with_gconf=auto])
508
509 AS_IF([test "$with_gconf" != "no"], [
510     PKG_CHECK_EXISTS([gconf-2.0 >= 2.24.0],[
511         AC_CHECK_PROG([GCONFTOOL], [gconftool-2], [gconftool-2], [no])
512         AS_IF([test "$GCONFTOOL" = "no"], [
513             AC_MSG_WARN([thumbnailer will not be built, unable to find gconftool-2])
514             have_gconf=no
515             ], [
516             have_gconf=yes
517             ])
518         ],[have_gconf=no])
519     ], [have_gconf=no])
520
521 AS_IF([test "$have_gconf" = "yes"], [], [
522     AS_IF([test "$with_gconf" = "yes"],
523         [AC_MSG_ERROR([gconf support requested, but not available.])])
524     ])
525
526 AM_GCONF_SOURCE_2
527 AM_CONDITIONAL(WITH_GCONF, test "$have_gconf" = "yes")
528
529 # ===================
530
531 LDFLAGS="-no-undefined $LDFLAGS"
532
533 AC_CONFIG_FILES([
534 Makefile
535 m4/Makefile
536 doc/Makefile
537 gsf/Makefile
538 gsf-gnome/Makefile
539 gsf-win32/Makefile
540 tests/Makefile
541 tools/Makefile
542 python/Makefile
543 thumbnailer/Makefile
544 po/Makefile.in
545 gsf/version.c
546 doc/version.xml
547 libgsf-1.pc
548 libgsf-1.spec
549 libgsf-gnome-1.pc
550 libgsf-gnome-1.spec
551 libgsf-win32-1.pc
552 libgsf-zip
553 ])
554 AC_OUTPUT
555
556 AC_MSG_RESULT([Configured $PACKAGE $VERSION])