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