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