b49aca4d0c41ea601dc9685f28eeb00315f3bfb8
[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 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( bos-new-config,
25 [  --enable-bos-new-config              enable bosserver pickup of BosConfig.new on restarts],, enable_bos_new_config="no")
26 AC_ARG_ENABLE( largefile-fileserver,
27 [  --enable-largefile-filesever         enable large file support in fileserver],, enable_largefile_fileserver="no")
28 AC_ARG_ENABLE( namei-fileserver,
29 [  --enable-namei-fileserver            force compilation of namei fileserver in preference to inode fileserver],, enable_namei_fileserver="no")
30 AC_ARG_ENABLE( fast-restart,
31 [  --enable-fast-restart                enable fast startup of file server without salvaging],, enable_fast_restart="no")
32 AC_ARG_ENABLE( bitmap-later,
33 [  --enable-bitmap-later                enable fast startup of file server by not reading bitmap till needed],, enable_bitmap_later="no")
34 AC_ARG_ENABLE( full-vos-listvol-switch,
35 [  --enable-full-vos-listvol-switch     enable vos full listvol switch for formatted output],, enable_full_vos_listvol_switch="no")
36 AC_ARG_WITH(dux-kernel-headers,
37 [  --with-dux-kernel-headers=path       use the kernel headers found at path(optional, defaults to first match in /usr/sys)]
38 )
39 AC_ARG_WITH(linux-kernel-headers,
40 [  --with-linux-kernel-headers=path     use the kernel headers found at path(optional, defaults to /usr/src/linux)]
41 )
42 AC_ARG_ENABLE(kernel-module,
43 [  --disable-kernel-module              disable compilation of the kernel module (defaults to enabled)],, enable_kernel_module="yes"
44 )
45 AC_ARG_ENABLE(redhat-buildsys,
46 [  --enable-redhat-buildsys             enable compilation of the redhat build system kernel (defaults to disabled)],, enable_redhat_buildsys="no"
47 )
48 AC_ARG_ENABLE(transarc-paths,
49 [  --enable-transarc-paths                      Use Transarc style paths like /usr/afs and /usr/vice],, enable_transarc_paths="no"
50 )
51 AC_ARG_ENABLE(tivoli-tsm,
52 [  --enable-tivoli-tsm                  Enable use of the Tivoli TSM API libraries for butc support],, enable_tivoli_tsm="no"
53 )
54 AC_ARG_ENABLE(debug-kernel,
55 [  --enable-debug-kernel                enable compilation of the kernel module with debugging information (defaults to disabled)],, enable_debug_kernel="no"
56 )
57
58 dnl weird ass systems
59 AC_AIX
60 AC_ISC_POSIX
61 AC_MINIX
62
63 dnl Various compiler setup.
64 AC_TYPE_PID_T
65 AC_TYPE_SIZE_T
66 AC_TYPE_SIGNAL
67
68 dnl Checks for programs.
69 AC_PROG_INSTALL
70 AC_PROG_LN_S
71 AC_PROG_RANLIB
72 AC_PROG_YACC
73 AM_PROG_LEX
74
75 OPENAFS_CHECK_BIGENDIAN
76
77 KERN_DEBUG_OPT=
78 if test "x$enable_debug_kernel" = "xyes"; then
79   KERN_DEBUG_OPT=-g
80 fi
81
82 AC_MSG_CHECKING(your OS)
83 system=$host
84 case $system in
85         *-linux*)
86                 MKAFS_OSTYPE=LINUX
87                 if test "x$enable_redhat_buildsys" = "xyes"; then
88                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS, 1, [define if you have redhat buildsystem])
89                 fi
90                 if test "x$enable_kernel_module" = "xyes"; then
91                  if test "x$with_linux_kernel_headers" != "x"; then
92                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
93                  else
94                    LINUX_KERNEL_PATH="/usr/src/linux"
95                  fi
96                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
97                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1`
98                   if test "x$linux_kvers" = "x"; then
99                     if test -f "$LINUX_KERNEL_PATH/include/linux/version-up.h"; then
100                       linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1`
101                       if test "x$linux_kvers" = "x"; then
102
103                         AC_MSG_ERROR(Linux headers lack version definition [2])
104                         exit 1
105                       else
106                         LINUX_VERSION="$linux_kvers"
107                       fi
108                     else
109                       AC_MSG_ERROR(Linux headers lack version definition)
110                       exit 1
111                     fi
112                   else
113                     LINUX_VERSION="$linux_kvers"
114                   fi
115                  else
116                     enable_kernel_module="no"
117                  fi
118                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
119                      enable_kernel_module="no"
120                  fi
121                  if test "x$enable_kernel_module" = "xno"; then
122                   if test "x$with_linux_kernel_headers" != "x"; then
123                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
124                    exit 1
125                   else
126                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
127                   fi
128                  fi
129                 fi
130                 AC_MSG_RESULT(linux)
131                 if test "x$enable_kernel_module" = "xyes"; then
132                  OMIT_FRAME_POINTER=
133                  if test "x$enable_debug_kernel" = "xno"; then
134                         OMIT_FRAME_POINTER=-fomit-frame-pointer
135                  fi
136                  AC_SUBST(OMIT_FRAME_POINTER)
137                  OPENAFS_GCC_SUPPORTS_MARCH
138                  AC_SUBST(P5PLUS_KOPTS)
139                  OPENAFS_GCC_NEEDS_NO_STRENGTH_REDUCE
140                  OPENAFS_GCC_NEEDS_NO_STRICT_ALIASING
141                  OPENAFS_GCC_SUPPORTS_NO_COMMON
142                  AC_SUBST(LINUX_GCC_KOPTS)
143                  ifdef([OPENAFS_CONFIGURE_LIBAFS],
144                    [LINUX_BUILD_VNODE_FROM_INODE(src/config,afs)],
145                    [LINUX_BUILD_VNODE_FROM_INODE(${srcdir}/src/config,src/afs/LINUX,${srcdir}/src/afs/LINUX)]
146                  )
147                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
148                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_GFP_MASK
149                  LINUX_FS_STRUCT_INODE_HAS_I_TRUNCATE_SEM
150                  LINUX_FS_STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
151                  LINUX_FS_STRUCT_INODE_HAS_I_DEVICES
152                  LINUX_INODE_SETATTR_RETURN_TYPE
153                  LINUX_COMPLETION_H_EXISTS
154                  LINUX_EXPORTS_TASKLIST_LOCK
155                  LINUX_NEED_RHCONFIG
156                  LINUX_WHICH_MODULES
157                  if test "x$ac_cv_linux_config_modversions" = "xno"; then
158                    AC_MSG_WARN([Cannot determine sys_call_table status. assuming it's exported])
159                    ac_cv_linux_exports_sys_call_table=yes
160                  else
161                    LINUX_EXPORTS_SYS_CALL_TABLE
162                    LINUX_EXPORTS_KALLSYMS_SYMBOL
163                    LINUX_EXPORTS_KALLSYMS_ADDRESS
164                    LINUX_EXPORTS_INIT_MM
165                    if test "x$ac_cv_linux_exports_sys_call_table" = "xno"; then
166                          linux_syscall_method=none
167                          if test "x$ac_cv_linux_exports_init_mm" = "xyes"; then
168                             linux_syscall_method=scan
169                             if test "x$ac_cv_linux_exports_kallsyms_address" = "xyes"; then
170                                linux_syscall_method=scan_with_kallsyms_address
171                             fi
172                          fi
173                          if test "x$ac_cv_linux_exports_kallsyms_symbol" = "xyes"; then
174                             linux_syscall_method=kallsyms_symbol
175                          fi
176                          if test "x$linux_syscall_method" = "xnone"; then
177                         AC_MSG_ERROR([no available sys_call_table access method])
178                          fi
179                    fi
180                  fi
181                  if test "x$ac_cv_linux_exports_tasklist_lock" = "xyes" ; then
182                   AC_DEFINE(EXPORTED_TASKLIST_LOCK, 1, [define if your linux kernel exports tasklist_lock])
183                  fi
184                  if test "x$ac_cv_linux_exports_sys_call_table" = "xyes"; then
185                   AC_DEFINE(EXPORTED_SYS_CALL_TABLE)
186                  fi
187                  if test "x$ac_cv_linux_exports_kallsyms_symbol" = "xyes"; then
188                   AC_DEFINE(EXPORTED_KALLSYMS_SYMBOL)
189                  fi
190                  if test "x$ac_cv_linux_exports_kallsyms_address" = "xyes"; then
191                   AC_DEFINE(EXPORTED_KALLSYMS_ADDRESS)
192                  fi
193                  if test "x$ac_cv_linux_completion_h_exists" = "xyes" ; then
194                   AC_DEFINE(COMPLETION_H_EXISTS, 1, [define if your h_exists exists])
195                  fi
196                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
197                   AC_DEFINE(INODE_SETATTR_NOT_VOID, 1, [define if your setattr return return non-void])
198                  fi
199                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
200                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK, 1, [define if your struct address_space has page_lock])
201                  fi
202                  if test "x$ac_cv_linux_fs_struct_address_space_has_gfp_mask" = "xyes"; then 
203                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_GFP_MASK, 1, [define if your struct address_space has gfp_mask])
204                  fi
205                  if test "x$ac_cv_linux_fs_struct_inode_has_i_truncate_sem" = "xyes"; then 
206                   AC_DEFINE(STRUCT_INODE_HAS_I_TRUNCATE_SEM, 1, [define if your struct inode has truncate_sem])
207                  fi
208                  if test "x$ac_cv_linux_fs_struct_inode_has_i_devices" = "xyes"; then 
209                   AC_DEFINE(STRUCT_INODE_HAS_I_DEVICES, 1, [define if you struct inode has i_devices])
210                  fi
211                  if test "x$ac_cv_linux_fs_struct_inode_has_i_dirty_data_buffers" = "xyes"; then 
212                   AC_DEFINE(STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS, 1, [define if you struct inode has data_buffers])
213                  fi
214                 :
215                 fi
216                 ;;
217         *-solaris*)
218                 MKAFS_OSTYPE=SOLARIS
219                 AC_MSG_RESULT(sun4)
220                 SOLARIS_UFSVFS_HAS_DQRWLOCK
221                 SOLARIS_PROC_HAS_P_COREFILE
222                 ;;
223         *-sunos*)
224                 MKAFS_OSTYPE=SUNOS
225                 enable_kernel_module=no
226                 AC_MSG_RESULT(sun4)
227                 ;;
228         *-hpux*)
229                 MKAFS_OSTYPE=HPUX
230                 AC_MSG_RESULT(hp_ux)
231                 ;;
232         *-irix*)
233                 if test -d /usr/include/sys/SN/SN1; then
234                  IRIX_BUILD_IP35="IP35"
235                 fi
236                 MKAFS_OSTYPE=IRIX
237                 AC_MSG_RESULT(sgi)
238                 ;;
239         *-aix*)
240                 MKAFS_OSTYPE=AIX
241                 AC_MSG_RESULT(rs_aix)
242                 ;;
243         *-osf*)
244                 MKAFS_OSTYPE=DUX
245                 AC_MSG_RESULT(alpha_dux)
246                 if test "x$enable_kernel_module" = "xyes"; then
247                  if test "x$with_dux_kernel_headers" != "x"; then
248                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
249                  else
250                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
251                  fi
252                 fi
253                 if test "$HEADER_RT" = "*" ; then
254                         AC_MSG_ERROR([Need a configured kernel directory])
255                 fi
256                 AC_SUBST([HEADER_RT])
257                 ;;
258         *-darwin*)
259                 MKAFS_OSTYPE=DARWIN
260                 AC_MSG_RESULT(ppc_darwin)
261                 ;;
262         *-freebsd*)
263                 MKAFS_OSTYPE=FBSD
264                 AC_MSG_RESULT(i386_fbsd)
265                 ;;
266         *-netbsd*)
267                 MKAFS_OSTYPE=NBSD
268                 AC_MSG_RESULT(nbsd)
269                 ;;
270         *-openbsd*)
271                 MKAFS_OSTYPE=OBSD
272                 AC_MSG_RESULT(i386_obsd)
273                 ;;
274         *)
275                 AC_MSG_RESULT($system)
276                 ;;
277 esac
278 AC_SUBST(KERN_DEBUG_OPT)
279
280 if test "x$with_afs_sysname" != "x"; then
281         AFS_SYSNAME="$with_afs_sysname"
282 else
283         AC_MSG_CHECKING(your AFS sysname)
284         case $host in
285                 i386-unknown-openbsd3.1)
286                         AFS_SYSNAME="i386_obsd31"
287                         ;;
288                 i?86-*-freebsd4.2*)
289                         AFS_SYSNAME="i386_fbsd_42"
290                         ;;
291                 i?86-*-freebsd4.3*)
292                         AFS_SYSNAME="i386_fbsd_43"
293                         ;;
294                 i?86-*-freebsd4.4*)
295                         AFS_SYSNAME="i386_fbsd_44"
296                         ;;
297                 i?86-*-freebsd4.5*)
298                         AFS_SYSNAME="i386_fbsd_45"
299                         ;;
300                 i?86-*-freebsd4.6*)
301                         AFS_SYSNAME="i386_fbsd_46"
302                         ;;
303                 i?86-*-freebsd4.7*)
304                         AFS_SYSNAME="i386_fbsd_47"
305                         ;;
306                 i?86-*-netbsd*1.5*)
307                         AFS_PARAM_COMMON=param.nbsd15.h
308                         AFS_SYSNAME="i386_nbsd15"
309                         ;;
310                 alpha-*-netbsd*1.5*)
311                         AFS_PARAM_COMMON=param.nbsd15.h
312                         AFS_SYSNAME="alpha_nbsd15"
313                         ;;
314                 i?86-*-netbsd*1.6*)
315                         AFS_PARAM_COMMON=param.nbsd16.h
316                         AFS_SYSNAME="i386_nbsd16"
317                         ;;
318                 alpha-*-netbsd*1.6*)
319                         AFS_PARAM_COMMON=param.nbsd16.h
320                         AFS_SYSNAME="alpha_nbsd16"
321                         ;;
322                 hppa*-hp-hpux11*)
323                         AFS_SYSNAME="hp_ux110"
324                         ;;
325                 hppa*-hp-hpux10*)
326                         AFS_SYSNAME="hp_ux102"
327                         ;;
328                 powerpc-apple-darwin1.2*)
329                         AFS_SYSNAME="ppc_darwin_12"
330                         ;;
331                 powerpc-apple-darwin1.3*)
332                         AFS_SYSNAME="ppc_darwin_13"
333                         ;;
334                 powerpc-apple-darwin1.4*)
335                         AFS_SYSNAME="ppc_darwin_14"
336                         ;;
337                 powerpc-apple-darwin5.1*)
338                         AFS_SYSNAME="ppc_darwin_14"
339                         ;;
340                 powerpc-apple-darwin5.2*)
341                         AFS_SYSNAME="ppc_darwin_14"
342                         ;;
343                 powerpc-apple-darwin5.3*)
344                         AFS_SYSNAME="ppc_darwin_14"
345                         ;;
346                 powerpc-apple-darwin5.4*)
347                         AFS_SYSNAME="ppc_darwin_14"
348                         ;;
349                 powerpc-apple-darwin5.5*)
350                         AFS_SYSNAME="ppc_darwin_14"
351                         ;;
352                 powerpc-apple-darwin6.0*)
353                         AFS_SYSNAME="ppc_darwin_60"
354                         ;;
355                 powerpc-apple-darwin6.1*)
356                         AFS_SYSNAME="ppc_darwin_60"
357                         ;;
358                 powerpc-apple-darwin6.2*)
359                         AFS_SYSNAME="ppc_darwin_60"
360                         ;;
361                 sparc-sun-solaris2.5*)
362                         AFS_SYSNAME="sun4x_55"
363                         ;;
364                 sparc-sun-solaris2.6)
365                         AFS_SYSNAME="sun4x_56"
366                         ;;
367                 sparc-sun-solaris2.7)
368                         AFS_SYSNAME="sun4x_57"
369                         ;;
370                 sparc-sun-solaris2.8)
371                         AFS_SYSNAME="sun4x_58"
372                         ;;
373                 sparc-sun-solaris2.9)
374                         AFS_SYSNAME="sun4x_59"
375                         ;;
376                 sparc-sun-sunos4*)
377                         AFS_SYSNAME="sun4_413"
378                         ;;
379                 i386-pc-solaris2.7)
380                         AFS_SYSNAME="sunx86_57"
381                         ;;
382                 i386-pc-solaris2.8)
383                         AFS_SYSNAME="sunx86_58"
384                         ;;
385                 i386-pc-solaris2.9)
386                         AFS_SYSNAME="sunx86_59"
387                         ;;
388                 alpha*-dec-osf4.0*)
389                         AFS_SYSNAME="alpha_dux40"
390                         ;;
391                 alpha*-dec-osf5.0*)
392                         AFS_SYSNAME="alpha_dux50"
393                         ;;
394                 alpha*-dec-osf5.1*)
395                         AFS_SYSNAME="alpha_dux51"
396                         ;;
397                 mips-sgi-irix6.5)
398                         AFS_SYSNAME="sgi_65"
399                         ;;
400                 ia64-*-linux*)
401                         AFS_SYSNAME="ia64_linuxXX"
402                         ;;
403                 powerpc-*-linux*)
404                         AFS_SYSNAME="ppc_linuxXX"
405                         ;;
406                 alpha*-linux*)
407                         AFS_SYSNAME="alpha_linux_XX"
408                         ;;
409                 s390-*-linux*)
410                         AFS_SYSNAME="s390_linuxXX"
411                         ;;
412                 sparc-*-linux*)
413                         AFS_SYSNAME="sparc_linuxXX"
414                         ;;
415                 sparc64-*-linux*)
416                         AFS_SYSNAME="sparc64_linuxXX"
417                         ;;
418                 i?86-*-linux*)
419                         AFS_SYSNAME="i386_linuxXX"
420                         ;;
421                 parisc-*-linux-gnu)
422                         AFS_SYSNAME="parisc_linuxXX"
423                         ;;
424                 power*-ibm-aix4.2*)
425                         AFS_SYSNAME="rs_aix42"
426                         ;;
427                 power*-ibm-aix4.3*)
428                         AFS_SYSNAME="rs_aix42"
429                         ;;
430                 *)
431                         AC_MSG_ERROR(An AFS sysname is required)
432                         exit 1
433                         ;;
434         esac
435         case $AFS_SYSNAME in
436                 *_linux*)
437                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $[]1 $[]2}'`
438                         if test "x${AFS_SYSKVERS}" = "x"; then
439                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
440                         fi
441                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
442                         AFS_SYSNAME="$_AFS_SYSNAME"
443                         ;;
444         esac
445         AC_MSG_RESULT($AFS_SYSNAME)
446 fi
447
448 case $AFS_SYSNAME in
449         *_darwin*)
450                 DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
451                 DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
452                 dnl the test below fails on darwin, even if the CPPFLAGS below
453                 dnl are added. the headers from Kernel.Framework must be used
454                 dnl when KERNEL is defined.
455
456                 dnl really, such a thing isn't guaranteed to work on any 
457                 dnl platform until the kernel cflags from MakefileProto are
458                 dnl known to configure
459                 AC_DEFINE(HAVE_STRUCT_BUF, 1, [define if you have a struct buf])
460                 ;;
461         *)
462 AC_MSG_CHECKING(for definition of struct buf)
463 dnl save_CPPFLAGS="$CPPFLAGS"
464 dnl CPPFLAGS="$CPPFLAGS -DKERNEL -D_KERNEL -D__KERNEL -D__KERNEL__"
465 AC_CACHE_VAL(ac_cv_have_struct_buf, [
466         ac_cv_have_struct_buf=no
467         AC_TRY_COMPILE(
468                 [#include <sys/buf.h>],
469                 [struct buf x;
470                 printf("%d\n", sizeof(x));],
471                 ac_cv_have_struct_buf=yes,)
472         ]
473 )
474 dnl CPPFLAGS="$save_CPPFLAGS"
475 AC_MSG_RESULT($ac_cv_have_struct_buf)
476 if test "$ac_cv_have_struct_buf" = yes; then
477         AC_DEFINE(HAVE_STRUCT_BUF, 1, [define if you have a struct buf])
478 fi
479 ;;
480 esac
481
482
483 AC_CACHE_VAL(ac_cv_sockaddr_len,
484 [
485 AC_MSG_CHECKING([if struct sockaddr has sa_len field])
486 AC_TRY_COMPILE( [#include <sys/types.h>
487 #include <sys/socket.h>],
488 [struct sockaddr *a;
489 a->sa_len=0;], ac_cv_sockaddr_len=yes, ac_cv_sockaddr_len=no)
490 AC_MSG_RESULT($ac_cv_sockaddr_len)])
491 if test "$ac_cv_sockaddr_len" = "yes"; then
492    AC_DEFINE(STRUCT_SOCKADDR_HAS_SA_LEN, 1, [define if you struct sockaddr sa_len])
493 fi
494 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
495         echo Skipping library tests because they confuse Irix.
496 else
497   AC_CHECK_FUNCS(socket)
498
499   if test "$ac_cv_func_socket" = no; then
500     for lib in socket inet; do
501         if test "$HAVE_SOCKET" != 1; then
502                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET, 1, [define if you have socket]))
503         fi
504     done
505   fi
506   
507   AC_CHECK_FUNCS(connect)       
508
509   if test "$ac_cv_func_connect" = no; then
510     for lib in nsl; do
511         if test "$HAVE_CONNECT" != 1; then
512                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT, 1, [define if you have connect]))
513         fi
514     done
515   fi
516
517   AC_CHECK_FUNCS(gethostbyname)
518   if test "$ac_cv_func_gethostbyname" = no; then
519         for lib in dns nsl resolv; do
520           if test "$HAVE_GETHOSTBYNAME" != 1; then
521             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [define if you have gethostbyname]))
522           fi
523         done    
524   fi    
525
526   AC_CHECK_FUNCS(res_search)
527   if test "$ac_cv_func_res_search" = no; then
528         for lib in dns nsl resolv; do
529           if test "$HAVE_RES_SEARCH" != 1; then
530             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH, 1, [define if you have res_search]))
531           fi
532         done    
533         if test "$HAVE_RES_SEARCH" = 1; then
534           LIB_res_search="-l$lib"       
535         fi
536   fi    
537 fi
538
539 PTHREAD_LIBS=error
540 AC_CHECK_LIB(pthread, pthread_attr_init,
541              PTHREAD_LIBS="-lpthread")
542 if test "x$PTHREAD_LIBS" = xerror; then
543         AC_CHECK_LIB(pthreads, pthread_attr_init,
544                 PTHREAD_LIBS="-lpthreads")
545 fi
546 if test "x$PTHREAD_LIBS" = xerror; then
547         AC_CHECK_LIB(c_r, pthread_attr_init,
548                 PTHREAD_LIBS="-lc_r")
549 fi
550 if test "x$PTHREAD_LIBS" = xerror; then
551         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
552 fi
553 if test "x$PTHREAD_LIBS" = xerror; then
554         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
555 fi
556 AC_SUBST(PTHREAD_LIBS)
557
558 WITH_OBSOLETE=NO
559 if test "$enable_obsolete" = "yes"; then
560         WITH_OBSOLETE=YES
561 fi
562
563 WITH_INSECURE=NO
564 if test "$enable_insecure" = "yes"; then
565         WITH_INSECURE=YES
566 fi
567
568 # Fast restart
569 if test "$enable_fast_restart" = "yes"; then
570         AC_DEFINE(FAST_RESTART, 1, [define if you want to have fast restart])
571 fi
572
573 if test "$enable_bitmap_later" = "yes"; then
574         AC_DEFINE(BITMAP_LATER, 1, [define if you want to salvager to check bitmasks later])
575 fi
576
577 if test "$enable_full_vos_listvol_switch" = "yes"; then
578         AC_DEFINE(FULL_LISTVOL_SWITCH, 1, [define if you want to want listvol switch])
579 fi
580
581 if test "$enable_bos_restricted_mode" = "yes"; then
582         AC_DEFINE(BOS_RESTRICTED_MODE, 1, [define if you want to want bos restricted mode])
583 fi
584
585 if test "$enable_bos_new_config" = "yes"; then
586         AC_DEFINE(BOS_NEW_CONFIG, 1, [define if you want to enable automatic renaming of BosConfig.new to BosConfig at startup])
587 fi
588
589 if test "$enable_largefile_fileserver" = "yes"; then
590         AC_DEFINE(AFS_LARGEFILE_ENV)
591 fi
592
593 if test "$enable_namei_fileserver" = "yes"; then
594         AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
595 fi
596
597 if test "$enable_afsdb" = "yes"; then
598         LIB_AFSDB="$LIB_res_search"
599         AC_DEFINE(AFS_AFSDB_ENV, 1, [define if you want to want search afsdb rr])
600 fi
601
602 dnl check for tivoli
603 AC_MSG_CHECKING(for tivoli tsm butc support)
604 XBSA_CFLAGS=""
605 if test "$enable_tivoli_tsm" = "yes"; then
606         XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
607         XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
608
609         if test -e "$XBSADIR1/xbsa.h"; then
610                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
611                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
612         elif test -e "$XBSADIR2/xbsa.h"; then
613                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
614                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
615         else
616                 AC_MSG_RESULT([no, missing xbsa.h header file])
617         fi
618 else
619         AC_MSG_RESULT([no])
620 fi
621 AC_SUBST(XBSA_CFLAGS)
622
623 dnl checks for header files.
624 AC_HEADER_STDC
625 AC_HEADER_SYS_WAIT
626 AC_HEADER_DIRENT
627 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
628 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
629 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
630 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
631 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
632 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h ucontext.h)
633
634 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
635 AC_CHECK_FUNCS(setprogname getprogname sigaction)
636 AC_CHECK_TYPE(ssize_t, int)
637 AC_SIZEOF_TYPE(long)
638
639 AC_CHECK_FUNCS(timegm)
640
641 dnl Directory PATH handling
642 if test "x$enable_transarc_paths" = "xyes"  ; then 
643     afsconfdir=${afsconfdir=/usr/afs/etc}
644     viceetcdir=${viceetcdir=/usr/vice/etc}
645     afskerneldir=${afskerneldir=${viceetcdir}}
646     afssrvbindir=${afssrvbindir=/usr/afs/bin}
647     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
648     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
649     afsdbdir=${afsdbdir=/usr/afs/db}
650     afslogsdir=${afslogsdir=/usr/afs/logs}
651     afslocaldir=${afslocaldir=/usr/afs/local}
652     afsbackupdir=${afsbackupdir=/usr/afs/backup}
653     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
654 else 
655     afsconfdir=${afsconfdir='${sysconfdir}/openafs/server'}
656     viceetcdir=${viceetcdir='${sysconfdir}/openafs'}
657     afskerneldir=${afskerneldir='${libdir}/openafs'}
658     afssrvbindir=${afssrvbindir='${bindir}'}
659     afssrvsbindir=${afssrvsbindir='${sbindir}'}
660     afssrvlibexecdir=${afssrvlibexecdir='${libexecdir}/openafs'}
661     afsdbdir=${afsdbdir='${localstatedir}/openafs/db'}
662     afslogsdir=${afslogsdir='${localstatedir}/openafs/logs'}
663     afslocaldir=${afslocaldir='${localstatedir}/openafs'}
664     afsbackupdir=${afsbackupdir='${localstatedir}/openafs/backup'}
665     afsbosconfigdir=${afsbosconfigdir='${sysconfdir}/openafs'}
666 fi
667 AC_SUBST(afsconfdir)
668 AC_SUBST(viceetcdir)
669 AC_SUBST(afskerneldir)
670 AC_SUBST(afssrvbindir)
671 AC_SUBST(afssrvsbindir)
672 AC_SUBST(afssrvlibexecdir)
673 AC_SUBST(afsdbdir)
674 AC_SUBST(afslogsdir)
675 AC_SUBST(afslocaldir)
676 AC_SUBST(afsbackupdir)
677 AC_SUBST(afsbosconfigdir)
678
679 if test "x$enable_kernel_module" = "xyes"; then
680 ENABLE_KERNEL_MODULE=libafs
681 fi
682
683 AC_SUBST(AFS_SYSNAME)
684 AC_SUBST(AFS_PARAM_COMMON)
685 AC_SUBST(ENABLE_KERNEL_MODULE)
686 AC_SUBST(LIB_AFSDB)
687 AC_SUBST(LINUX_KERNEL_PATH)
688 AC_SUBST(LINUX_VERSION)
689 AC_SUBST(MKAFS_OSTYPE)
690 AC_SUBST(TOP_OBJDIR)
691 AC_SUBST(TOP_SRCDIR)
692 AC_SUBST(TOP_INCDIR)
693 AC_SUBST(TOP_LIBDIR)
694 AC_SUBST(DEST)
695 AC_SUBST(WITH_OBSOLETE)
696 AC_SUBST(WITH_INSECURE)
697 AC_SUBST(DARWIN_INFOFILE)
698 AC_SUBST(IRIX_BUILD_IP35)
699
700 OPENAFS_OSCONF
701
702 TOP_SRCDIR="${srcdir}/src"
703 dnl
704 dnl If we're using ./configure, need a more reasonable TOP_SRCDIR, since relative links don't work everywhere
705 dnl
706 case $TOP_SRCDIR in
707         /*)
708                 ;;
709         *)
710                 TOP_SRCDIR=${SRCDIR_PARENT}/src
711 esac
712
713 TOP_OBJDIR="${SRCDIR_PARENT}"
714 TOP_INCDIR="${SRCDIR_PARENT}/include"
715 TOP_LIBDIR="${SRCDIR_PARENT}/lib"
716 if test "${DEST}x" = "x"; then
717         DEST="${SRCDIR_PARENT}/${AFS_SYSNAME}/dest"
718 fi
719
720
721 ])