bozo-make-logging-more-readable-20011120
[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_INODE_SETATTR_RETURN_TYPE
131                  LINUX_NEED_RHCONFIG
132                  LINUX_WHICH_MODULES
133                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
134                   AC_DEFINE(INODE_SETATTR_NOT_VOID)
135                  fi
136                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
137                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK)
138                  fi
139                  if test "x$ac_cv_linux_fs_struct_inode_has_i_truncate_sem" = "xyes"; then 
140                   AC_DEFINE(STRUCT_INODE_HAS_I_TRUNCATE_SEM)
141                  fi
142                 :
143                 fi
144                 ;;
145         *-solaris*)
146                 MKAFS_OSTYPE=SOLARIS
147                 AC_MSG_RESULT(sun4)
148                 SOLARIS_UFSVFS_HAS_DQRWLOCK
149                 ;;
150         *-hpux*)
151                 MKAFS_OSTYPE=HPUX
152                 AC_MSG_RESULT(hp_ux)
153                 ;;
154         *-irix*)
155                 if test -d /usr/include/sys/SN/SN1; then
156                  IRIX_BUILD_IP35="IP35"
157                 fi
158                 MKAFS_OSTYPE=IRIX
159                 AC_MSG_RESULT(sgi)
160                 ;;
161         *-aix*)
162                 MKAFS_OSTYPE=AIX
163                 AC_MSG_RESULT(rs_aix)
164                 ;;
165         *-osf*)
166                 MKAFS_OSTYPE=DUX
167                 AC_MSG_RESULT(alpha_dux)
168                 if test "x$enable_kernel_module" = "xyes"; then
169                  if test "x$with_dux_kernel_headers" != "x"; then
170                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
171                  else
172                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
173                  fi
174                 fi
175                 if test "$HEADER_RT" = "*" ; then
176                         AC_MSG_ERROR([Need a configured kernel directory])
177                 fi
178                 AC_SUBST([HEADER_RT])
179                 ;;
180         *-darwin*)
181                 MKAFS_OSTYPE=DARWIN
182                 AC_MSG_RESULT(ppc_darwin)
183                 ;;
184         *-freebsd*)
185                 MKAFS_OSTYPE=FBSD
186                 AC_MSG_RESULT(i386_fbsd)
187                 ;;
188         *-openbsd*)
189                 MKAFS_OSTYPE=OBSD
190                 AC_MSG_RESULT(i386_obsd)
191                 ;;
192         *)
193                 AC_MSG_RESULT($system)
194                 ;;
195 esac
196
197 if test "x$with_afs_sysname" != "x"; then
198         AFS_SYSNAME="$with_afs_sysname"
199 else
200         AC_MSG_CHECKING(your AFS sysname)
201         case $host in
202                 i?86-*-freebsd4.2*)
203                         AFS_SYSNAME="i386_fbsd_42"
204                         ;;
205                 hppa*-hp-hpux11*)
206                         AFS_SYSNAME="hp_ux110"
207                         ;;
208                 hppa*-hp-hpux10*)
209                         AFS_SYSNAME="hp_ux102"
210                         ;;
211                 powerpc-apple-darwin1.2*)
212                         AFS_SYSNAME="ppc_darwin_12"
213                         DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
214                         DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
215                         ;;
216                 powerpc-apple-darwin1.3*)
217                         AFS_SYSNAME="ppc_darwin_13"
218                         DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
219                         DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
220                         ;;
221                 powerpc-apple-darwin1.4*)
222                         AFS_SYSNAME="ppc_darwin_14"
223                         DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
224                         DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
225                         ;;
226                 sparc-sun-solaris2.5*)
227                         AFS_SYSNAME="sun4x_55"
228                         ;;
229                 sparc-sun-solaris2.6)
230                         AFS_SYSNAME="sun4x_56"
231                         ;;
232                 sparc-sun-solaris2.7)
233                         AFS_SYSNAME="sun4x_57"
234                         ;;
235                 sparc-sun-solaris2.8)
236                         AFS_SYSNAME="sun4x_58"
237                         ;;
238                 sparc-sun-solaris2.9)
239                         AFS_SYSNAME="sun4x_59"
240                         ;;
241                 alpha*-dec-osf4.0*)
242                         AFS_SYSNAME="alpha_dux40"
243                         ;;
244                 alpha*-dec-osf5.0*)
245                         AFS_SYSNAME="alpha_dux50"
246                         ;;
247                 mips-sgi-irix6.5)
248                         AFS_SYSNAME="sgi_65"
249                         ;;
250                 ia64-*-linux*)
251                         AFS_SYSNAME="ia64_linuxXX"
252                         ;;
253                 powerpc-*-linux*)
254                         AFS_SYSNAME="ppc_linuxXX"
255                         ;;
256                 alpha*-linux*)
257                         AFS_SYSNAME="alpha_linux_XX"
258                         ;;
259                 s390-*-linux*)
260                         AFS_SYSNAME="s390_linuxXX"
261                         ;;
262                 sparc-*-linux*)
263                         AFS_SYSNAME="sparc_linuxXX"
264                         ;;
265                 sparc64-*-linux*)
266                         AFS_SYSNAME="sparc64_linuxXX"
267                         ;;
268                 i?86-*-linux*)
269                         AFS_SYSNAME="i386_linuxXX"
270                         ;;
271                 parisc-*-linux-gnu)
272                         AFS_SYSNAME="parisc_linuxXX"
273                         ;;
274                 power*-ibm-aix4.2*)
275                         AFS_SYSNAME="rs_aix42"
276                         ;;
277                 power*-ibm-aix4.3*)
278                         AFS_SYSNAME="rs_aix42"
279                         ;;
280                 *)
281                         AC_MSG_ERROR(An AFS sysname is required)
282                         exit 1
283                         ;;
284         esac
285         case $AFS_SYSNAME in
286                 *_linux*)
287                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $[]1 $[]2}'`
288                         if test "x${AFS_SYSKVERS}" = "x"; then
289                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
290                         fi
291                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
292                         AFS_SYSNAME="$_AFS_SYSNAME"
293                         ;;
294         esac
295         AC_MSG_RESULT($AFS_SYSNAME)
296 fi
297
298
299 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
300         echo Skipping library tests because they confuse Irix.
301 else
302   AC_CHECK_FUNCS(socket)
303
304   if test "$ac_cv_func_socket" = no; then
305     for lib in socket inet; do
306         if test "$HAVE_SOCKET" != 1; then
307                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
308         fi
309     done
310   fi
311   
312   AC_CHECK_FUNCS(connect)       
313
314   if test "$ac_cv_func_connect" = no; then
315     for lib in nsl; do
316         if test "$HAVE_CONNECT" != 1; then
317                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
318         fi
319     done
320   fi
321
322   AC_CHECK_FUNCS(gethostbyname)
323   if test "$ac_cv_func_gethostbyname" = no; then
324         for lib in dns nsl resolv; do
325           if test "$HAVE_GETHOSTBYNAME" != 1; then
326             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
327           fi
328         done    
329   fi    
330
331   AC_CHECK_FUNCS(res_search)
332   if test "$ac_cv_func_res_search" = no; then
333         for lib in dns nsl resolv; do
334           if test "$HAVE_RES_SEARCH" != 1; then
335             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
336           fi
337         done    
338         if test "$HAVE_RES_SEARCH" = 1; then
339           LIB_res_search="-l$lib"       
340         fi
341   fi    
342 fi
343
344 PTHREAD_LIBS=error
345 AC_CHECK_LIB(pthread, pthread_attr_init,
346              PTHREAD_LIBS="-lpthread")
347 if test "x$PTHREAD_LIBS" = xerror; then
348         AC_CHECK_LIB(pthreads, pthread_attr_init,
349                 PTHREAD_LIBS="-lpthreads")
350 fi
351 if test "x$PTHREAD_LIBS" = xerror; then
352         AC_CHECK_LIB(c_r, pthread_attr_init,
353                 PTHREAD_LIBS="-lc_r")
354 fi
355 if test "x$PTHREAD_LIBS" = xerror; then
356         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
357 fi
358 if test "x$PTHREAD_LIBS" = xerror; then
359         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
360 fi
361 AC_SUBST(PTHREAD_LIBS)
362
363 WITH_OBSOLETE=NO
364 if test "$enable_obsolete" = "yes"; then
365         WITH_OBSOLETE=YES
366 fi
367
368 WITH_INSECURE=NO
369 if test "$enable_insecure" = "yes"; then
370         WITH_INSECURE=YES
371 fi
372
373 # Fast restart
374 if test "$enable_fast_restart" = "yes"; then
375         AC_DEFINE(FAST_RESTART)
376 fi
377
378 if test "$enable_bitmap_later" = "yes"; then
379         AC_DEFINE(BITMAP_LATER)
380 fi
381
382 if test "$enable_full_vos_listvol_switch" = "yes"; then
383         AC_DEFINE(FULL_LISTVOL_SWITCH)
384 fi
385
386 if test "$enable_bos_restricted_mode" = "yes"; then
387         AC_DEFINE(BOS_RESTRICTED_MODE)
388 fi
389
390 if test "$enable_namei_fileserver" = "yes"; then
391         AC_DEFINE(AFS_NAMEI_ENV)
392 fi
393
394 if test "$enable_afsdb" = "yes"; then
395         LIB_AFSDB="$LIB_res_search"
396         AC_DEFINE(AFS_AFSDB_ENV)
397 fi
398
399 dnl check for tivoli
400 AC_MSG_CHECKING(for tivoli tsm butc support)
401 XBSA_CFLAGS=""
402 if test "$enable_tivoli_tsm" = "yes"; then
403         XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
404         XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
405
406         if test -e "$XBSADIR1/xbsa.h"; then
407                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
408                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
409         elif test -e "$XBSADIR2/xbsa.h"; then
410                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
411                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
412         else
413                 AC_MSG_RESULT([no, missing xbsa.h header file])
414         fi
415 else
416         AC_MSG_RESULT([no])
417 fi
418 AC_SUBST(XBSA_CFLAGS)
419
420 dnl checks for header files.
421 AC_HEADER_STDC
422 AC_HEADER_SYS_WAIT
423 AC_HEADER_DIRENT
424 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
425 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
426 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
427 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
428 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
429 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
430
431 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
432
433 dnl Directory PATH handling
434 if test "x$enable_transarc_paths" = "xyes"  ; then 
435     afsconfdir=${afsconfdir=/usr/afs/etc}
436     viceetcdir=${viceetcdir=/usr/vice/etc}
437     afskerneldir=${afskerneldir=${viceetcdir}}
438     afssrvbindir=${afssrvbindir=/usr/afs/bin}
439     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
440     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
441     afsdbdir=${afsdbdir=/usr/afs/db}
442     afslogsdir=${afslogsdir=/usr/afs/logs}
443     afslocaldir=${afslocaldir=/usr/afs/local}
444     afsbackupdir=${afsbackupdir=/usr/afs/backup}
445     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
446 else 
447     afsconfdir=${afsconfdir='${sysconfdir}/openafs/server'}
448     viceetcdir=${viceetcdir='${sysconfdir}/openafs'}
449     afskerneldir=${afskerneldir='${libdir}/openafs'}
450     afssrvbindir=${afssrvbindir='${bindir}'}
451     afssrvsbindir=${afssrvsbindir='${sbindir}'}
452     afssrvlibexecdir=${afssrvlibexecdir='${libexecdir}/openafs'}
453     afsdbdir=${afsdbdir='${localstatedir}/openafs/db'}
454     afslogsdir=${afslogsdir='${localstatedir}/openafs/logs'}
455     afslocaldir=${afslocaldir='${localstatedir}/openafs'}
456     afsbackupdir=${afsbackupdir='${localstatedir}/openafs/backup'}
457     afsbosconfigdir=${afsbosconfigdir='${sysconfdir}/openafs'}
458 fi
459 AC_SUBST(afsconfdir)
460 AC_SUBST(viceetcdir)
461 AC_SUBST(afskerneldir)
462 AC_SUBST(afssrvbindir)
463 AC_SUBST(afssrvsbindir)
464 AC_SUBST(afssrvlibexecdir)
465 AC_SUBST(afsdbdir)
466 AC_SUBST(afslogsdir)
467 AC_SUBST(afslocaldir)
468 AC_SUBST(afsbackupdir)
469 AC_SUBST(afsbosconfigdir)
470
471 if test "x$enable_kernel_module" = "xyes"; then
472 ENABLE_KERNEL_MODULE=libafs
473 fi
474
475 AC_SUBST(AFS_SYSNAME)
476 AC_SUBST(ENABLE_KERNEL_MODULE)
477 AC_SUBST(LIB_AFSDB)
478 AC_SUBST(LINUX_KERNEL_PATH)
479 AC_SUBST(LINUX_VERSION)
480 AC_SUBST(MKAFS_OSTYPE)
481 AC_SUBST(TOP_OBJDIR)
482 AC_SUBST(TOP_SRCDIR)
483 AC_SUBST(TOP_INCDIR)
484 AC_SUBST(TOP_LIBDIR)
485 AC_SUBST(DEST)
486 AC_SUBST(WITH_OBSOLETE)
487 AC_SUBST(WITH_INSECURE)
488 AC_SUBST(DARWIN_INFOFILE)
489 AC_SUBST(IRIX_BUILD_IP35)
490
491 OPENAFS_OSCONF
492
493 ])