configure-and-configure-libafs-use-acinclude-as-common-ground-20011008
[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
48 AC_PROG_CC
49
50 dnl weird ass systems
51 AC_AIX
52 AC_ISC_POSIX
53 AC_MINIX
54
55 dnl Various compiler setup.
56 AC_C_INLINE
57 AC_C_CONST
58 AC_TYPE_PID_T
59 AC_TYPE_SIZE_T
60 AC_TYPE_SIGNAL
61
62 dnl Checks for programs.
63 AC_PROG_INSTALL
64 AC_PROG_LN_S
65 AC_PROG_RANLIB
66 AC_PROG_YACC
67 AM_PROG_LEX
68
69 OPENAFS_CHECK_BIGENDIAN
70
71 AC_MSG_CHECKING(your OS)
72 system=$host
73 case $system in
74         *-linux*)
75                 MKAFS_OSTYPE=LINUX
76                 if test "x$enable_redhat_buildsys" = "xyes"; then
77                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS)
78                 fi
79                 if test "x$enable_kernel_module" = "xyes"; then
80                  if test "x$with_linux_kernel_headers" != "x"; then
81                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
82                  else
83                    LINUX_KERNEL_PATH="/usr/src/linux"
84                  fi
85                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
86                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1`
87                   if test "x$linux_kvers" = "x"; then
88                     if test -f "$LINUX_KERNEL_PATH/include/linux/version-up.h"; then
89                       linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1`
90                       if test "x$linux_kvers" = "x"; then
91
92                         AC_MSG_ERROR(Linux headers lack version definition [2])
93                         exit 1
94                       else
95                         LINUX_VERSION="$linux_kvers"
96                       fi
97                     else
98                       AC_MSG_ERROR(Linux headers lack version definition)
99                       exit 1
100                     fi
101                   else
102                     LINUX_VERSION="$linux_kvers"
103                   fi
104                  else
105                     enable_kernel_module="no"
106                  fi
107                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
108                      enable_kernel_module="no"
109                  fi
110                  if test "x$enable_kernel_module" = "xno"; then
111                   if test "x$with_linux_kernel_headers" != "x"; then
112                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
113                    exit 1
114                   else
115                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
116                   fi
117                  fi
118                 fi
119                 AC_MSG_RESULT(linux)
120                 if test "x$enable_kernel_module" = "xyes"; then
121                  ifdef([OPENAFS_CONFIGURE_LIBAFS],
122                    [LINUX_BUILD_VNODE_FROM_INODE(config,afs)],
123                    [LINUX_BUILD_VNODE_FROM_INODE(src/config,src/afs/LINUX)]
124                  )
125                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
126                  LINUX_INODE_SETATTR_RETURN_TYPE
127                  LINUX_NEED_RHCONFIG
128                  LINUX_WHICH_MODULES
129                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
130                   AC_DEFINE(INODE_SETATTR_NOT_VOID)
131                  fi
132                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
133                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK)
134                  fi
135                 :
136                 fi
137                 ;;
138         *-solaris*)
139                 MKAFS_OSTYPE=SOLARIS
140                 AC_MSG_RESULT(sun4)
141                 SOLARIS_UFSVFS_HAS_DQRWLOCK
142                 ;;
143         *-hpux*)
144                 MKAFS_OSTYPE=HPUX
145                 AC_MSG_RESULT(hp_ux)
146                 ;;
147         *-irix*)
148                 MKAFS_OSTYPE=IRIX
149                 AC_MSG_RESULT(sgi)
150                 ;;
151         *-aix*)
152                 MKAFS_OSTYPE=AIX
153                 AC_MSG_RESULT(rs_aix)
154                 ;;
155         *-osf*)
156                 MKAFS_OSTYPE=DUX
157                 AC_MSG_RESULT(alpha_dux)
158                 if test "x$enable_kernel_module" = "xyes"; then
159                  if test "x$with_dux_kernel_headers" != "x"; then
160                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
161                  else
162                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
163                  fi
164                 fi
165                 if test "$HEADER_RT" = "*" ; then
166                         AC_MSG_ERROR([Need a configured kernel directory])
167                 fi
168                 AC_SUBST([HEADER_RT])
169                 ;;
170         *-darwin*)
171                 MKAFS_OSTYPE=DARWIN
172                 AC_MSG_RESULT(ppc_darwin)
173                 ;;
174         *-freebsd*)
175                 MKAFS_OSTYPE=FBSD
176                 AC_MSG_RESULT(i386_fbsd)
177                 ;;
178         *-openbsd*)
179                 MKAFS_OSTYPE=OBSD
180                 AC_MSG_RESULT(i386_obsd)
181                 ;;
182         *)
183                 AC_MSG_RESULT($system)
184                 ;;
185 esac
186
187 if test "x$with_afs_sysname" != "x"; then
188         AFS_SYSNAME="$with_afs_sysname"
189 else
190         AC_MSG_CHECKING(your AFS sysname)
191         case $host in
192                 i?86-*-freebsd4.2*)
193                         AFS_SYSNAME="i386_fbsd_42"
194                         ;;
195                 hppa*-hp-hpux11*)
196                         AFS_SYSNAME="hp_ux110"
197                         ;;
198                 hppa*-hp-hpux10*)
199                         AFS_SYSNAME="hp_ux102"
200                         ;;
201                 powerpc-apple-darwin1.2*)
202                         AFS_SYSNAME="ppc_darwin_12"
203                         DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
204                         DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
205                         ;;
206                 powerpc-apple-darwin1.3*)
207                         AFS_SYSNAME="ppc_darwin_13"
208                         DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
209                         DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
210                         ;;
211                 powerpc-apple-darwin1.4*)
212                         AFS_SYSNAME="ppc_darwin_14"
213                         DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
214                         DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
215                         ;;
216                 sparc-sun-solaris2.5*)
217                         AFS_SYSNAME="sun4x_55"
218                         ;;
219                 sparc-sun-solaris2.6)
220                         AFS_SYSNAME="sun4x_56"
221                         ;;
222                 sparc-sun-solaris2.7)
223                         AFS_SYSNAME="sun4x_57"
224                         ;;
225                 sparc-sun-solaris2.8)
226                         AFS_SYSNAME="sun4x_58"
227                         ;;
228                 alpha*-dec-osf4.0*)
229                         AFS_SYSNAME="alpha_dux40"
230                         ;;
231                 alpha*-dec-osf5.0*)
232                         AFS_SYSNAME="alpha_dux50"
233                         ;;
234                 mips-sgi-irix6.5)
235                         AFS_SYSNAME="sgi_65"
236                         ;;
237                 ia64-*-linux*)
238                         AFS_SYSNAME="ia64_linuxXX"
239                         ;;
240                 powerpc-*-linux*)
241                         AFS_SYSNAME="ppc_linuxXX"
242                         ;;
243                 alpha*-linux*)
244                         AFS_SYSNAME="alpha_linux_XX"
245                         ;;
246                 s390-*-linux*)
247                         AFS_SYSNAME="s390_linuxXX"
248                         ;;
249                 sparc-*-linux*)
250                         AFS_SYSNAME="sparc_linuxXX"
251                         ;;
252                 sparc64-*-linux*)
253                         AFS_SYSNAME="sparc64_linuxXX"
254                         ;;
255                 i?86-*-linux*)
256                         AFS_SYSNAME="i386_linuxXX"
257                         ;;
258                 parisc-*-linux-gnu)
259                         AFS_SYSNAME="parisc_linuxXX"
260                         ;;
261                 power*-ibm-aix4.2*)
262                         AFS_SYSNAME="rs_aix42"
263                         ;;
264                 power*-ibm-aix4.3*)
265                         AFS_SYSNAME="rs_aix42"
266                         ;;
267                 *)
268                         AC_MSG_ERROR(An AFS sysname is required)
269                         exit 1
270                         ;;
271         esac
272         case $AFS_SYSNAME in
273                 *_linux*)
274                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $[]1 $[]2}'`
275                         if test "x${AFS_SYSKVERS}" = "x"; then
276                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
277                         fi
278                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
279                         AFS_SYSNAME="$_AFS_SYSNAME"
280                         ;;
281         esac
282         AC_MSG_RESULT($AFS_SYSNAME)
283 fi
284
285
286 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
287         echo Skipping library tests because they confuse Irix.
288 else
289   AC_CHECK_FUNCS(socket)
290
291   if test "$ac_cv_func_socket" = no; then
292     for lib in socket inet; do
293         if test "$HAVE_SOCKET" != 1; then
294                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
295         fi
296     done
297   fi
298   
299   AC_CHECK_FUNCS(connect)       
300
301   if test "$ac_cv_func_connect" = no; then
302     for lib in nsl; do
303         if test "$HAVE_CONNECT" != 1; then
304                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
305         fi
306     done
307   fi
308
309   AC_CHECK_FUNCS(gethostbyname)
310   if test "$ac_cv_func_gethostbyname" = no; then
311         for lib in dns nsl resolv; do
312           if test "$HAVE_GETHOSTBYNAME" != 1; then
313             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
314           fi
315         done    
316   fi    
317
318   AC_CHECK_FUNCS(res_search)
319   if test "$ac_cv_func_res_search" = no; then
320         for lib in dns nsl resolv; do
321           if test "$HAVE_RES_SEARCH" != 1; then
322             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
323           fi
324         done    
325         if test "$HAVE_RES_SEARCH" = 1; then
326           LIB_res_search="-l$lib"       
327         fi
328   fi    
329 fi
330
331 PTHREAD_LIBS=error
332 AC_CHECK_LIB(pthread, pthread_attr_init,
333              PTHREAD_LIBS="-lpthread")
334 if test "x$PTHREAD_LIBS" = xerror; then
335         AC_CHECK_LIB(pthreads, pthread_attr_init,
336                 PTHREAD_LIBS="-lpthreads")
337 fi
338 if test "x$PTHREAD_LIBS" = xerror; then
339         AC_CHECK_LIB(c_r, pthread_attr_init,
340                 PTHREAD_LIBS="-lc_r")
341 fi
342 if test "x$PTHREAD_LIBS" = xerror; then
343         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
344 fi
345 if test "x$PTHREAD_LIBS" = xerror; then
346         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
347 fi
348 AC_SUBST(PTHREAD_LIBS)
349
350 WITH_OBSOLETE=NO
351 if test "$enable_obsolete" = "yes"; then
352         WITH_OBSOLETE=YES
353 fi
354
355 WITH_INSECURE=NO
356 if test "$enable_insecure" = "yes"; then
357         WITH_INSECURE=YES
358 fi
359
360 # Fast restart
361 if test "$enable_fast_restart" = "yes"; then
362         AC_DEFINE(FAST_RESTART)
363 fi
364
365 if test "$enable_bitmap_later" = "yes"; then
366         AC_DEFINE(BITMAP_LATER)
367 fi
368
369 if test "$enable_full_vos_listvol_switch" = "yes"; then
370         AC_DEFINE(FULL_LISTVOL_SWITCH)
371 fi
372
373 if test "$enable_bos_restricted_mode" = "yes"; then
374         AC_DEFINE(BOS_RESTRICTED_MODE)
375 fi
376
377 if test "$enable_namei_fileserver" = "yes"; then
378         AC_DEFINE(AFS_NAMEI_ENV)
379 fi
380
381 if test "$enable_afsdb" = "yes"; then
382         LIB_AFSDB="$LIB_res_search"
383         AC_DEFINE(AFS_AFSDB_ENV)
384 fi
385
386 dnl checks for header files.
387 AC_HEADER_STDC
388 AC_HEADER_SYS_WAIT
389 AC_HEADER_DIRENT
390 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
391 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
392 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
393 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
394 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
395 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
396
397 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
398
399 dnl Directory PATH handling
400 if test "x$enable_transarc_paths" = "xyes"  ; then 
401     afsconfdir=${afsconfdir=/usr/afs/etc}
402     viceetcdir=${viceetcdir=/usr/vice/etc}
403     afskerneldir=${afskerneldir=${viceetcdir}}
404     afssrvbindir=${afssrvbindir=/usr/afs/bin}
405     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
406     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
407     afsdbdir=${afsdbdir=/usr/afs/db}
408     afslogsdir=${afslogsdir=/usr/afs/logs}
409     afslocaldir=${afslocaldir=/usr/afs/local}
410     afsbackupdir=${afsbackupdir=/usr/afs/backup}
411     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
412     else 
413     afsconfdir=${afsconfdir=$sysconfdir/openafs/server}
414     viceetcdir=${viceetcdir=$sysconfdir/openafs}
415     afskerneldir=${afskerneldir=$libdir/openafs}
416     afssrvbindir=${afssrvbindir=$bindir}
417     afssrvsbindir=${afssrvsbindir=$sbindir}
418     afssrvlibexecdir=${afssrvlibexecdir=$libexecdir/openafs}
419     afsdbdir=${afsdbdir=$localstatedir/openafs/db}
420     afslogsdir=${afslogsdir=$localstatedir/openafs/logs}
421     afslocaldir=${afslocaldir=$localstatedir/openafs}
422     afsbackupdir=${afsbackupdir=$localstatedir/openafs/backup}
423     afsbosconfigdir=${afsbosconfigdir=$sysconfdir/openafs}
424
425 fi
426 AC_SUBST(afsconfdir)
427 AC_SUBST(viceetcdir)
428 AC_SUBST(afskerneldir)
429 AC_SUBST(afssrvbindir)
430 AC_SUBST(afssrvsbindir)
431 AC_SUBST(afssrvlibexecdir)
432 AC_SUBST(afsdbdir)
433 AC_SUBST(afslogsdir)
434 AC_SUBST(afslocaldir)
435 AC_SUBST(afsbackupdir)
436 AC_SUBST(afsbosconfigdir)
437
438 if test "x$enable_kernel_module" = "xyes"; then
439 ENABLE_KERNEL_MODULE=libafs
440 fi
441
442 AC_SUBST(AFS_SYSNAME)
443 AC_SUBST(ENABLE_KERNEL_MODULE)
444 AC_SUBST(LIB_AFSDB)
445 AC_SUBST(LINUX_KERNEL_PATH)
446 AC_SUBST(LINUX_VERSION)
447 AC_SUBST(MKAFS_OSTYPE)
448 AC_SUBST(TOP_SRCDIR)
449 AC_SUBST(TOP_INCDIR)
450 AC_SUBST(TOP_LIBDIR)
451 AC_SUBST(DEST)
452 AC_SUBST(WITH_OBSOLETE)
453 AC_SUBST(WITH_INSECURE)
454 AC_SUBST(DARWIN_INFOFILE)
455
456 ])