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