a67eefd7afbe84aac19062dd3d2364375b46b75a
[openafs.git] / configure.in
1 AC_INIT(src/config/stds.h)
2 AM_INIT_AUTOMAKE(openafs,devel)
3 AC_CANONICAL_HOST
4 AC_CONFIG_HEADER(src/config/afsconfig.h)
5
6 #BOZO_SAVE_CORES BOS_RESTRICTED_MODE BOS_NEW_CONFIG pam sia
7 AC_ARG_WITH(afs-sysname,
8 [  --with-afs-sysname=sys    use sys for the afs sysname]
9 )
10 AC_ARG_ENABLE( obsolete,
11 [  --enable-obsolete                    enable obsolete portions of AFS (mpp, ntp and package)],, enable_obsolete="no")
12 AC_ARG_ENABLE( insecure,
13 [  --enable-insecure                    enable insecure portions of AFS (ftpd, inetd, rcp, rlogind and rsh)],, enable_insecure="no")
14 AC_ARG_ENABLE( afsdb,
15 [  --disable-afsdb                      disable AFSDB RR support],, enable_afsdb="yes")
16 AC_ARG_ENABLE( bos-restricted-mode,
17 [  --enable-bos-restricted-mode         enable bosserver restricted mode which disables certain bosserver functionality],, enable_bos_restricted_mode="no")
18 AC_ARG_ENABLE( namei-fileserver,
19 [  --enable-namei-fileserver            force compilation of namei fileserver in preference to inode fileserver],, enable_namei_fileserver="no")
20 AC_ARG_ENABLE( fast-restart,
21 [  --enable-fast-restart                enable fast startup of file server without salvaging],, enable_fast_restart="no")
22 AC_ARG_ENABLE( bitmap-later,
23 [  --enable-bitmap-later                enable fast startup of file server by not reading bitmap till needed],, enable_bitmap_later="no")
24 AC_ARG_WITH(dux-kernel-headers,
25 [  --with-dux-kernel-headers=path       use the kernel headers found at path(optional, defaults to first match in /usr/sys)]
26 )
27 AC_ARG_WITH(linux-kernel-headers,
28 [  --with-linux-kernel-headers=path     use the kernel headers found at path(optional, defaults to /usr/src/linux)]
29 )
30 AC_ARG_ENABLE(kernel-module,
31 [  --disable-kernel-module              disable compilation of the kernel module (defaults to enabled)],, enable_kernel_module="yes"
32 )
33 AC_ARG_ENABLE(redhat-buildsys,
34 [  --enable-redhat-buildsys             enable compilation of the redhat build system kernel (defaults to disabled)],, enable_redhat_buildsys="no"
35 )
36
37 AC_PROG_CC
38
39 dnl weird ass systems
40 AC_AIX
41 AC_ISC_POSIX
42 AC_MINIX
43
44 dnl Various compiler setup.
45 AC_C_INLINE
46 AC_C_CONST
47 AC_TYPE_PID_T
48 AC_TYPE_SIZE_T
49 AC_TYPE_SIGNAL
50
51 dnl Checks for programs.
52 AC_PROG_INSTALL
53 AC_PROG_LN_S
54 AC_PROG_RANLIB
55 AC_PROG_YACC
56 AM_PROG_LEX
57
58 OPENAFS_CHECK_BIGENDIAN
59
60 AC_MSG_CHECKING(your OS)
61 system=$host
62 case $system in
63         *-linux*)
64                 MKAFS_OSTYPE=LINUX
65                 if test "x$enable_kernel_module" = "xyes"; then
66                  if test "x$with_linux_kernel_headers" != "x"; then
67                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
68                  else
69                    LINUX_KERNEL_PATH="/usr/src/linux"
70                  fi
71                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
72                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
73                   if test "x$linux_kvers" = "x"; then
74                     if test -f "$LINUX_KERNEL_PATH/include/linux/version-up.h"; then
75                       linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
76                       if test "x$linux_kvers" = "x"; then
77
78                         AC_MSG_ERROR(Linux headers lack version definition [2])
79                         exit 1
80                       else
81                         LINUX_VERSION="$linux_kvers"
82                       fi
83                     else
84                       AC_MSG_ERROR(Linux headers lack version definition)
85                       exit 1
86                     fi
87                   else
88                     LINUX_VERSION="$linux_kvers"
89                   fi
90                  else
91                     enable_kernel_module="no"
92                  fi
93                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
94                      enable_kernel_module="no"
95                  fi
96                  if test "x$enable_kernel_module" = "xno"; then
97                   if test "x$with_linux_kernel_headers" != "x"; then
98                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
99                    exit 1
100                   else
101                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
102                   fi
103                  fi
104                 fi
105                 AC_MSG_RESULT(linux)
106                 if test "x$enable_kernel_module" = "xyes"; then
107                  LINUX_FS_STRUCT_INODE_HAS_I_BYTES
108                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
109                  LINUX_INODE_SETATTR_RETURN_TYPE
110                  LINUX_NEED_RHCONFIG
111                  LINUX_WHICH_MODULES
112                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
113                   AC_DEFINE(INODE_SETATTR_NOT_VOID)
114                  fi
115                  if test "x$ac_cv_linux_fs_struct_inode_has_i_bytes" = "xyes"; then 
116                   AC_DEFINE(STRUCT_INODE_HAS_I_BYTES)
117                  fi
118                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
119                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK)
120                  fi
121                 :
122                 fi
123                 ;;
124         *-solaris*)
125                 MKAFS_OSTYPE=SOLARIS
126                 AC_MSG_RESULT(sun4)
127                 SOLARIS_UFSVFS_HAS_DQRWLOCK
128                 ;;
129         *-hpux*)
130                 MKAFS_OSTYPE=HPUX
131                 AC_MSG_RESULT(hp_ux)
132                 ;;
133         *-irix*)
134                 MKAFS_OSTYPE=IRIX
135                 AC_MSG_RESULT(sgi)
136                 ;;
137         *-aix*)
138                 MKAFS_OSTYPE=AIX
139                 AC_MSG_RESULT(rs_aix)
140                 ;;
141         *-osf*)
142                 MKAFS_OSTYPE=DUX
143                 AC_MSG_RESULT(alpha_dux)
144                 if test "x$enable_kernel_module" = "xyes"; then
145                  if test "x$with_dux_kernel_headers" != "x"; then
146                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
147                  else
148                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
149                  fi
150                 fi
151                 if test "$HEADER_RT" = "*" ; then
152                         AC_MSG_ERROR([Need a configured kernel directory])
153                 fi
154                 AC_SUBST([HEADER_RT])
155                 ;;
156         *-darwin*)
157                 MKAFS_OSTYPE=DARWIN
158                 AC_MSG_RESULT(ppc_darwin)
159                 ;;
160         *-freebsd*)
161                 MKAFS_OSTYPE=FBSD
162                 AC_MSG_RESULT(i386_fbsd)
163                 ;;
164         *)
165                 AC_MSG_RESULT($system)
166                 ;;
167 esac
168
169 if test "x$with_afs_sysname" != "x"; then
170         AFS_SYSNAME="$with_afs_sysname"
171 else
172         AC_MSG_CHECKING(your AFS sysname)
173         case $host in
174                 i?86-*-freebsd4.2*)
175                         AFS_SYSNAME="i386_fbsd_42"
176                         ;;
177                 hppa-hp-hpux11*)
178                         AFS_SYSNAME="hp_ux110"
179                         ;;
180                 hppa-hp-hpux10*)
181                         AFS_SYSNAME="hp_ux102"
182                         ;;
183                 powerpc-apple-darwin1.2*)
184                         AFS_SYSNAME="ppc_darwin_12"
185                         ;;
186                 powerpc-apple-darwin1.3*)
187                         AFS_SYSNAME="ppc_darwin_13"
188                         ;;
189                 sparc-sun-solaris2.5*)
190                         AFS_SYSNAME="sun4x_55"
191                         ;;
192                 sparc-sun-solaris2.6)
193                         AFS_SYSNAME="sun4x_56"
194                         ;;
195                 sparc-sun-solaris2.7)
196                         AFS_SYSNAME="sun4x_57"
197                         ;;
198                 sparc-sun-solaris2.8)
199                         AFS_SYSNAME="sun4x_58"
200                         ;;
201                 alpha*-dec-osf4.0*)
202                         AFS_SYSNAME="alpha_dux40"
203                         ;;
204                 alpha*-dec-osf5.0*)
205                         AFS_SYSNAME="alpha_dux50"
206                         ;;
207                 mips-sgi-irix6.5)
208                         AFS_SYSNAME="sgi_65"
209                         ;;
210                 powerpc-*-linux*)
211                         AFS_SYSNAME="ppc_linuxXX"
212                         ;;
213                 alpha*-linux*)
214                         AFS_SYSNAME="alpha_linux_XX"
215                         ;;
216                 sparc-*-linux*)
217                         AFS_SYSNAME="sparc_linuxXX"
218                         ;;
219                 sparc64-*-linux*)
220                         AFS_SYSNAME="sparc64_linuxXX"
221                         ;;
222                 i?86-*-linux*)
223                         AFS_SYSNAME="i386_linuxXX"
224                         ;;
225                 power*-ibm-aix4.2*)
226                         AFS_SYSNAME="rs_aix42"
227                         ;;
228                 power*-ibm-aix4.3*)
229                         AFS_SYSNAME="rs_aix42"
230                         ;;
231                 *)
232                         AC_MSG_ERROR(An AFS sysname is required)
233                         exit 1
234                         ;;
235         esac
236         case $AFS_SYSNAME in
237                 *_linux*)
238                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $1 $2}'`
239                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
240                         AFS_SYSNAME="$_AFS_SYSNAME"
241                         ;;
242         esac
243         AC_MSG_RESULT($AFS_SYSNAME)
244 fi
245
246
247 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
248         echo Skipping library tests because they confuse Irix.
249 else
250   AC_CHECK_FUNCS(socket)
251
252   if test "$ac_cv_func_socket" = no; then
253     for lib in socket inet; do
254         if test "$HAVE_SOCKET" != 1; then
255                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
256         fi
257     done
258   fi
259   
260   AC_CHECK_FUNCS(connect)       
261
262   if test "$ac_cv_func_connect" = no; then
263     for lib in nsl; do
264         if test "$HAVE_CONNECT" != 1; then
265                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
266         fi
267     done
268   fi
269
270   AC_CHECK_FUNCS(gethostbyname)
271   if test "$ac_cv_func_gethostbyname" = no; then
272         for lib in dns nsl resolv; do
273           if test "$HAVE_GETHOSTBYNAME" != 1; then
274             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
275           fi
276         done    
277   fi    
278
279   AC_CHECK_FUNCS(res_search)
280   if test "$ac_cv_func_res_search" = no; then
281         for lib in dns nsl resolv; do
282           if test "$HAVE_RES_SEARCH" != 1; then
283             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
284           fi
285         done    
286         if test "$HAVE_RES_SEARCH" = 1; then
287           LIB_res_search="-l$lib"       
288         fi
289   fi    
290 fi
291
292 PTHREAD_LIBS=error
293 AC_CHECK_LIB(pthread, pthread_attr_init,
294              PTHREAD_LIBS="-lpthread")
295 if test "x$PTHREAD_LIBS" = xerror; then
296         AC_CHECK_LIB(pthreads, pthread_attr_init,
297                 PTHREAD_LIBS="-lpthreads")
298 fi
299 if test "x$PTHREAD_LIBS" = xerror; then
300         AC_CHECK_LIB(c_r, pthread_attr_init,
301                 PTHREAD_LIBS="-lc_r")
302 fi
303 if test "x$PTHREAD_LIBS" = xerror; then
304         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
305 fi
306 if test "x$PTHREAD_LIBS" = xerror; then
307         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
308 fi
309 AC_SUBST(PTHREAD_LIBS)
310
311 WITH_OBSOLETE=NO
312 if test "$enable_obsolete" = "yes"; then
313         WITH_OBSOLETE=YES
314 fi
315
316 WITH_INSECURE=NO
317 if test "$enable_insecure" = "yes"; then
318         WITH_INSECURE=YES
319 fi
320
321 # Fast restart
322 if test "$enable_fast_restart" = "yes"; then
323         AC_DEFINE(FAST_RESTART)
324 fi
325
326 if test "$enable_bitmap_later" = "yes"; then
327         AC_DEFINE(BITMAP_LATER)
328 fi
329
330 if test "$enable_bos_restricted_mode" = "yes"; then
331         AC_DEFINE(BOS_RESTRICTED_MODE)
332 fi
333
334 if test "$enable_namei_fileserver" = "yes"; then
335         AC_DEFINE(AFS_NAMEI_ENV)
336 fi
337
338 if test "$enable_afsdb" = "yes"; then
339         LIB_AFSDB="$LIB_res_search"
340         AC_DEFINE(AFS_AFSDB_ENV)
341 fi
342
343 SRCDIR_PARENT=`pwd`
344 TOP_SRCDIR="${SRCDIR_PARENT}/src"
345
346 dnl checks for header files.
347 AC_HEADER_STDC
348 AC_HEADER_SYS_WAIT
349 AC_HEADER_DIRENT
350 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
351 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
352 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
353 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
354 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
355 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
356
357 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
358
359 if test "x$enable_kernel_module" = "xyes"; then
360 ENABLE_KERNEL_MODULE=libafs
361 fi
362
363 AC_SUBST(AFS_SYSNAME)
364 AC_SUBST(ENABLE_KERNEL_MODULE)
365 AC_SUBST(LIB_AFSDB)
366 AC_SUBST(LINUX_KERNEL_PATH)
367 AC_SUBST(LINUX_VERSION)
368 AC_SUBST(MKAFS_OSTYPE)
369 AC_SUBST(TOP_SRCDIR)
370 AC_SUBST(WITH_OBSOLETE)
371 AC_SUBST(WITH_INSECURE)
372
373 AC_OUTPUT(             \
374 Makefile               \
375 src/config/Makefile.version-NOCML \
376 src/config/Makefile.${AFS_SYSNAME} \
377 src/libafs/MakefileProto.${MKAFS_OSTYPE} \
378 src/pam/Makefile \
379 src/afsd/afs.ppc_darwin.plist \
380 )