netbsd-alpha-start-at-server-support-20020118
[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(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_PARAM_COMMON=param.nbsd15.h
213                         AFS_SYSNAME="i386_nbsd15"
214                         ;;
215                 alpha-*-netbsd*1.5*)
216                         AFS_PARAM_COMMON=param.nbsd15.h
217                         AFS_SYSNAME="alpha_nbsd15"
218                         ;;
219                 hppa*-hp-hpux11*)
220                         AFS_SYSNAME="hp_ux110"
221                         ;;
222                 hppa*-hp-hpux10*)
223                         AFS_SYSNAME="hp_ux102"
224                         ;;
225                 powerpc-apple-darwin1.2*)
226                         AFS_SYSNAME="ppc_darwin_12"
227                         ;;
228                 powerpc-apple-darwin1.3*)
229                         AFS_SYSNAME="ppc_darwin_13"
230                         ;;
231                 powerpc-apple-darwin1.4*)
232                         AFS_SYSNAME="ppc_darwin_14"
233                         ;;
234                 powerpc-apple-darwin5.1*)
235                         AFS_SYSNAME="ppc_darwin_51"
236                         ;;
237                 sparc-sun-solaris2.5*)
238                         AFS_SYSNAME="sun4x_55"
239                         ;;
240                 sparc-sun-solaris2.6)
241                         AFS_SYSNAME="sun4x_56"
242                         ;;
243                 sparc-sun-solaris2.7)
244                         AFS_SYSNAME="sun4x_57"
245                         ;;
246                 sparc-sun-solaris2.8)
247                         AFS_SYSNAME="sun4x_58"
248                         ;;
249                 sparc-sun-solaris2.9)
250                         AFS_SYSNAME="sun4x_59"
251                         ;;
252                 alpha*-dec-osf4.0*)
253                         AFS_SYSNAME="alpha_dux40"
254                         ;;
255                 alpha*-dec-osf5.0*)
256                         AFS_SYSNAME="alpha_dux50"
257                         ;;
258                 mips-sgi-irix6.5)
259                         AFS_SYSNAME="sgi_65"
260                         ;;
261                 ia64-*-linux*)
262                         AFS_SYSNAME="ia64_linuxXX"
263                         ;;
264                 powerpc-*-linux*)
265                         AFS_SYSNAME="ppc_linuxXX"
266                         ;;
267                 alpha*-linux*)
268                         AFS_SYSNAME="alpha_linux_XX"
269                         ;;
270                 s390-*-linux*)
271                         AFS_SYSNAME="s390_linuxXX"
272                         ;;
273                 sparc-*-linux*)
274                         AFS_SYSNAME="sparc_linuxXX"
275                         ;;
276                 sparc64-*-linux*)
277                         AFS_SYSNAME="sparc64_linuxXX"
278                         ;;
279                 i?86-*-linux*)
280                         AFS_SYSNAME="i386_linuxXX"
281                         ;;
282                 parisc-*-linux-gnu)
283                         AFS_SYSNAME="parisc_linuxXX"
284                         ;;
285                 power*-ibm-aix4.2*)
286                         AFS_SYSNAME="rs_aix42"
287                         ;;
288                 power*-ibm-aix4.3*)
289                         AFS_SYSNAME="rs_aix42"
290                         ;;
291                 *)
292                         AC_MSG_ERROR(An AFS sysname is required)
293                         exit 1
294                         ;;
295         esac
296         case $AFS_SYSNAME in
297                 *_linux*)
298                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $[]1 $[]2}'`
299                         if test "x${AFS_SYSKVERS}" = "x"; then
300                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
301                         fi
302                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
303                         AFS_SYSNAME="$_AFS_SYSNAME"
304                         ;;
305         esac
306         AC_MSG_RESULT($AFS_SYSNAME)
307 fi
308
309 case $AFS_SYSNAME in
310         *_darwin*)
311                 DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
312                 DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
313                 ;;
314 esac
315
316 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
317         echo Skipping library tests because they confuse Irix.
318 else
319   AC_CHECK_FUNCS(socket)
320
321   if test "$ac_cv_func_socket" = no; then
322     for lib in socket inet; do
323         if test "$HAVE_SOCKET" != 1; then
324                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
325         fi
326     done
327   fi
328   
329   AC_CHECK_FUNCS(connect)       
330
331   if test "$ac_cv_func_connect" = no; then
332     for lib in nsl; do
333         if test "$HAVE_CONNECT" != 1; then
334                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
335         fi
336     done
337   fi
338
339   AC_CHECK_FUNCS(gethostbyname)
340   if test "$ac_cv_func_gethostbyname" = no; then
341         for lib in dns nsl resolv; do
342           if test "$HAVE_GETHOSTBYNAME" != 1; then
343             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
344           fi
345         done    
346   fi    
347
348   AC_CHECK_FUNCS(res_search)
349   if test "$ac_cv_func_res_search" = no; then
350         for lib in dns nsl resolv; do
351           if test "$HAVE_RES_SEARCH" != 1; then
352             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
353           fi
354         done    
355         if test "$HAVE_RES_SEARCH" = 1; then
356           LIB_res_search="-l$lib"       
357         fi
358   fi    
359 fi
360
361 PTHREAD_LIBS=error
362 AC_CHECK_LIB(pthread, pthread_attr_init,
363              PTHREAD_LIBS="-lpthread")
364 if test "x$PTHREAD_LIBS" = xerror; then
365         AC_CHECK_LIB(pthreads, pthread_attr_init,
366                 PTHREAD_LIBS="-lpthreads")
367 fi
368 if test "x$PTHREAD_LIBS" = xerror; then
369         AC_CHECK_LIB(c_r, pthread_attr_init,
370                 PTHREAD_LIBS="-lc_r")
371 fi
372 if test "x$PTHREAD_LIBS" = xerror; then
373         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
374 fi
375 if test "x$PTHREAD_LIBS" = xerror; then
376         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
377 fi
378 AC_SUBST(PTHREAD_LIBS)
379
380 WITH_OBSOLETE=NO
381 if test "$enable_obsolete" = "yes"; then
382         WITH_OBSOLETE=YES
383 fi
384
385 WITH_INSECURE=NO
386 if test "$enable_insecure" = "yes"; then
387         WITH_INSECURE=YES
388 fi
389
390 # Fast restart
391 if test "$enable_fast_restart" = "yes"; then
392         AC_DEFINE(FAST_RESTART)
393 fi
394
395 if test "$enable_bitmap_later" = "yes"; then
396         AC_DEFINE(BITMAP_LATER)
397 fi
398
399 if test "$enable_full_vos_listvol_switch" = "yes"; then
400         AC_DEFINE(FULL_LISTVOL_SWITCH)
401 fi
402
403 if test "$enable_bos_restricted_mode" = "yes"; then
404         AC_DEFINE(BOS_RESTRICTED_MODE)
405 fi
406
407 if test "$enable_namei_fileserver" = "yes"; then
408         AC_DEFINE(AFS_NAMEI_ENV)
409 fi
410
411 if test "$enable_afsdb" = "yes"; then
412         LIB_AFSDB="$LIB_res_search"
413         AC_DEFINE(AFS_AFSDB_ENV)
414 fi
415
416 dnl check for tivoli
417 AC_MSG_CHECKING(for tivoli tsm butc support)
418 XBSA_CFLAGS=""
419 if test "$enable_tivoli_tsm" = "yes"; then
420         XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
421         XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
422
423         if test -e "$XBSADIR1/xbsa.h"; then
424                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
425                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
426         elif test -e "$XBSADIR2/xbsa.h"; then
427                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
428                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
429         else
430                 AC_MSG_RESULT([no, missing xbsa.h header file])
431         fi
432 else
433         AC_MSG_RESULT([no])
434 fi
435 AC_SUBST(XBSA_CFLAGS)
436
437 dnl checks for header files.
438 AC_HEADER_STDC
439 AC_HEADER_SYS_WAIT
440 AC_HEADER_DIRENT
441 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
442 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
443 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
444 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
445 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
446 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
447
448 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
449
450 dnl Directory PATH handling
451 if test "x$enable_transarc_paths" = "xyes"  ; then 
452     afsconfdir=${afsconfdir=/usr/afs/etc}
453     viceetcdir=${viceetcdir=/usr/vice/etc}
454     afskerneldir=${afskerneldir=${viceetcdir}}
455     afssrvbindir=${afssrvbindir=/usr/afs/bin}
456     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
457     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
458     afsdbdir=${afsdbdir=/usr/afs/db}
459     afslogsdir=${afslogsdir=/usr/afs/logs}
460     afslocaldir=${afslocaldir=/usr/afs/local}
461     afsbackupdir=${afsbackupdir=/usr/afs/backup}
462     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
463 else 
464     afsconfdir=${afsconfdir='${sysconfdir}/openafs/server'}
465     viceetcdir=${viceetcdir='${sysconfdir}/openafs'}
466     afskerneldir=${afskerneldir='${libdir}/openafs'}
467     afssrvbindir=${afssrvbindir='${bindir}'}
468     afssrvsbindir=${afssrvsbindir='${sbindir}'}
469     afssrvlibexecdir=${afssrvlibexecdir='${libexecdir}/openafs'}
470     afsdbdir=${afsdbdir='${localstatedir}/openafs/db'}
471     afslogsdir=${afslogsdir='${localstatedir}/openafs/logs'}
472     afslocaldir=${afslocaldir='${localstatedir}/openafs'}
473     afsbackupdir=${afsbackupdir='${localstatedir}/openafs/backup'}
474     afsbosconfigdir=${afsbosconfigdir='${sysconfdir}/openafs'}
475 fi
476 AC_SUBST(afsconfdir)
477 AC_SUBST(viceetcdir)
478 AC_SUBST(afskerneldir)
479 AC_SUBST(afssrvbindir)
480 AC_SUBST(afssrvsbindir)
481 AC_SUBST(afssrvlibexecdir)
482 AC_SUBST(afsdbdir)
483 AC_SUBST(afslogsdir)
484 AC_SUBST(afslocaldir)
485 AC_SUBST(afsbackupdir)
486 AC_SUBST(afsbosconfigdir)
487
488 if test "x$enable_kernel_module" = "xyes"; then
489 ENABLE_KERNEL_MODULE=libafs
490 fi
491
492 AC_SUBST(AFS_SYSNAME)
493 AC_SUBST(AFS_PARAM_COMMON)
494 AC_SUBST(ENABLE_KERNEL_MODULE)
495 AC_SUBST(LIB_AFSDB)
496 AC_SUBST(LINUX_KERNEL_PATH)
497 AC_SUBST(LINUX_VERSION)
498 AC_SUBST(MKAFS_OSTYPE)
499 AC_SUBST(TOP_OBJDIR)
500 AC_SUBST(TOP_SRCDIR)
501 AC_SUBST(TOP_INCDIR)
502 AC_SUBST(TOP_LIBDIR)
503 AC_SUBST(DEST)
504 AC_SUBST(WITH_OBSOLETE)
505 AC_SUBST(WITH_INSECURE)
506 AC_SUBST(DARWIN_INFOFILE)
507 AC_SUBST(IRIX_BUILD_IP35)
508
509 OPENAFS_OSCONF
510
511 ])