Compilation of C++ modules conditioned by --with-cxx (disabled by default).
[lufs.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.50)
3 AC_INIT(AUTHORS)
4 AM_CONFIG_HEADER(config.h)
5 AC_CANONICAL_SYSTEM
6 AM_INIT_AUTOMAKE(lufs,0.9.6)
7 AM_MAINTAINER_MODE
8 dnl Some Makefiles use additional tests etc.
9 AM_CONDITIONAL(MAINTAINER_MODE,[test "$USE_MAINTAINER_MODE" = "yes"])
10
11 dnl "static" FSs
12 opt_fs="localfs gnetfs"
13
14 dnl Checks for programs.
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_DISABLE_STATIC
20 AM_PROG_LIBTOOL
21 AC_PROG_MAKE_SET
22
23 AC_ARG_WITH(cxx, 
24     [  --with-cxx              permit use of C++ compiler for additional filesystems],
25     [
26         AC_PROG_CXX
27         opt_fs="$opt_fs locasefs ftpfs"
28     ],
29     [
30         AC_PROG_CXX(true)
31         CXX=false
32     ])
33
34 AC_ARG_ENABLE(kernel-support,
35     [  --enable-kernel-support enable building of the kernel module (default=yes)],
36     [  KERNEL_SUPPORT=$enableval ],)
37
38 if test "$KERNEL_SUPPORT" != "no"
39 then
40
41     dnl Checking os
42     AC_MSG_CHECKING(OS)
43     OS_DIR=`uname -s`
44     if test ! -d kernel/$OS_DIR
45     then
46         AC_MSG_ERROR($OS_DIR - not supported!)
47     else
48         AC_MSG_RESULT($OS_DIR)
49     fi
50
51     dnl LINUX kernel configuration
52     if test "$OS_DIR"="Linux"
53     then
54
55         dnl Checking kernel & headers
56         AC_MSG_CHECKING(kernel)
57         AC_ARG_WITH(kernel, 
58             [  --with-kernel=VERSION   specify a kernel version to compile for], 
59             [KERNEL_VERSION=$withval],
60             [KERNEL_VERSION=`uname -r`])    
61         MODULES_DIR=/lib/modules/$KERNEL_VERSION
62         AC_MSG_RESULT($KERNEL_VERSION)
63
64         AC_MSG_CHECKING(kernel support)
65         KERNEL_DIR=`echo $KERNEL_VERSION | cut -d'.' -f1,2`
66         if test ! -d kernel/$OS_DIR/$KERNEL_DIR
67         then
68             AC_MSG_ERROR([$KERNEL_DIR not supported!])
69         else
70             AC_MSG_RESULT([supported in kernel/$OS_DIR/$KERNEL_DIR])
71         fi
72
73         AC_MSG_CHECKING(kernel headers)
74         AC_ARG_WITH(kheaders,
75             [  --with-kheaders=DIR     specify the location of the kernel headers],
76             [KERNEL_HDR=$withval],
77             [KERNEL_HDR=$MODULES_DIR/build/include])
78         if test ! -f $KERNEL_HDR/linux/fs.h
79         then 
80             AC_MSG_ERROR([not found in $KERNEL_HDR. please install them!])
81         else
82             AC_MSG_RESULT([found in $KERNEL_HDR])
83         fi
84
85         AC_MSG_CHECKING(kernel configuration)
86         if test -f $MODULES_DIR/build/.config
87         then
88             tmp=`cat $MODULES_DIR/build/.config | grep CONFIG_MODVERSIONS=y`
89             if test "$tmp"
90             then
91                 AC_MSG_RESULT([found, using modversions])
92                 MODV_FLAGS="-DMODVERSIONS -include $KERNEL_HDR/linux/modversions.h"
93             else
94                 AC_MSG_RESULT([found, not using modversions])
95             fi
96         else
97             AC_MSG_RESULT([not found at $MODULES_DIR/build/.config, assuming modversions support])
98             MODV_FLAGS="-DMODVERSIONS -include $KERNEL_HDR/linux/modversions.h"        
99         fi
100
101         AC_ARG_ENABLE(modversions, 
102             [  --enable-modversions    enable modeversions support (default=auto-detect)],
103             [ if test $enableval = "yes"; then MODV_FLAGS="-DMODVERSIONS -include $KERNEL_HDR/linux/modversions.h"; else MODV_FLAGS=""; fi ],)
104     
105         AC_SUBST(MODV_FLAGS)
106         AC_SUBST(KERNEL_DIR)
107         AC_SUBST(MODULES_DIR)
108         AC_SUBST(KERNEL_HDR)
109
110     fi
111 fi
112 AC_SUBST(OS_DIR)
113
114
115 dnl options
116 AC_ARG_ENABLE(debug,
117     [  --enable-debug          enable debug messages to stdout (default=no)],
118     [  DEBUG_FLAGS="-g -DDEBUG" && CXXFLAGS="-g -O2 -Wall -DDEBUG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" && CFLAGS="-g -O2 -Wall -DDEBUG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"],
119     [  CXXFLAGS="-O2 -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" && CFLAGS="-O2 -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"])
120 AC_SUBST(DEBUG_FLAGS)
121
122 AC_ARG_ENABLE(kdebug,
123     [  --enable-kdebug         enable kernel module debug messages (default=no)],
124     [  KDEBUG_FLAGS="-DLUFS_DEBUG -DLUFS_VERBOSE" ], )
125 AC_SUBST(KDEBUG_FLAGS)
126
127 AC_ARG_ENABLE(autofs-install,
128     [  --enable-autofs-install enable installing of autofs configuration (default=no)],
129     [  AUTOFS_INSTALL="yes"],)
130 AC_SUBST(AUTOFS_INSTALL)    
131
132 AC_ARG_ENABLE(suid,
133     [  --enable-suid           make lufsmnt and lufsumount suid root (default=yes)],
134     [ if test $enableval = "no"; then LUFS_SUID=""; else LUFS_SUID="true"; fi ] , LUFS_SUID="true" )
135 AC_SUBST(LUFS_SUID)
136
137
138 dnl Checking ssh
139 AC_MSG_CHECKING(for ssh)
140 AC_ARG_WITH(ssh, 
141         [  --with-ssh=PATH         specify the path to the ssh executable], 
142         [
143             if test "$CXX" = "false"
144             then
145                 AC_MSG_ERROR([Use --with-cxx to permit C++ compilation of sshfs.])
146             fi
147             SSHPROG=$withval
148             if test ! -x "$SSHPROG"
149             then
150                 AC_MSG_ERROR([Specified --with-ssh $SSHPROG is not executable.])
151             fi
152         ],[
153             if test "$CXX" = "false"
154             then
155                 SSHPROG=no
156             else
157                 if which ssh 2>/dev/null
158                 then
159                     SSHPROG=`which ssh`
160                 else
161                     SSHPROG=no
162                 fi
163             fi
164         ])
165 if test "$SSHPROG" = "no"
166 then
167     AC_MSG_RESULT([not found (sshfs support disabled)])
168 else
169     AC_MSG_RESULT([found ($SSHPROG)])
170     AC_DEFINE([HAS_SSH], 1 , [Define if ssh is found.])
171     opt_fs="$opt_fs sshfs"
172 fi
173 AC_SUBST(SSHPROG)
174
175
176 dnl Checking gnome
177 if test "$CXX" != "false"
178 then
179     AC_CHECK_PROG(GCONF, gnome-config, gnome-config)
180     AC_CHECK_PROG(GVFSCONF, gnome-vfs-config, gnome-vfs-config)
181     AC_CHECK_LIB(gnomevfs, gnome_vfs_init, HAS_GNOMEVFS=1,)
182     if test "$GCONF" -a "$GVFSCONF" -a "$HAS_GNOMEVFS"
183     then
184         AC_DEFINE([HAS_GVFS], 1, [Define if gvfs is to be built.])
185
186         GVFS_LDADD="`$GCONF --libs gnome` `$GVFSCONF --libs`"
187         GVFS_CFLAGS="`$GCONF --cflags gnome` `$GVFSCONF --cflags`"
188         opt_fs="$opt_fs gvfs"
189     fi
190 fi
191 AC_SUBST(GVFS_LDADD)
192 AC_SUBST(GVFS_CFLAGS)
193
194 AC_ARG_ENABLE(wavfs,
195         [  --enable-wavfs          build wavfs support (default=no)],
196         [
197             if test "$CXX" = "false"
198             then
199                 AC_MSG_ERROR([Use --with-cxx to permit C++ compilation of wavfs.])
200             fi
201             opt_fs="$opt_fs wavfs"
202         ],)
203
204
205 AC_ARG_ENABLE(cefs,
206         [  --enable-cefs           build cefs support (default=no)],
207         [
208             if test "$CXX" = "false"
209             then
210                 AC_MSG_ERROR([Use --with-cxx to permit C++ compilation of cefs.])
211             fi
212             opt_fs="$opt_fs cefs"
213         ],)
214
215 if test -n "$cefs_dir"; then
216     AC_DEFINE([HAS_CEFS], 1, [Define if cefs is to be built.])
217     AC_DEFINE([INFOFILE], ["/tmp/cedevices"], [Path to the information file for the RAPI library])
218 fi
219
220 AC_ARG_ENABLE(cardfs,
221         [  --enable-cardfs         build cardfs support (default=no)],
222         [ WITH_CARDFS=true ],)
223
224 dnl Checks for libraries.
225 AC_CHECK_LIB(pthread, pthread_detach,,AC_MSG_ERROR(libpthread is needed by lufs))
226
227
228 dnl Checks for header files.
229 AC_HEADER_STDC
230 AC_CHECK_HEADERS(unistd.h)
231
232
233 dnl This will test for endian-swapping headers
234 AC_CHECK_HEADERS(byteswap.h sys/byteswap.h endian.h machine/endian.h sys/types.h)
235
236
237 dnl Checks for typedefs, structures, and compiler characteristics.
238 AC_C_CONST
239 AC_TYPE_PID_T
240
241 dnl Checks for library functions.
242 AC_CHECK_FUNCS(mkdir rmdir)
243
244 if test -n "$WITH_CARDFS"; then
245     echo checking for cardfs
246     if test "$CXX" = "false"
247     then
248         AC_MSG_ERROR([Use --with-cxx to permit C++ compilation of cardfs.])
249     fi
250     AC_MSG_CHECKING(for libchipcard)
251     AC_ARG_WITH(chipcard-dir, 
252         [  --with-chipcard-dir=DIR uses libchipcard from given dir],
253         [cc_dir="$withval"],
254         [cc_dir="/usr/local/libchipcard \
255             /usr/local \
256             /usr/libchipcard \
257             /usr \
258             /"])
259     for li in $cc_dir; do
260         if test -x "$li/bin/libchipcard-config"; then
261             chipcard_dir="$li"
262         fi
263     done
264     if test -z "$chipcard_dir"; then
265         AC_MSG_RESULT([not found (chipcard support disabled)])
266     else
267         all_libraries="$all_libraries `$chipcard_dir/bin/libchipcard-config --libraries`"
268         all_includes="$all_includes `$chipcard_dir/bin/libchipcard-config --includes`"
269         AC_DEFINE([HAS_LIBCHIPCARD], 1, [Define if libchipcard is present.])
270         define_has_libchipcard="#define HAS_LIBCHIPCARD"
271         AC_SUBST(define_has_libchipcard)
272         LIBCHIPCARD_LIB="`$chipcard_dir/bin/libchipcard-config --libraries` -lcardfs"
273         LIBCHIPCARD_INCLUDES="`$chipcard_dir/bin/libchipcard-config --includes`"
274         AC_MSG_RESULT($chipcard_dir)
275         all_libraries="$all_libraries $libchipcard_libs"
276         all_includes="$all_includes $libchipcard_includes"
277         opt_fs="$opt_fs cardfs"
278     fi
279 fi
280 AC_SUBST(LIBCHIPCARD_LIB)
281 AC_SUBST(LIBCHIPCARD_INCLUDES)
282
283 all_includes="$all_includes -I`pwd`/include"
284
285 AC_SUBST(opt_fs)
286 AC_SUBST(all_includes)
287 AC_SUBST(all_libraries)
288
289 AC_OUTPUT(\
290         Makefile \
291         lufsd/Makefile \
292         filesystems/Makefile \
293         filesystems/localfs/Makefile \
294         filesystems/locasefs/Makefile \
295         filesystems/sshfs/Makefile \
296         filesystems/ftpfs/Makefile \
297         filesystems/cardfs/Makefile \
298         filesystems/cefs/Makefile \
299         filesystems/cefs/asyncd/Makefile \
300         filesystems/gvfs/Makefile \
301         filesystems/gnetfs/Makefile \
302         filesystems/wavfs/Makefile \
303         util/Makefile \
304         kernel/Makefile \
305         kernel/Linux/Makefile \
306         kernel/Linux/2.4/Makefile \
307         kernel/Linux/2.5/Makefile \
308         include/Makefile \
309         docs/Makefile \
310         man/Makefile \
311         lufs.spec \
312         )
313
314 echo "###############################################################################"
315 echo " supported filesystems: $opt_fs"
316 echo -n " suid files: "
317 if test $LUFS_SUID; then echo "lufsmnt & lufsumount."; else echo "none."; fi
318 echo "###############################################################################"