'./configure' requirements made optional for various parts of projects.
[captive.git] / configure.in
1 # $Id$
2 # Source file to generate "./configure" to prepare package for compilation
3 # Copyright (C) 2002-2003 Jan Kratochvil <project-captive@jankratochvil.net>
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; exactly version 2 of June 1991 is required
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19 AC_INIT(src/libcaptive/Makefile-libcaptive.am)
20 dnl 2.53 for AM_GLIB_GNU_GETTEXT:
21 AC_PREREQ(2.53)
22 AM_INIT_AUTOMAKE(captive,0.9cvs)
23 AM_CONFIG_HEADER(config.h)
24 AM_MAINTAINER_MODE
25 dnl Call AC_PROG_CC before AC_ISC_POSIX.
26 AC_PROG_CC(gcc3 gcc-3.0 gcc cc)
27 AC_TRY_CPP([
28 #if __GNUC__ >= 3
29 #else
30 #error "GCC version 3.0+ required at least for ReactOS anonymous unions"
31 #endif
32 ],,[AC_MSG_ERROR([Captive requires GCC version 3.0+.])])
33 dnl Prevent "AC_TRY_COMPILE was called before AC_ISC_POSIX":
34 AC_ISC_POSIX
35 AC_SYS_LARGEFILE
36 AM_PROG_AS
37 AM_ENABLE_STATIC
38 AM_DISABLE_SHARED
39 AM_PROG_LIBTOOL
40
41 dnl gettext localization.
42 dnl Use simpler AM_GLIB_GNU_GETTEXT instead of AM_GNU_GETTEXT
43 dnl as we depend on glib and glib requires system installed gettext anyway.
44 dnl http://lists.gnome.org/archives/gtk-devel-list/2003-April/msg00066.html
45 dnl Special 'GETTEXT_PACKAGE' is required by glib gettext.
46 ALL_LINGUAS="cs"
47 GETTEXT_PACKAGE="$PACKAGE"
48 AC_SUBST(GETTEXT_PACKAGE)
49 AM_GLIB_GNU_GETTEXT
50
51 GTK_DOC_CHECK
52 dnl AM_CONDITIONAL needs to be here explicitely for doc/apiref/Makefile rebuild
53 AM_CONDITIONAL(ENABLE_GTK_DOC,[test x$enable_gtk_doc = xyes])
54 AM_CONDITIONAL(GTK_DOC_USE_LIBTOOL,[test -n "$LIBTOOL"])
55
56 dnl Do not discard 'CFLAGS' settings as they may have been passed us by rpmbuild(8)
57
58 dnl Define MAINTAINER_MODE in config.h.
59 if test "$USE_MAINTAINER_MODE" = "yes";then
60         AC_DEFINE(MAINTAINER_MODE,,[Turn even some software behaviour according to MAINTAINER_MODE.])
61         CFLAGS="$CFLAGS -ggdb3 -Wall -Wstrict-prototypes -Wsign-compare"  ## FIXME: fix all sources: -Wsign-compare
62         fi
63 dnl Some Makefiles use additional tests etc.
64 AM_CONDITIONAL(MAINTAINER_MODE,[test "$USE_MAINTAINER_MODE" = "yes"])
65
66
67 AC_ARG_ENABLE(sbin-mountdir,
68                 [  --enable-sbin-mountdir=DIR       mount(8) 'mount.captive' directory (def.=/sbin)],,
69                 [ enable_sbin_mountdir="/sbin" ])
70 AC_ARG_ENABLE(sbin-mount-fs,
71                 [  --enable-sbin-mount-fs=FS1:FS2   sbin-mount pre-installed symlinks (def.=ntfs:fastfat:cdfs:ext2fsd)],,
72                 [ enable_sbin_mount_fs="ntfs:fastfat:cdfs:ext2fsd" ])
73 AC_ARG_ENABLE(sandbox-setuid,
74                 [  --enable-sandbox-setuid=USER     non-privileged user  for captive-sandbox-server (def.=captive)],
75                 [ CAPTIVE_SANDBOX_SETUID="$enableval" ],[ CAPTIVE_SANDBOX_SETUID="captive" ])
76 AC_ARG_ENABLE(sandbox-setgid,
77                 [  --enable-sandbox-setgid=GROUP    non-privileged group for captive-sandbox-server (def.=captive)],
78                 [ CAPTIVE_SANDBOX_SETGID="$enableval" ],[ CAPTIVE_SANDBOX_SETGID="captive" ])
79 AC_ARG_ENABLE(sandbox-chroot,
80                 [  --enable-sandbox-chroot=DIR      root-owned directory for captive-sandbox-server (def.=/var/lib/captive)],
81                 [ CAPTIVE_SANDBOX_CHROOT="$enableval" ],[ CAPTIVE_SANDBOX_CHROOT="/var/lib/captive" ])
82 AC_ARG_ENABLE(bug-replay,
83                 [  --enable-bug-replay=no/yes/auto  compile debugging tool (def.=auto)],,enable_bug_replay=auto)
84 AC_ARG_ENABLE(lufs,
85                 [  --enable-lufs=no/yes/auto        compile LUFS filesystem module (def.=auto)],,enable_lufs=auto)
86 AC_ARG_ENABLE(install-pkg,
87                 [  --enable-install-pkg=no/yes/auto compile installation utils (def.=auto)],,enable_install_pkg=auto)
88
89
90 # AC_ARG_ENABLE(sbin-mountdir,[--enable-sbin-mountdir=DIR],,[enable_sbin_mountdir="/sbin"])
91 AM_CONDITIONAL(ENABLE_SBIN_MOUNT,[test "$enable_sbin_mount" != "no"])
92 AC_SUBST(enable_sbin_mountdir)
93
94 # AC_ARG_ENABLE(sbin-mount-fs,[--enable-sbin-mount-fs=FS1:FS2],,[enable_sbin_mount_fs="ntfs:fastfat:cdfs:ext2fsd"])
95 AC_SUBST(enable_sbin_mount_fs)
96
97 # AC_ARG_ENABLE(sandbox-setuid,[--enable-sandbox-setuid=USER],,[CAPTIVE_SANDBOX_SETUID="captive"])
98 AC_DEFINE_UNQUOTED(CAPTIVE_SANDBOX_SETUID,"$CAPTIVE_SANDBOX_SETUID",
99                 [non-privileged user  for captive-sandbox-server])
100
101 # AC_ARG_ENABLE(sandbox-setgid,[--enable-sandbox-setgid=GROUP],,[CAPTIVE_SANDBOX_SETGID="captive"])
102 AC_DEFINE_UNQUOTED(CAPTIVE_SANDBOX_SETGID,"$CAPTIVE_SANDBOX_SETGID",
103                 [non-privileged group for captive-sandbox-server])
104
105 # AC_ARG_ENABLE(sandbox-chroot,[--enable-sandbox-chroot=DIR],,[CAPTIVE_SANDBOX_CHROOT="/var/lib/captive"])
106 AC_DEFINE_UNQUOTED(CAPTIVE_SANDBOX_CHROOT,"$CAPTIVE_SANDBOX_CHROOT",
107                 [root-owned directory for captive-sandbox-server])
108 AC_SUBST(CAPTIVE_SANDBOX_CHROOT)
109
110
111 dnl Permit 'if NEVER' for Makefile.am-s; symbol 'FALSE' forbidden by automake
112 AM_CONDITIONAL(NEVER,false)
113
114 PERL=
115 AC_PATH_PROGS(PERL,perl5 perl)
116 if test '!' -f ./src/libcaptive/ke/exports.c -a -z "$PERL";then
117         AC_MSG_ERROR([perl(1) required as './src/libcaptive/ke/exports.c' is not found.])
118 fi
119 AM_CONDITIONAL(HAVE_PERL,test -n "$PERL")
120
121 dnl Separate 'acconfig.h' is no longer recommended by autoconf
122 AH_TOP([
123 #ifndef _CAPTIVE_CONFIG_H
124 #define _CAPTIVE_CONFIG_H 1
125 ])
126 AH_BOTTOM([
127 /* Do not place any stuff to AH_TOP as some of its includes
128  * would discard the effect of _FILE_OFFSET_BITS by AC_SYS_LARGEFILE.
129  */
130
131 #ifdef ENABLE_NLS
132 /* <libintl.h> is taken from "$(top_srcdir)/intl" if system doesn't provide intl */
133 #       include <libintl.h>
134 #ifdef LIBCAPTIVE
135 #       define _(String) dgettext (PACKAGE,String)
136 #else
137 #       define _(String) gettext (String)
138 #endif /* LIBCAPTIVE */
139 #       ifdef gettext_noop
140 #               define N_(String) gettext_noop (String)
141 #       else
142 #               define N_(String) (String)
143 #       endif
144 #else /* !ENABLE_NLS */
145 /* Stubs that do something close enough.  */
146 #       define textdomain(String) (String)
147 #       define gettext(String) (String)
148 #       define dgettext(Domain,Message) (Message)
149 #       define dcgettext(Domain,Message,Type) (Message)
150 #       define bindtextdomain(Domain,Directory) (Domain)
151 #       define _(String) (String)
152 #       define N_(String) (String)
153 #endif /* !ENABLE_NLS */
154
155 #include <glib/gtypes.h>        /* for 'gchar' */
156 #define G_LOG_DOMAIN ((const gchar *)"Captive")
157
158 /* Supplemental definitions not possible in this file. */
159 #ifdef LIBCAPTIVE
160 #include "captive/config2.h"
161 #endif
162
163 #endif /* !_CAPTIVE_CONFIG_H */
164 ])
165
166 AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([Captive requires glib-2.0 library.])],[gmodule gobject])
167 dnl Force glib for the whole package
168 CFLAGS="$CFLAGS $GLIB_CFLAGS"
169 LIBS="$LIBS $GLIB_LIBS"
170
171 dnl popt
172 AC_CHECK_LIB(popt,poptParseArgvString,[POPT_LIBS="-lpopt"],[AC_MSG_ERROR([Captive requires popt library.])])
173 AC_SUBST(POPT_LIBS)
174
175 AC_ARG_WITH(readline,[  --with-readline=[no/yes/auto]   clients with line editing (def.=auto)],,with_readline=auto)
176 AC_CHECK_HEADERS(readline/history.h)
177 dnl Check for libraries, if needed by configuration options.
178 if test "$with_readline" != "no"
179 then
180         if test -d "/usr/lib/termcap"
181         then
182                 READLINE_LDFLAGS="$READLINE_LDFLAGS -L/usr/lib/termcap"
183         fi
184         have_libreadline=false
185         need_failed=""
186         for need in "" termcap ncurses; do
187                 if test "x$need" != "x"
188                 then
189                         captive_save_LIBS="$LIBS"
190                         AC_CHECK_LIB($need,main,,
191                                 [ need_failed="$need_failed $need"
192                                 continue ]
193                                 )
194                         LIBS="$captive_save_LIBS"
195                         lneed="-l$need"
196                 else
197                         lneed=""
198                 fi
199                 dnl Prevent AC_CHECK_LIB() here as it would _cache_ the value ignoring
200                 dnl our ever-changing "additiona libraries" parameter
201                 captive_save_LIBS="$LIBS"
202                 LIBS="-lreadline $lneed $READLINE_LIBS"
203                 AC_TRY_LINK(,[ main() ],
204                         [ have_libreadline=true
205                         READLINE_LIBS="$LIBS" ])
206                 LIBS="$captive_save_LIBS"
207                 if $have_libreadline
208                 then
209                         break
210                 fi
211         done
212         if $have_libreadline
213         then
214                 AC_DEFINE(HAVE_LIBREADLINE,,[Use functions from libreadline?])
215                 AC_CHECK_LIB(readline,add_history,
216                         AC_DEFINE(HAVE_ADD_HISTORY,,[Use 'history' extension of libreadline?]),,
217                         $READLINE_LIBS)
218         else
219                 for need in $need_failed; do
220                         AC_MSG_WARN(captive recommends $need library as your readline library
221                         probably needs it.)
222                 done
223                 if test "$with_readline" = "yes"
224                 then
225                         AC_MSG_ERROR([captive did not find the requested readline library for its client line editing capability.])
226                 else
227                         AC_MSG_WARN([captive recommends readline library for its client line editing capability.])
228                 fi
229         fi
230 fi
231 AC_SUBST(READLINE_LIBS)
232 AC_SUBST(READLINE_LDFLAGS)
233
234 PKG_CHECK_MODULES(GNOME_VFS_MODULE,gnome-vfs-module-2.0)
235 AC_SUBST(GNOME_VFS_MODULE_CFLAGS)
236 AC_SUBST(GNOME_VFS_MODULE_LIBS)
237 PKG_CHECK_MODULES(GNOME_VFS,gnome-vfs-2.0)
238 AC_SUBST(GNOME_VFS_CFLAGS)
239 AC_SUBST(GNOME_VFS_LIBS)
240
241 # AC_ARG_ENABLE(bug-replay,[--enable-bug-replay=[no/yes/auto]],,enable_bug_replay=auto)
242 dnl Check for 2.5.9 for: http://bugzilla.gnome.org/show_bug.cgi?id=117702
243 dnl Check the version - impossible to reliably check the missing feature.
244 PKG_CHECK_MODULES(LIBXML,libxml-2.0 >= 2.5.9,[ have_libxml_buffering=true ],[
245         dnl Disable bug-replay(1) build if not met; --bug-pathname would be still OK.
246         PKG_CHECK_MODULES(LIBXML,libxml-2.0,[ have_libxml_buffering=false ])
247         ])
248 dnl We also condition 'HAVE_LIBXML_XMLREADER_H' by 'HAVE_LIBXML_BUFFERING'
249 dnl as we have no use for xmlreader without working libxml buffering of 2.5.9.
250 AM_CONDITIONAL(ENABLE_BUG_REPLAY,[$have_libxml_buffering && test x$enable_bug_replay != xno])
251 if $have_libxml_buffering;then
252         AC_DEFINE(HAVE_LIBXML_BUFFERING,,[libxml2 correctly reads textnodes by its xmlTextReader.])
253 else
254         if test x$enable_bug_replay = xyes;then
255                 AC_MSG_ERROR([captive require libxml2 at least 2.5.9 for --enable-bug-replay feature.])
256         elif test x$enable_bug_replay != no;then
257                 AC_MSG_WARN([libxml2 at least 2.5.9 required --enable-bug-replay feature; disabled now.])
258         fi
259 fi
260 AC_SUBST(LIBXML_CFLAGS)
261 AC_SUBST(LIBXML_LIBS)
262
263 PKG_CHECK_MODULES(OPENSSL,openssl,,[
264         dnl At least Debian-3.0r1 has openssl but without its .pc module.
265         AC_CHECK_LIB(crypto,MD5,[
266                 OPENSSL_CFLAGS=""
267                 OPENSSL_LIBS="-lcrypto"
268                 ],[AC_MSG_ERROR([Captive requires crypto library (of openssl).])])
269         ])
270 AC_SUBST(OPENSSL_CFLAGS)
271 AC_SUBST(OPENSSL_LIBS)
272
273 # AC_ARG_ENABLE(lufs,[--enable-lufs=[no/yes/auto]],,enable_lufs=auto)
274 if test x$enable_lufs != no;then
275         have_lufs_includes=true
276         dnl If ACTION-IF-NOT-FOUND is given, it is executed when one of the header
277         dnl files is not found.
278         AC_CHECK_HEADERS(lufs/fs.h lufs/proto.h,,[ have_lufs_includes=false ])
279         AC_CHECK_TYPES([struct lufs_sbattr],,[
280                 dnl FIXME: Include 'lufs' version when 'lufs_sbattr' gets integrated:
281                 if $have_lufs_includes && test x$enable_lufs = xyes;then
282                         AC_MSG_ERROR([Although LUFS include files were found they are too old. You may also use --enable-lufs=auto.])
283                 else
284                         AC_MSG_WARN([Although LUFS include files were found they are too old. df(1) will not show available NTFS disk space.])
285                 fi
286                 ],[#include <lufs/proto.h>])
287 fi
288 AM_CONDITIONAL(ENABLE_LUFS,[ $have_lufs_includes && test x$enable_lufs != no ])
289
290 dnl for $(top_srcdir)/src/libcaptive/sandbox/split-sandbox.c
291 AM_PATH_LINC(,,[AC_MSG_ERROR([Captive requires linc library used by ORBit.])])
292
293 dnl for $(top_srcdir)/src/libcaptive/client/
294 dnl Do not use '[client server]' as $4 to prevent: configure: test: too many arguments
295 dnl  - currently this argument is not used by 'orbit2-config' in any way anyway
296 AM_PATH_ORBIT2(,,[AC_MSG_ERROR([Captive requires ORBit library.])])
297
298 # AC_ARG_ENABLE(install-pkg,[--enable-install-pkg=[no/yes/auto]],,enable_install_pkg=auto)
299 GLADE_W_INIT([
300         ./src/install/acquire/ui-gnome-interface.c
301         ./src/install/acquire/ui-gnome-interface.h
302         ./src/install/acquire/ui-gnome-callbacks.h
303         ./src/install/acquire/ui-gnome-support.c
304         ./src/install/acquire/ui-gnome-support.h
305         ],[$enable_install_pkg],[
306                 AC_CHECK_LIB(ntfs,ntfs_mount,[
307                         LIBNTFS_LIBS="-lntfs"
308                         glade_addon=yes
309                         ])
310                 ])
311 AC_SUBST(GNOMEUI_CFLAGS)
312 AC_SUBST(GNOMEUI_LIBS)
313 AC_SUBST(LIBNTFS_LIBS)
314 # Do not: AM_CONDITIONAL(HAVE_LIBNTFS,[ test -n "$LIBNTFS_LIBS" ])
315 # as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
316 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
317 # Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
318 # as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
319 GNOME_ADDON_LIBS=""
320 if test "x$BUILD_GLADESRC_TRUE" = "x"
321 then
322         AC_CHECK_LIB(Xi,XOpenDevice,GNOME_ADDON_LIBS="$GNOME_ADDON_LIBS -lXi")
323 fi
324 AC_SUBST(GNOME_ADDON_LIBS)
325 AM_CONDITIONAL(ENABLE_INSTALL_PKG,[ test "xyes" = "x$BUILD_GLADESRC" ])
326
327
328 AC_SUBST(CFLAGS)
329 AC_SUBST(LIBS)
330
331 dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified!
332 dnl FIXME: Why the rule above was written here?
333 AC_OUTPUT([
334 captive.spec
335 ./src/client/gnomevfs/captive.conf
336 ./src/client/lufs/mount.captive
337 ./po/Makefile.in
338 ./macros/glade-w.sh
339 Makefile
340 ./macros/Makefile
341 ./src/Makefile
342 ./src/libcaptive/Makefile
343 ./src/libcaptive/include/Makefile
344 ./src/libcaptive/include/captive/Makefile
345 ./src/libcaptive/include/reactos/Makefile
346 ./src/libcaptive/include/reactos/ddk/Makefile
347 ./src/libcaptive/include/reactos/ddk/i386/Makefile
348 ./src/libcaptive/include/reactos/internal/Makefile
349 ./src/libcaptive/include/reactos/internal/i386/Makefile
350 ./src/libcaptive/include/reactos/napi/Makefile
351 ./src/libcaptive/include/reactos/ntos/Makefile
352 ./src/libcaptive/reactos/Makefile
353 ./src/libcaptive/reactos/include/Makefile
354 ./src/libcaptive/reactos/hal/Makefile
355 ./src/libcaptive/reactos/hal/halx86/Makefile
356 ./src/libcaptive/reactos/ntoskrnl/Makefile
357 ./src/libcaptive/reactos/ntoskrnl/dbg/Makefile
358 ./src/libcaptive/reactos/ntoskrnl/ex/Makefile
359 ./src/libcaptive/reactos/ntoskrnl/fs/Makefile
360 ./src/libcaptive/reactos/ntoskrnl/io/Makefile
361 ./src/libcaptive/reactos/ntoskrnl/ke/Makefile
362 ./src/libcaptive/reactos/ntoskrnl/ldr/Makefile
363 ./src/libcaptive/reactos/ntoskrnl/mm/Makefile
364 ./src/libcaptive/reactos/ntoskrnl/nt/Makefile
365 ./src/libcaptive/reactos/ntoskrnl/ob/Makefile
366 ./src/libcaptive/reactos/ntoskrnl/ps/Makefile
367 ./src/libcaptive/reactos/ntoskrnl/rtl/Makefile
368 ./src/libcaptive/reactos/ntoskrnl/rtl/i386/Makefile
369 ./src/libcaptive/reactos/ntoskrnl/se/Makefile
370 ./src/libcaptive/halcaptive/Makefile
371 ./src/libcaptive/cc/Makefile
372 ./src/libcaptive/cm/Makefile
373 ./src/libcaptive/ex/Makefile
374 ./src/libcaptive/fs/Makefile
375 ./src/libcaptive/io/Makefile
376 ./src/libcaptive/kd/Makefile
377 ./src/libcaptive/ke/Makefile
378 ./src/libcaptive/ldr/Makefile
379 ./src/libcaptive/mm/Makefile
380 ./src/libcaptive/nt/Makefile
381 ./src/libcaptive/ob/Makefile
382 ./src/libcaptive/po/Makefile
383 ./src/libcaptive/ps/Makefile
384 ./src/libcaptive/rtl/Makefile
385 ./src/libcaptive/se/Makefile
386 ./src/libcaptive/storage/Makefile
387 ./src/libcaptive/sandbox/Makefile
388 ./src/libcaptive/client/Makefile
389 ./src/client/Makefile
390 ./src/client/bug-replay/Makefile
391 ./src/client/cmdline/Makefile
392 ./src/client/gnomevfs/Makefile
393 ./src/client/lufs/Makefile
394 ./src/client/sandbox-server/Makefile
395 ./src/install/Makefile
396 ./src/install/libcaptive-install/Makefile
397 ./src/install/fstab/Makefile
398 ./src/install/acquire/Makefile
399 ./src/TraceFS/Makefile
400 ./src/w32-mod/Makefile
401 ./doc/Makefile
402 ./doc/apiref/Makefile
403 ])
404
405 dnl FIXME: Why is "po/POTFILES" being substituted?
406 make -C src distfiles DISTFILES_PRINT=1 \
407                 |sed -n 's/^:DISTFILES: *\(.*\)$/\1/p'|tr ' ' '\n'|grep . >po/POTFILES.in
408 make -C po Makefile
409
410 echo done.