linux24-add-configure-glue-for-new-inode-fields-20020108
[openafs.git] / acinclude.m4
1 dnl This file contains the common configuration code which would
2 dnl otherwise be duplicated between configure and configure-libafs.
3 dnl
4 dnl NB: Because this code is a macro, references to positional shell
5 dnl parameters must be done like $[]1 instead of $1
6
7 AC_DEFUN(OPENAFS_CONFIGURE_COMMON,[
8
9 AC_CANONICAL_HOST
10 SRCDIR_PARENT=`pwd`
11
12 #BOZO_SAVE_CORES BOS_RESTRICTED_MODE BOS_NEW_CONFIG pam sia
13 AC_ARG_WITH(afs-sysname,
14 [  --with-afs-sysname=sys    use sys for the afs sysname]
15 )
16 AC_ARG_ENABLE( obsolete,
17 [  --enable-obsolete                    enable obsolete portions of AFS (mpp, ntp and package)],, enable_obsolete="no")
18 AC_ARG_ENABLE( insecure,
19 [  --enable-insecure                    enable insecure portions of AFS (ftpd, inetd, rcp, rlogind and rsh)],, enable_insecure="no")
20 AC_ARG_ENABLE( afsdb,
21 [  --disable-afsdb                      disable AFSDB RR support],, enable_afsdb="yes")
22 AC_ARG_ENABLE( bos-restricted-mode,
23 [  --enable-bos-restricted-mode         enable bosserver restricted mode which disables certain bosserver functionality],, enable_bos_restricted_mode="no")
24 AC_ARG_ENABLE( namei-fileserver,
25 [  --enable-namei-fileserver            force compilation of namei fileserver in preference to inode fileserver],, enable_namei_fileserver="no")
26 AC_ARG_ENABLE( fast-restart,
27 [  --enable-fast-restart                enable fast startup of file server without salvaging],, enable_fast_restart="no")
28 AC_ARG_ENABLE( bitmap-later,
29 [  --enable-bitmap-later                enable fast startup of file server by not reading bitmap till needed],, enable_bitmap_later="no")
30 AC_ARG_ENABLE( full-vos-listvol-switch,
31 [  --enable-full-vos-listvol-switch     enable vos full listvol switch for formatted output],, enable_full_vos_listvol_switch="no")
32 AC_ARG_WITH(dux-kernel-headers,
33 [  --with-dux-kernel-headers=path       use the kernel headers found at path(optional, defaults to first match in /usr/sys)]
34 )
35 AC_ARG_WITH(linux-kernel-headers,
36 [  --with-linux-kernel-headers=path     use the kernel headers found at path(optional, defaults to /usr/src/linux)]
37 )
38 AC_ARG_ENABLE(kernel-module,
39 [  --disable-kernel-module              disable compilation of the kernel module (defaults to enabled)],, enable_kernel_module="yes"
40 )
41 AC_ARG_ENABLE(redhat-buildsys,
42 [  --enable-redhat-buildsys             enable compilation of the redhat build system kernel (defaults to disabled)],, enable_redhat_buildsys="no"
43 )
44 AC_ARG_ENABLE(transarc-paths,
45 [  --enable-transarc-paths                      Use Transarc style paths like /usr/afs and /usr/vice],, enable_transarc_paths="no"
46 )
47 AC_ARG_ENABLE(tivoli-tsm,
48 [  --enable-tivoli-tsm                  Enable use of the Tivoli TSM API libraries for butc support],, enable_tivoli_tsm="no"
49 )
50
51 AC_PROG_CC
52
53 dnl weird ass systems
54 AC_AIX
55 AC_ISC_POSIX
56 AC_MINIX
57
58 dnl Various compiler setup.
59 AC_C_INLINE
60 AC_C_CONST
61 AC_TYPE_PID_T
62 AC_TYPE_SIZE_T
63 AC_TYPE_SIGNAL
64
65 dnl Checks for programs.
66 AC_PROG_INSTALL
67 AC_PROG_LN_S
68 AC_PROG_RANLIB
69 AC_PROG_YACC
70 AM_PROG_LEX
71
72 OPENAFS_CHECK_BIGENDIAN
73
74 AC_MSG_CHECKING(your OS)
75 system=$host
76 case $system in
77         *-linux*)
78                 MKAFS_OSTYPE=LINUX
79                 if test "x$enable_redhat_buildsys" = "xyes"; then
80                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS)
81                 fi
82                 if test "x$enable_kernel_module" = "xyes"; then
83                  if test "x$with_linux_kernel_headers" != "x"; then
84                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
85                  else
86                    LINUX_KERNEL_PATH="/usr/src/linux"
87                  fi
88                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
89                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1`
90                   if test "x$linux_kvers" = "x"; then
91                     if test -f "$LINUX_KERNEL_PATH/include/linux/version-up.h"; then
92                       linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1`
93                       if test "x$linux_kvers" = "x"; then
94
95                         AC_MSG_ERROR(Linux headers lack version definition [2])
96                         exit 1
97                       else
98                         LINUX_VERSION="$linux_kvers"
99                       fi
100                     else
101                       AC_MSG_ERROR(Linux headers lack version definition)
102                       exit 1
103                     fi
104                   else
105                     LINUX_VERSION="$linux_kvers"
106                   fi
107                  else
108                     enable_kernel_module="no"
109                  fi
110                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
111                      enable_kernel_module="no"
112                  fi
113                  if test "x$enable_kernel_module" = "xno"; then
114                   if test "x$with_linux_kernel_headers" != "x"; then
115                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
116                    exit 1
117                   else
118                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
119                   fi
120                  fi
121                 fi
122                 AC_MSG_RESULT(linux)
123                 if test "x$enable_kernel_module" = "xyes"; then
124                  ifdef([OPENAFS_CONFIGURE_LIBAFS],
125                    [LINUX_BUILD_VNODE_FROM_INODE(src/config,afs)],
126                    [LINUX_BUILD_VNODE_FROM_INODE(${srcdir}/src/config,src/afs/LINUX,${srcdir}/src/afs/LINUX)]
127                  )
128                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
129                  LINUX_FS_STRUCT_INODE_HAS_I_TRUNCATE_SEM
130                  LINUX_FS_STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
131                  LINUX_FS_STRUCT_INODE_HAS_I_DEVICES
132                  LINUX_INODE_SETATTR_RETURN_TYPE
133                  LINUX_NEED_RHCONFIG
134                  LINUX_WHICH_MODULES
135                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
136                   AC_DEFINE(INODE_SETATTR_NOT_VOID)
137                  fi
138                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
139                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK)
140                  fi
141                  if test "x$ac_cv_linux_fs_struct_inode_has_i_truncate_sem" = "xyes"; then 
142                   AC_DEFINE(STRUCT_INODE_HAS_I_TRUNCATE_SEM)
143                  fi
144                 :
145                 fi
146                 ;;
147         *-solaris*)
148                 MKAFS_OSTYPE=SOLARIS
149                 AC_MSG_RESULT(sun4)
150                 SOLARIS_UFSVFS_HAS_DQRWLOCK
151                 ;;
152         *-hpux*)
153                 MKAFS_OSTYPE=HPUX
154                 AC_MSG_RESULT(hp_ux)
155                 ;;
156         *-irix*)
157                 if test -d /usr/include/sys/SN/SN1; then
158                  IRIX_BUILD_IP35="IP35"
159                 fi
160                 MKAFS_OSTYPE=IRIX
161                 AC_MSG_RESULT(sgi)
162                 ;;
163         *-aix*)
164                 MKAFS_OSTYPE=AIX
165                 AC_MSG_RESULT(rs_aix)
166                 ;;
167         *-osf*)
168                 MKAFS_OSTYPE=DUX
169                 AC_MSG_RESULT(alpha_dux)
170                 if test "x$enable_kernel_module" = "xyes"; then
171                  if test "x$with_dux_kernel_headers" != "x"; then
172                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
173                  else
174                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
175                  fi
176                 fi
177                 if test "$HEADER_RT" = "*" ; then
178                         AC_MSG_ERROR([Need a configured kernel directory])
179                 fi
180                 AC_SUBST([HEADER_RT])
181                 ;;
182         *-darwin*)
183                 MKAFS_OSTYPE=DARWIN
184                 AC_MSG_RESULT(ppc_darwin)
185                 ;;
186         *-freebsd*)
187                 MKAFS_OSTYPE=FBSD
188                 AC_MSG_RESULT(i386_fbsd)
189                 ;;
190         *-netbsd*)
191                 MKAFS_OSTYPE=NBSD
192                 AC_MSG_RESULT(i386_nbsd)
193                 ;;
194         *-openbsd*)
195                 MKAFS_OSTYPE=OBSD
196                 AC_MSG_RESULT(i386_obsd)
197                 ;;
198         *)
199                 AC_MSG_RESULT($system)
200                 ;;
201 esac
202
203 if test "x$with_afs_sysname" != "x"; then
204         AFS_SYSNAME="$with_afs_sysname"
205 else
206         AC_MSG_CHECKING(your AFS sysname)
207         case $host in
208                 i?86-*-freebsd4.2*)
209                         AFS_SYSNAME="i386_fbsd_42"
210                         ;;
211                 i?86-*-netbsd*1.5*)
212                         AFS_SYSNAME="i386_nbsd15"
213                         ;;
214                 hppa*-hp-hpux11*)
215                         AFS_SYSNAME="hp_ux110"
216                         ;;
217                 hppa*-hp-hpux10*)
218                         AFS_SYSNAME="hp_ux102"
219                         ;;
220                 powerpc-apple-darwin1.2*)
221                         AFS_SYSNAME="ppc_darwin_12"
222                         ;;
223                 powerpc-apple-darwin1.3*)
224                         AFS_SYSNAME="ppc_darwin_13"
225                         ;;
226                 powerpc-apple-darwin1.4*)
227                         AFS_SYSNAME="ppc_darwin_14"
228                         ;;
229                 powerpc-apple-darwin5.1*)
230                         AFS_SYSNAME="ppc_darwin_51"
231                         ;;
232                 sparc-sun-solaris2.5*)
233                         AFS_SYSNAME="sun4x_55"
234                         ;;
235                 sparc-sun-solaris2.6)
236                         AFS_SYSNAME="sun4x_56"
237                         ;;
238                 sparc-sun-solaris2.7)
239                         AFS_SYSNAME="sun4x_57"
240                         ;;
241                 sparc-sun-solaris2.8)
242                         AFS_SYSNAME="sun4x_58"
243                         ;;
244                 sparc-sun-solaris2.9)
245                         AFS_SYSNAME="sun4x_59"
246                         ;;
247                 alpha*-dec-osf4.0*)
248                         AFS_SYSNAME="alpha_dux40"
249                         ;;
250                 alpha*-dec-osf5.0*)
251                         AFS_SYSNAME="alpha_dux50"
252                         ;;
253                 mips-sgi-irix6.5)
254                         AFS_SYSNAME="sgi_65"
255                         ;;
256                 ia64-*-linux*)
257                         AFS_SYSNAME="ia64_linuxXX"
258                         ;;
259                 powerpc-*-linux*)
260                         AFS_SYSNAME="ppc_linuxXX"
261                         ;;
262                 alpha*-linux*)
263                         AFS_SYSNAME="alpha_linux_XX"
264                         ;;
265                 s390-*-linux*)
266                         AFS_SYSNAME="s390_linuxXX"
267                         ;;
268                 sparc-*-linux*)
269                         AFS_SYSNAME="sparc_linuxXX"
270                         ;;
271                 sparc64-*-linux*)
272                         AFS_SYSNAME="sparc64_linuxXX"
273                         ;;
274                 i?86-*-linux*)
275                         AFS_SYSNAME="i386_linuxXX"
276                         ;;
277                 parisc-*-linux-gnu)
278                         AFS_SYSNAME="parisc_linuxXX"
279                         ;;
280                 power*-ibm-aix4.2*)
281                         AFS_SYSNAME="rs_aix42"
282                         ;;
283                 power*-ibm-aix4.3*)
284                         AFS_SYSNAME="rs_aix42"
285                         ;;
286                 *)
287                         AC_MSG_ERROR(An AFS sysname is required)
288                         exit 1
289                         ;;
290         esac
291         case $AFS_SYSNAME in
292                 *_linux*)
293                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $[]1 $[]2}'`
294                         if test "x${AFS_SYSKVERS}" = "x"; then
295                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
296                         fi
297                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
298                         AFS_SYSNAME="$_AFS_SYSNAME"
299                         ;;
300         esac
301         AC_MSG_RESULT($AFS_SYSNAME)
302 fi
303
304 case $AFS_SYSNAME in
305         *_darwin*)
306                 DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
307                 DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
308                 ;;
309 esac
310
311 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
312         echo Skipping library tests because they confuse Irix.
313 else
314   AC_CHECK_FUNCS(socket)
315
316   if test "$ac_cv_func_socket" = no; then
317     for lib in socket inet; do
318         if test "$HAVE_SOCKET" != 1; then
319                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
320         fi
321     done
322   fi
323   
324   AC_CHECK_FUNCS(connect)       
325
326   if test "$ac_cv_func_connect" = no; then
327     for lib in nsl; do
328         if test "$HAVE_CONNECT" != 1; then
329                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
330         fi
331     done
332   fi
333
334   AC_CHECK_FUNCS(gethostbyname)
335   if test "$ac_cv_func_gethostbyname" = no; then
336         for lib in dns nsl resolv; do
337           if test "$HAVE_GETHOSTBYNAME" != 1; then
338             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
339           fi
340         done    
341   fi    
342
343   AC_CHECK_FUNCS(res_search)
344   if test "$ac_cv_func_res_search" = no; then
345         for lib in dns nsl resolv; do
346           if test "$HAVE_RES_SEARCH" != 1; then
347             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
348           fi
349         done    
350         if test "$HAVE_RES_SEARCH" = 1; then
351           LIB_res_search="-l$lib"       
352         fi
353   fi    
354 fi
355
356 PTHREAD_LIBS=error
357 AC_CHECK_LIB(pthread, pthread_attr_init,
358              PTHREAD_LIBS="-lpthread")
359 if test "x$PTHREAD_LIBS" = xerror; then
360         AC_CHECK_LIB(pthreads, pthread_attr_init,
361                 PTHREAD_LIBS="-lpthreads")
362 fi
363 if test "x$PTHREAD_LIBS" = xerror; then
364         AC_CHECK_LIB(c_r, pthread_attr_init,
365                 PTHREAD_LIBS="-lc_r")
366 fi
367 if test "x$PTHREAD_LIBS" = xerror; then
368         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
369 fi
370 if test "x$PTHREAD_LIBS" = xerror; then
371         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
372 fi
373 AC_SUBST(PTHREAD_LIBS)
374
375 WITH_OBSOLETE=NO
376 if test "$enable_obsolete" = "yes"; then
377         WITH_OBSOLETE=YES
378 fi
379
380 WITH_INSECURE=NO
381 if test "$enable_insecure" = "yes"; then
382         WITH_INSECURE=YES
383 fi
384
385 # Fast restart
386 if test "$enable_fast_restart" = "yes"; then
387         AC_DEFINE(FAST_RESTART)
388 fi
389
390 if test "$enable_bitmap_later" = "yes"; then
391         AC_DEFINE(BITMAP_LATER)
392 fi
393
394 if test "$enable_full_vos_listvol_switch" = "yes"; then
395         AC_DEFINE(FULL_LISTVOL_SWITCH)
396 fi
397
398 if test "$enable_bos_restricted_mode" = "yes"; then
399         AC_DEFINE(BOS_RESTRICTED_MODE)
400 fi
401
402 if test "$enable_namei_fileserver" = "yes"; then
403         AC_DEFINE(AFS_NAMEI_ENV)
404 fi
405
406 if test "$enable_afsdb" = "yes"; then
407         LIB_AFSDB="$LIB_res_search"
408         AC_DEFINE(AFS_AFSDB_ENV)
409 fi
410
411 dnl check for tivoli
412 AC_MSG_CHECKING(for tivoli tsm butc support)
413 XBSA_CFLAGS=""
414 if test "$enable_tivoli_tsm" = "yes"; then
415         XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
416         XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
417
418         if test -e "$XBSADIR1/xbsa.h"; then
419                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
420                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
421         elif test -e "$XBSADIR2/xbsa.h"; then
422                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
423                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
424         else
425                 AC_MSG_RESULT([no, missing xbsa.h header file])
426         fi
427 else
428         AC_MSG_RESULT([no])
429 fi
430 AC_SUBST(XBSA_CFLAGS)
431
432 dnl checks for header files.
433 AC_HEADER_STDC
434 AC_HEADER_SYS_WAIT
435 AC_HEADER_DIRENT
436 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
437 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
438 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
439 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
440 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
441 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
442
443 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
444
445 dnl Directory PATH handling
446 if test "x$enable_transarc_paths" = "xyes"  ; then 
447     afsconfdir=${afsconfdir=/usr/afs/etc}
448     viceetcdir=${viceetcdir=/usr/vice/etc}
449     afskerneldir=${afskerneldir=${viceetcdir}}
450     afssrvbindir=${afssrvbindir=/usr/afs/bin}
451     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
452     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
453     afsdbdir=${afsdbdir=/usr/afs/db}
454     afslogsdir=${afslogsdir=/usr/afs/logs}
455     afslocaldir=${afslocaldir=/usr/afs/local}
456     afsbackupdir=${afsbackupdir=/usr/afs/backup}
457     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
458 else 
459     afsconfdir=${afsconfdir='${sysconfdir}/openafs/server'}
460     viceetcdir=${viceetcdir='${sysconfdir}/openafs'}
461     afskerneldir=${afskerneldir='${libdir}/openafs'}
462     afssrvbindir=${afssrvbindir='${bindir}'}
463     afssrvsbindir=${afssrvsbindir='${sbindir}'}
464     afssrvlibexecdir=${afssrvlibexecdir='${libexecdir}/openafs'}
465     afsdbdir=${afsdbdir='${localstatedir}/openafs/db'}
466     afslogsdir=${afslogsdir='${localstatedir}/openafs/logs'}
467     afslocaldir=${afslocaldir='${localstatedir}/openafs'}
468     afsbackupdir=${afsbackupdir='${localstatedir}/openafs/backup'}
469     afsbosconfigdir=${afsbosconfigdir='${sysconfdir}/openafs'}
470 fi
471 AC_SUBST(afsconfdir)
472 AC_SUBST(viceetcdir)
473 AC_SUBST(afskerneldir)
474 AC_SUBST(afssrvbindir)
475 AC_SUBST(afssrvsbindir)
476 AC_SUBST(afssrvlibexecdir)
477 AC_SUBST(afsdbdir)
478 AC_SUBST(afslogsdir)
479 AC_SUBST(afslocaldir)
480 AC_SUBST(afsbackupdir)
481 AC_SUBST(afsbosconfigdir)
482
483 if test "x$enable_kernel_module" = "xyes"; then
484 ENABLE_KERNEL_MODULE=libafs
485 fi
486
487 AC_SUBST(AFS_SYSNAME)
488 AC_SUBST(ENABLE_KERNEL_MODULE)
489 AC_SUBST(LIB_AFSDB)
490 AC_SUBST(LINUX_KERNEL_PATH)
491 AC_SUBST(LINUX_VERSION)
492 AC_SUBST(MKAFS_OSTYPE)
493 AC_SUBST(TOP_OBJDIR)
494 AC_SUBST(TOP_SRCDIR)
495 AC_SUBST(TOP_INCDIR)
496 AC_SUBST(TOP_LIBDIR)
497 AC_SUBST(DEST)
498 AC_SUBST(WITH_OBSOLETE)
499 AC_SUBST(WITH_INSECURE)
500 AC_SUBST(DARWIN_INFOFILE)
501 AC_SUBST(IRIX_BUILD_IP35)
502
503 OPENAFS_OSCONF
504
505 ])