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