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