Fix aklog segfault
[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 AH_BOTTOM([
9 #undef HAVE_RES_SEARCH
10 #undef STRUCT_SOCKADDR_HAS_SA_LEN
11 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
12 # if ENDIANESS_IN_SYS_PARAM_H
13 #  ifndef KERNEL
14 #   include <sys/types.h>
15 #   include <sys/param.h>
16 #   if BYTE_ORDER == BIG_ENDIAN
17 #   define WORDS_BIGENDIAN 1
18 #   endif
19 #  else
20 #   if defined(AUTOCONF_FOUND_BIGENDIAN)
21 #    define WORDS_BIGENDIAN 1
22 #   else
23 #    undef WORDS_BIGENDIAN
24 #   endif
25 #  endif
26 # else
27 #  if defined(AUTOCONF_FOUND_BIGENDIAN)
28 #   define WORDS_BIGENDIAN 1
29 #  else
30 #   undef WORDS_BIGENDIAN
31 #  endif
32 # endif
33 #else
34 # if defined(__BIG_ENDIAN__)
35 #  define WORDS_BIGENDIAN 1
36 # else
37 #  undef WORDS_BIGENDIAN
38 # endif
39 #endif
40 #ifdef UKERNEL
41 /*
42  * Always use 64-bit file offsets for UKERNEL code. Needed for UKERNEL stuff to
43  * play nice with some other interfaces like FUSE. We technically only would
44  * need to define this when building for such interfaces, but set it always to
45  * try and reduce potential confusion. 
46  */
47 #define _FILE_OFFSET_BITS 64
48 #define AFS_CACHE_VNODE_PATH
49 #endif
50
51 #undef AFS_NAMEI_ENV
52 #undef BITMAP_LATER
53 #undef FAST_RESTART
54 #undef DEFINED_FOR_EACH_PROCESS
55 #undef DEFINED_PREV_TASK
56 #undef EXPORTED_SYS_CALL_TABLE
57 #undef EXPORTED_IA32_SYS_CALL_TABLE
58 #undef IRIX_HAS_MEM_FUNCS
59 #undef RECALC_SIGPENDING_TAKES_VOID
60 #undef STRUCT_FS_HAS_FS_ROLLED
61 #undef ssize_t
62 #undef HAVE_ARPA_NAMESER_COMPAT_H
63 /* glue for RedHat kernel bug */
64 #undef ENABLE_REDHAT_BUILDSYS
65 #if defined(ENABLE_REDHAT_BUILDSYS) && defined(KERNEL) && defined(REDHAT_FIX)
66 #include "redhat-fix.h"
67 #endif])
68
69 AC_CANONICAL_HOST
70 SRCDIR_PARENT=`pwd`
71
72 #BOZO_SAVE_CORES pam
73
74 dnl System identity.
75 AC_ARG_WITH([afs-sysname],
76     [AS_HELP_STRING([--with-afs-sysname=sys], [use sys for the afs sysname])])
77
78 dnl General feature options.
79 AC_ARG_ENABLE([pam],
80     [AS_HELP_STRING([--disable-pam], [disable PAM support])],
81     ,
82     [enable_pam="yes"])
83 AC_ARG_ENABLE([namei-fileserver],
84     [AS_HELP_STRING([--enable-namei-fileserver],
85         [force compilation of namei fileserver in preference to inode
86          fileserver])],
87     , 
88     [enable_namei_fileserver="default"])
89 AC_ARG_ENABLE([cache-bypass],
90     [AS_HELP_STRING([--enable-cache-bypass],
91         [enable client support for cache bypass])],
92     , 
93     [enable_cache_bypass="no"])
94 AC_ARG_ENABLE([supergroups],
95     [AS_HELP_STRING([--enable-supergroups],
96         [enable support for nested pts groups])],
97     , 
98     [enable_supergroups="no"])
99 AC_ARG_ENABLE([fast-restart],
100     [AS_HELP_STRING([--enable-fast-restart],
101         [enable fast startup of file server without salvaging])],
102     , 
103     [enable_fast_restart="no"])
104 AC_ARG_ENABLE([bitmap-later],
105     [AS_HELP_STRING([--enable-bitmap-later],
106         [enable fast startup of file server by not reading bitmap till
107          needed])],
108     , 
109     [enable_bitmap_later="no"])
110 AC_ARG_ENABLE([demand-attach-fs],
111     [AS_HELP_STRING([--enable-demand-attach-fs],
112         [enable Demand Attach Fileserver (please see documentation)])],
113     , 
114     [enable_demand_attach_fs="no"])
115 AC_ARG_ENABLE([disconnected],
116     [AS_HELP_STRING([--enable-disconnected],
117         [enable disconnected support in cache manager (experimental)])],
118     , 
119     [enable_disconnected="no"])
120 AC_ARG_ENABLE([unix-sockets],
121     [AS_HELP_STRING([--enable-unix-sockets],
122         [enable use of unix domain sockets for fssync])],
123     ,
124     [enable_unix_sockets="yes"])
125 AC_ARG_ENABLE([icmp-pmtu-discovery],
126     [AS_HELP_STRING([--enable-icmp-pmtu-discovery],
127         [enable path MTU discovery by decoding ICMP unreachable replies])],
128     , 
129     [enable_icmp_pmtu_discovery="no"])
130 AC_ARG_ENABLE([tivoli-tsm],
131     [AS_HELP_STRING([--enable-tivoli-tsm],
132         [enable use of the Tivoli TSM API libraries for butc support])],
133     , 
134     [enable_tivoli_tsm="no"])
135 AC_ARG_ENABLE([pthreaded-ubik],
136     [AS_HELP_STRING([--enable-pthreaded-ubik],
137         [enable installation of pthreaded ubik applications (defaults to
138          disabled)])],
139     ,
140     [enable_pthreaded_ubik="no"])
141
142 dnl Kernel module build options.
143 AC_ARG_WITH([linux-kernel-headers],
144     [AS_HELP_STRING([--with-linux-kernel-headers=path],
145         [use the kernel headers found at path (optional, defaults to
146          /usr/src/linux-2.4, then /usr/src/linux)])])
147 AC_ARG_WITH([linux-kernel-build],
148     [AS_HELP_STRING([--with-linux-kernel-build=path],
149         [use the kernel build found at path(optional, defaults to 
150         /usr/src/linux-2.4, then /usr/src/linux)])])
151 AC_ARG_WITH([bsd-kernel-headers],
152     [AS_HELP_STRING([--with-bsd-kernel-headers=path],
153         [use the kernel headers found at path (optional, defaults to
154          /usr/src/sys)])])
155 AC_ARG_WITH([bsd-kernel-build],
156     [AS_HELP_STRING([--with-bsd-kernel-build=path], 
157         [use the kernel build found at path (optional, defaults to
158          KSRC/i386/compile/GENERIC)])])
159 AC_ARG_WITH([linux-kernel-packaging],
160     [AS_HELP_STRING([--with-linux-kernel-packaging],
161         [use standard naming conventions to aid Linux kernel build packaging
162          (disables MPS, sets the kernel module name to openafs.ko, and
163          installs kernel modules into the standard Linux location)])],
164     [AC_SUBST(LINUX_KERNEL_PACKAGING, "yes")
165      AC_SUBST(LINUX_LIBAFS_NAME, "openafs")],
166     [AC_SUBST(LINUX_LIBAFS_NAME, "libafs")])
167 AC_ARG_ENABLE([kernel-module],
168     [AS_HELP_STRING([--disable-kernel-module],
169         [disable compilation of the kernel module (defaults to enabled)])],
170     , 
171     [enable_kernel_module="yes"])
172 AC_ARG_ENABLE([redhat-buildsys],
173     [AS_HELP_STRING([--enable-redhat-buildsys],
174         [enable compilation of the redhat build system kernel (defaults to
175          disabled)])],
176     ,
177     [enable_redhat_buildsys="no"])
178
179 dnl Installation locations.
180 AC_ARG_ENABLE([transarc-paths],
181     [AS_HELP_STRING([--enable-transarc-paths],
182         [use Transarc style paths like /usr/afs and /usr/vice])],
183     , 
184     [enable_transarc_paths="no"])
185
186 dnl Optimization and debugging flags.
187 AC_ARG_ENABLE([strip-binaries],
188     [AS_HELP_STRING([--disable-strip-binaries],
189         [disable stripping of symbol information from binaries (defaults to
190          enabled)])],
191     ,
192     [enable_strip_binaries="maybe"])
193 AC_ARG_ENABLE([debug],
194     [AS_HELP_STRING([--enable-debug],
195         [enable compilation of the user space code with debugging information
196          (defaults to disabled)])],
197     , 
198     [enable_debug="no"])
199 AC_ARG_ENABLE([optimize],
200     [AS_HELP_STRING([--disable-optimize],
201         [disable optimization for compilation of the user space code (defaults
202          to enabled)])],
203     , 
204     [enable_optimize="yes"])
205 AC_ARG_ENABLE([warnings],
206     [AS_HELP_STRING([--enable-warnings],
207         [enable compilation warnings when building with gcc (defaults to
208          disabled)])],
209     ,
210     [enable_warnings="no"])
211 AC_ARG_ENABLE([checking],
212     [AS_HELP_STRING([--enable-checking],
213         [turn compilation warnings into errors when building with gcc (defaults
214          to disabled)])],
215     [enable_checking="$enableval"],
216     [enable_checking="no"])
217 AC_ARG_ENABLE([debug-kernel],
218     [AS_HELP_STRING([--enable-debug-kernel],
219         [enable compilation of the kernel module with debugging information
220          (defaults to disabled)])],
221     ,
222     [enable_debug_kernel="no"])
223 AC_ARG_ENABLE([optimize-kernel],
224     [AS_HELP_STRING([--disable-optimize-kernel],
225         [disable compilation of the kernel module with optimization (defaults
226          based on platform)])],
227     , 
228     [enable_optimize_kernel="yes"])
229 AC_ARG_ENABLE([debug-lwp],
230     [AS_HELP_STRING([--enable-debug-lwp],
231         [enable compilation of the LWP code with debugging information
232          (defaults to disabled)])],
233     ,
234     [enable_debug_lwp="no"])
235 AC_ARG_ENABLE([optimize-lwp],
236     [AS_HELP_STRING([--disable-optimize-lwp],
237         [disable optimization for compilation of the LWP code (defaults to
238          enabled)])],
239     ,
240     [enable_optimize_lwp="yes"])
241 AC_ARG_ENABLE([debug-pam],
242     [AS_HELP_STRING([--enable-debug-pam],
243         [enable compilation of the PAM code with debugging information
244          (defaults to disabled)])],
245     ,
246     [enable_debug_pam="no"])
247 AC_ARG_ENABLE([optimize-pam],
248     [AS_HELP_STRING([--disable-optimize-pam],
249         [disable optimization for compilation of the PAM code (defaults to
250          enabled)])],
251     ,
252     [enable_optimize_pam="yes"])
253 AC_ARG_ENABLE([linux-syscall-probing],
254     [AS_HELP_STRING([--enable-linux-syscall-probing],
255         [enable Linux syscall probing (defaults to autodetect)])],
256     ,
257     [enable_linux_syscall_probing="maybe"])
258     
259
260 AC_ARG_WITH([xslt-processor],
261         AS_HELP_STRING([--with-xslt-processor=ARG],
262         [which XSLT processor to use (possible choices are: libxslt, saxon, xalan-j, xsltproc)]),
263         XSLTPROC="$withval",
264         XSLTPROC="libxslt")
265
266 AC_ARG_WITH([html-xsl], 
267         AS_HELP_STRING([--with-html-xsl],
268         [build HTML documentation using Norman Walsh's DocBook XSL stylesheets (default is no; specify a path to chunk.xsl or docbook.xsl)]),
269         HTML_XSL="$withval",
270         HTML_XSL=no)
271
272 enable_login="no"
273
274 dnl weird ass systems
275 dnl AC_AIX
276 AC_ISC_POSIX
277 dnl AC_MINIX
278
279 dnl Various compiler setup.
280 AC_TYPE_PID_T
281 AC_TYPE_SIZE_T
282
283 dnl Checks for programs.
284 AC_PROG_INSTALL
285 AC_PROG_LN_S
286 AC_PROG_RANLIB
287 AC_PROG_YACC
288 AM_PROG_LEX
289
290 OPENAFS_CHECK_BIGENDIAN
291 OPENAFS_PRINTF_TAKES_Z_LEN
292
293 AC_MSG_CHECKING(your OS)
294 system=$host
295 case $system in
296         *-linux*)
297
298                 MKAFS_OSTYPE=LINUX
299                 if test "x$enable_redhat_buildsys" = "xyes"; then
300                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS, 1, [define if you have redhat buildsystem])
301                 fi
302                 if test "x$enable_kernel_module" = "xyes"; then
303                  if test "x$with_linux_kernel_headers" != "x"; then
304                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
305                  else
306                    LINUX_KERNEL_PATH="/lib/modules/`uname -r`/source"
307                    if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
308                      LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build"
309                    fi
310                    if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
311                      LINUX_KERNEL_PATH="/usr/src/linux-2.4"
312                    fi
313                    if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
314                      LINUX_KERNEL_PATH="/usr/src/linux"
315                    fi
316                  fi
317                  if test "x$with_linux_kernel_build" != "x"; then
318                          LINUX_KERNEL_BUILD="$with_linux_kernel_build"
319                  else
320                    LINUX_KERNEL_BUILD=$LINUX_KERNEL_PATH
321                  fi
322                  if test -f "$LINUX_KERNEL_BUILD/include/generated/utsrelease.h"; then
323                    linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/generated/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
324                    LINUX_VERSION="$linux_kvers"
325                  else
326                    if test -f "$LINUX_KERNEL_BUILD/include/linux/utsrelease.h"; then
327                      linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
328                      LINUX_VERSION="$linux_kvers"
329                    else
330                      if test -f "$LINUX_KERNEL_BUILD/include/linux/version.h"; then
331                        linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
332                        if test "x$linux_kvers" = "x"; then
333                          if test -f "$LINUX_KERNEL_BUILD/include/linux/version-up.h"; then
334                            linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
335                            if test "x$linux_kvers" = "x"; then
336                              AC_MSG_ERROR(Linux headers lack version definition [2])
337                              exit 1
338                            else
339                              LINUX_VERSION="$linux_kvers"
340                            fi
341                          else
342                            AC_MSG_ERROR(Linux headers lack version definition)
343                            exit 1
344                          fi
345                        else
346                          LINUX_VERSION="$linux_kvers"
347                        fi
348                      else
349                        enable_kernel_module="no"
350                      fi
351                    fi
352                  fi
353                  if test ! -f "$LINUX_KERNEL_BUILD/include/generated/autoconf.h" &&
354                     test ! -f "$LINUX_KERNEL_BUILD/include/linux/autoconf.h"; then
355                      enable_kernel_module="no"
356                  fi
357                  if test "x$enable_kernel_module" = "xno"; then
358                   if test "x$with_linux_kernel_headers" != "x"; then
359                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
360                    exit 1
361                   else
362                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
363                   fi
364                  fi
365                  dnl do we need to determine SUBARCH from autoconf.h
366                  SUBARCH=default
367                 fi
368                 AC_MSG_RESULT(linux)
369                 if test "x$enable_kernel_module" = "xyes"; then
370                  AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $[]1 $[]2}'`
371                  if test "x${AFS_SYSKVERS}" = "x"; then
372                   AC_MSG_ERROR(Couldn't guess your Linux version [2])
373                  fi
374                 fi
375                 ;;
376         *-solaris*)
377                 MKAFS_OSTYPE=SOLARIS
378                 AC_MSG_RESULT(sun4)
379                 AC_PATH_PROG(SOLARISCC, [cc], ,
380                     [/opt/SUNWspro/bin:/opt/SunStudioExpress/bin])
381                 SOLARIS_UFSVFS_HAS_DQRWLOCK
382                 SOLARIS_FS_HAS_FS_ROLLED
383                 SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS
384                 ;;
385         *-sunos*)
386                 MKAFS_OSTYPE=SUNOS
387                 enable_kernel_module=no
388                 AC_MSG_RESULT(sun4)
389                 ;;
390         *-hpux*)
391                 MKAFS_OSTYPE=HPUX
392                 AC_MSG_RESULT(hp_ux)
393                 if test -f "/usr/old/usr/include/ndir.h"; then
394                  AC_DEFINE(HAVE_USR_OLD_USR_INCLUDE_NDIR_H, 1, [define if you have old ndir.h])
395                 fi
396                 ;;
397         *-irix*)
398                 if test -d /usr/include/sys/SN/SN1; then
399                  IRIX_BUILD_IP35="IP35"
400                 fi
401                 MKAFS_OSTYPE=IRIX
402                 AC_MSG_RESULT(sgi)
403                 ;;
404         *-aix*)
405                 MKAFS_OSTYPE=AIX
406                 AC_MSG_RESULT(rs_aix)
407                 ;;
408         arm-*-darwin*)
409                 MKAFS_OSTYPE=DARWIN
410                 AC_MSG_RESULT(arm_darwin)
411                 ;;
412         powerpc-*-darwin*)
413                 MKAFS_OSTYPE=DARWIN
414                 AC_MSG_RESULT(ppc_darwin)
415                 ;;
416         i386-*-darwin*)
417                 MKAFS_OSTYPE=DARWIN
418                 AC_MSG_RESULT(x86_darwin)
419                 ;;
420         i386-*-freebsd*)
421                 MKAFS_OSTYPE=FBSD
422                 AC_MSG_RESULT(i386_fbsd)
423                 ;;
424         x86_64-*-freebsd*)
425                 MKAFS_OSTYPE=FBSD
426                 AC_MSG_RESULT(amd64_fbsd)
427                 ;;
428         *-netbsd*)
429                 MKAFS_OSTYPE=NBSD
430                 AC_MSG_RESULT(nbsd)
431                 ;;
432         x86_64-*-openbsd*)
433                 MKAFS_OSTYPE=OBSD
434                 AC_MSG_RESULT(amd64_obsd)
435                 ;;
436         i386-*-openbsd*)
437                 MKAFS_OSTYPE=OBSD
438                 AC_MSG_RESULT(i386_obsd)
439                 ;;
440         *-dragonfly*)
441                 MKAFS_OSTYPE=DFBSD
442                 AC_MSG_RESULT(i386_dfbsd)
443                 ;;
444         *)
445                 AC_MSG_RESULT($system)
446                 ;;
447 esac
448
449 if test "x$with_afs_sysname" != "x"; then
450         AFS_SYSNAME="$with_afs_sysname"
451 else
452         AC_MSG_CHECKING(your AFS sysname)
453         case $host in
454                 i?86-*-openbsd?.?)
455                         v=${host#*openbsd}
456                         vM=${v%.*}
457                         vm=${v#*.}
458                         AFS_SYSNAME="i386_obsd${vM}${vm}"
459                         ;;
460                 sparc64-*-openbsd?.?)
461                         v=${host#*openbsd}
462                         vM=${v%.*}
463                         vm=${v#*.}
464                         AFS_SYSNAME="sparc64_obsd${vM}${vm}"
465                         ;;
466                 x86_64-*-openbsd?.?)
467                         v=${host#*openbsd}
468                         vM=${v%.*}
469                         vm=${v#*.}
470                         AFS_SYSNAME="amd64_obsd${vM}${vm}"
471                         ;;
472                 i?86-*-freebsd?.*)
473                         v=${host#*freebsd}
474                         vM=${v%.*}
475                         vm=${v#*.}
476                         AFS_SYSNAME="i386_fbsd_${vM}${vm}"
477                         ;;
478                 x86_64-*-freebsd?.*)
479                         v=${host#*freebsd}
480                         vM=${v%.*}
481                         vm=${v#*.}
482                         AFS_SYSNAME="amd64_fbsd_${vM}${vm}"
483                         ;;
484                 i386-*-dragonfly2.2*)
485                         AFS_SYSNAME="i386_dfbsd_23"
486                         ;;
487                 i386-*-dragonfly2.3*)
488                         AFS_SYSNAME="i386_dfbsd_23"
489                         ;;
490                 i?86-*-netbsd*1.6[[M-Z]]*)
491                         AFS_SYSNAME="i386_nbsd20"
492                         ;;
493                 powerpc-*-netbsd*1.6[[M-Z]]*)
494                         AFS_SYSNAME="ppc_nbsd20"
495                         ;;
496                 *-*-netbsd*)
497                         arch=${host%%-unknown*}
498                         arch=$(echo $arch |sed -e 's/x86_64/amd64/g' \
499                                                -e 's/powerpc/ppc/g')
500                         v=${host#*netbsd}
501                         v=${v#*aout}
502                         v=${v#*ecoff}
503                         v=${v#*elf}
504                         vM=${v%%.*}
505                         vM=${vM%.*}
506                         v=${v#*.}
507                         vm=${v%%.*}
508                         vm=${vm%.*}
509                         vm=${vm%%[[_A-Z]]*}
510                         if test $vm -eq 99 ; then
511                                 vM=$((vM+1))
512                         fi
513                         if test $vM -gt 1 ; then
514                                 vm=0
515                         fi
516                         AFS_SYSNAME="${arch}_nbsd${vM}${vm}"
517                         ;;
518                 hppa*-hp-hpux11.0*)
519                         AFS_SYSNAME="hp_ux110"
520                         ;;
521                 hppa*-hp-hpux11.11)
522                         AFS_SYSNAME="hp_ux11i"
523                         ;;
524                 hppa*-hp-hpux11.23)
525                         AFS_SYSNAME="hp_ux1123"
526                         ;;
527                 ia64-hp-hpux11.22)
528                         AFS_SYSNAME="ia64_hpux1122"
529                         ;;
530                 ia64-hp-hpux*)
531                         AFS_SYSNAME="ia64_hpux1123"
532                         ;;
533                 hppa*-hp-hpux10*)
534                         AFS_SYSNAME="hp_ux102"
535                         ;;
536                 powerpc-apple-darwin7*)
537                         AFS_SYSNAME="ppc_darwin_70"
538                         ;;
539                 powerpc-apple-darwin8.*)
540                         AFS_SYSNAME="ppc_darwin_80"
541                         ;;
542                 i386-apple-darwin8.*)
543                         AFS_SYSNAME="x86_darwin_80"
544                         ;;
545                 powerpc-apple-darwin9.*)
546                         AFS_SYSNAME="ppc_darwin_90"
547                         ;;
548                 i386-apple-darwin9.*)
549                         AFS_SYSNAME="x86_darwin_90"
550                         ;;
551                 i?86-apple-darwin10.*)
552                         AFS_SYSNAME="x86_darwin_100"
553                         ;;
554                 sparc-sun-solaris2.5*)
555                         AFS_SYSNAME="sun4x_55"
556                         enable_login="yes"
557                         ;;
558                 sparc-sun-solaris2.6)
559                         AFS_SYSNAME="sun4x_56"
560                         ;;
561                 sparc-sun-solaris2.7)
562                         AFS_SYSNAME="sun4x_57"
563                         ;;
564                 sparc-sun-solaris2.8)
565                         AFS_SYSNAME="sun4x_58"
566                         ;;
567                 sparc-sun-solaris2.9)
568                         AFS_SYSNAME="sun4x_59"
569                         ;;
570                 sparc-sun-solaris2.10)
571                         AFS_SYSNAME="sun4x_510"
572                         ;;
573                 sparc-sun-solaris2.11)
574                         AFS_SYSNAME="sun4x_511"
575                         ;;
576                 sparc-sun-sunos4*)
577                         AFS_SYSNAME="sun4_413"
578                         enable_login="yes"
579                         ;;
580                 i386-pc-solaris2.7)
581                         AFS_SYSNAME="sunx86_57"
582                         ;;
583                 i386-pc-solaris2.8)
584                         AFS_SYSNAME="sunx86_58"
585                         ;;
586                 i386-pc-solaris2.9)
587                         AFS_SYSNAME="sunx86_59"
588                         ;;
589                 i386-pc-solaris2.10)
590                         AFS_SYSNAME="sunx86_510"
591                         ;;
592                 i386-pc-solaris2.11)
593                         AFS_SYSNAME="sunx86_511"
594                         ;;
595                 alpha*-dec-osf4.0*)
596                         AFS_SYSNAME="alpha_dux40"
597                         ;;
598                 alpha*-dec-osf5.0*)
599                         AFS_SYSNAME="alpha_dux50"
600                         ;;
601                 alpha*-dec-osf5.1*)
602                         AFS_SYSNAME="alpha_dux51"
603                         ;;
604                 mips-sgi-irix6.5)
605                         AFS_SYSNAME="sgi_65"
606                         ;;
607                 ia64-*-linux*)
608                         AFS_SYSNAME="ia64_linuxXX"
609                         ;;
610                 powerpc-*-linux*)
611                         AFS_SYSNAME="`/bin/arch`_linuxXX"
612                         ;;
613                 powerpc64-*-linux*)
614                         AFS_SYSNAME="ppc64_linuxXX"
615                         ;;
616                 alpha*-linux*)
617                         AFS_SYSNAME="alpha_linux_XX"
618                         ;;
619                 s390-*-linux*)
620                         AFS_SYSNAME="s390_linuxXX"
621                         ;;
622                 s390x-*-linux*)
623                         AFS_SYSNAME="s390x_linuxXX"
624                         ;;
625                 sparc-*-linux*)
626                         AFS_SYSNAME="`/bin/arch`_linuxXX"
627                         ;;
628                 sparc64-*-linux*)
629                         AFS_SYSNAME="sparc64_linuxXX"
630                         ;;
631                 i?86-*-linux*)
632                         AFS_SYSNAME="i386_linuxXX"
633                         ;;
634                 arm*-linux*)
635                         AFS_SYSNAME="arm_linuxXX"
636                         ;;
637                 parisc-*-linux-gnu|hppa-*-linux-gnu)
638                         AFS_SYSNAME="parisc_linuxXX"
639                         enable_pam="no"
640                         ;;
641                 power*-ibm-aix4.2*)
642                         AFS_SYSNAME="rs_aix42"
643                         enable_pam="no"
644                         ;;
645                 power*-ibm-aix4.3*)
646                         AFS_SYSNAME="rs_aix42"
647                         enable_pam="no"
648                         ;;
649                 power*-ibm-aix5.1*)
650                         AFS_SYSNAME="rs_aix51"
651                         enable_pam="no"
652                         ;;
653                 power*-ibm-aix5.2*)
654                         AFS_SYSNAME="rs_aix52"
655                         enable_pam="no"
656                         ;;
657                 power*-ibm-aix5.3*)
658                         AFS_SYSNAME="rs_aix53"
659                         enable_pam="no"
660                         ;;
661                 power*-ibm-aix6.1*)
662                         AFS_SYSNAME="rs_aix61"
663                         enable_pam="no"
664                         ;;
665                 x86_64-*-linux-gnu)
666                         AFS_SYSNAME="amd64_linuxXX"
667                         enable_pam="yes"
668                         ;;
669                 *)
670                         AC_MSG_ERROR(An AFS sysname is required)
671                         exit 1
672                         ;;
673         esac
674         case $AFS_SYSNAME in
675                 *_linux* | *_umlinux*)
676                         if test "x${AFS_SYSKVERS}" = "x"; then
677                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
678                         fi
679                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
680                         AFS_SYSNAME="$_AFS_SYSNAME"
681                         AC_TRY_KBUILD(
682                          [],
683                          [#ifndef CONFIG_USERMODE
684                           #error not UML
685                           #endif],
686                          ac_cv_linux_is_uml=yes,)
687                         if test "${ac_cv_linux_is_uml}" = yes; then
688                          _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/linux/umlinux/`
689                         fi
690                         AFS_SYSNAME="$_AFS_SYSNAME"
691                         ;;
692         esac
693         AC_MSG_RESULT($AFS_SYSNAME)
694 fi
695
696 case $AFS_SYSNAME in
697         *_darwin*)
698                 AC_CHECK_HEADERS(crt_externs.h)
699                 DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
700                 DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
701                 ;;
702 esac
703
704 dnl Some hosts have a separate common param file they should include.  Figure
705 dnl out if we're on one of them now that we know the sysname.
706 case $AFS_SYSNAME in
707     *_nbsd15)   AFS_PARAM_COMMON=param.nbsd15.h  ;;
708     *_nbsd16)   AFS_PARAM_COMMON=param.nbsd16.h  ;;
709     *_nbsd20)   AFS_PARAM_COMMON=param.nbsd20.h  ;;
710     *_nbsd21)   AFS_PARAM_COMMON=param.nbsd21.h  ;;
711     *_nbsd30)   AFS_PARAM_COMMON=param.nbsd30.h  ;;
712     *_nbsd40)   AFS_PARAM_COMMON=param.nbsd40.h  ;;
713     *_nbsd50)   AFS_PARAM_COMMON=param.nbsd50.h  ;;
714     *_obsd31)   AFS_PARAM_COMMON=param.obsd31.h  ;;
715     *_obsd32)   AFS_PARAM_COMMON=param.obsd32.h  ;;
716     *_obsd33)   AFS_PARAM_COMMON=param.obsd33.h  ;;
717     *_obsd34)   AFS_PARAM_COMMON=param.obsd34.h  ;;
718     *_obsd35)   AFS_PARAM_COMMON=param.obsd35.h  ;;
719     *_obsd36)   AFS_PARAM_COMMON=param.obsd36.h  ;;
720     *_obsd37)   AFS_PARAM_COMMON=param.obsd37.h  ;;
721     *_obsd38)   AFS_PARAM_COMMON=param.obsd38.h  ;;
722     *_obsd39)   AFS_PARAM_COMMON=param.obsd39.h  ;;
723     *_obsd40)   AFS_PARAM_COMMON=param.obsd40.h  ;;
724     *_obsd41)   AFS_PARAM_COMMON=param.obsd41.h  ;;
725     *_obsd42)   AFS_PARAM_COMMON=param.obsd42.h  ;;
726     *_obsd43)   AFS_PARAM_COMMON=param.obsd43.h  ;;
727     *_obsd44)   AFS_PARAM_COMMON=param.obsd44.h  ;;
728     *_obsd45)   AFS_PARAM_COMMON=param.obsd45.h  ;;
729     *_obsd46)   AFS_PARAM_COMMON=param.obsd46.h  ;;
730     *_linux22)  AFS_PARAM_COMMON=param.linux22.h ;;
731     *_linux24)  AFS_PARAM_COMMON=param.linux24.h ;;
732     *_linux26)  AFS_PARAM_COMMON=param.linux26.h ;;
733 # Linux alpha adds an extra underscore for no good reason.
734     *_linux_22) AFS_PARAM_COMMON=param.linux22.h ;;
735     *_linux_24) AFS_PARAM_COMMON=param.linux24.h ;;
736     *_linux_26) AFS_PARAM_COMMON=param.linux26.h ;;
737 esac
738
739 case $AFS_SYSNAME in *_linux* | *_umlinux*)
740
741                 # Add (sub-) architecture-specific paths needed by conftests
742                 case $AFS_SYSNAME  in
743                         *_umlinux26)
744                                 UMLINUX26_FLAGS="-I$LINUX_KERNEL_PATH/arch/um/include"
745                                 UMLINUX26_FLAGS="$UMLINUX26_FLAGS -I$LINUX_KERNEL_PATH/arch/um/kernel/tt/include"
746                                 UMLINUX26_FLAGS="$UMLINUX26_FLAGS -I$LINUX_KERNEL_PATH/arch/um/kernel/skas/include"
747                                 CPPFLAGS="$CPPFLAGS $UMLINUX26_FLAGS"
748                 esac
749
750                 if test "x$enable_kernel_module" = "xyes"; then
751                  if test "x$enable_debug_kernel" = "xno"; then
752                         LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -fomit-frame-pointer"
753                  fi
754                  OPENAFS_GCC_SUPPORTS_MARCH
755                  AC_SUBST(P5PLUS_KOPTS)
756                  OPENAFS_GCC_NEEDS_NO_STRENGTH_REDUCE
757                  OPENAFS_GCC_NEEDS_NO_STRICT_ALIASING
758                  OPENAFS_GCC_SUPPORTS_NO_COMMON
759                  OPENAFS_GCC_SUPPORTS_PIPE
760                  AC_SUBST(LINUX_GCC_KOPTS)
761
762                  dnl Setup the kernel build environment
763                  LINUX_KBUILD_USES_EXTRA_CFLAGS
764                  LINUX_KERNEL_COMPILE_WORKS
765
766                  dnl Check for header files
767                  AC_CHECK_LINUX_HEADER([config.h])
768                  AC_CHECK_LINUX_HEADER([completion.h])
769                  AC_CHECK_LINUX_HEADER([exportfs.h])
770                  AC_CHECK_LINUX_HEADER([freezer.h])
771                  AC_CHECK_LINUX_HEADER([key-type.h])
772                  AC_CHECK_LINUX_HEADER([semaphore.h])
773                  AC_CHECK_LINUX_HEADER([seq_file.h])
774
775                  dnl Check for structure elements
776                  AC_CHECK_LINUX_STRUCT([address_space_operations],
777                                        [write_begin], [fs.h])
778                  AC_CHECK_LINUX_STRUCT([backing_dev_info], [name],
779                                        [backing-dev.h])
780                  AC_CHECK_LINUX_STRUCT([ctl_table], [ctl_name], [sysctl.h])
781                  AC_CHECK_LINUX_STRUCT([inode], [i_alloc_sem], [fs.h])
782                  AC_CHECK_LINUX_STRUCT([inode], [i_blkbits], [fs.h])
783                  AC_CHECK_LINUX_STRUCT([inode], [i_blksize], [fs.h])
784                  AC_CHECK_LINUX_STRUCT([inode], [i_mutex], [fs.h])
785                  AC_CHECK_LINUX_STRUCT([inode], [i_security], [fs.h])
786                  AC_CHECK_LINUX_STRUCT([file_operations], [flock], [fs.h])
787                  AC_CHECK_LINUX_STRUCT([file_operations], [sendfile], [fs.h])
788                  AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
789                  AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
790                  AC_CHECK_LINUX_STRUCT([super_block], [s_bdi], [fs.h])
791                  AC_CHECK_LINUX_STRUCT([super_operations], [alloc_inode],
792                                        [fs.h])
793                  AC_CHECK_LINUX_STRUCT([task_struct], [cred], [sched.h])
794                  AC_CHECK_LINUX_STRUCT([task_struct], [exit_state], [sched.h])
795                  AC_CHECK_LINUX_STRUCT([task_struct], [parent], [sched.h])
796                  AC_CHECK_LINUX_STRUCT([task_struct], [real_parent], [sched.h])
797                  AC_CHECK_LINUX_STRUCT([task_struct], [rlim], [sched.h])
798                  AC_CHECK_LINUX_STRUCT([task_struct], [sig], [sched.h])
799                  AC_CHECK_LINUX_STRUCT([task_struct], [sighand], [sched.h])
800                  AC_CHECK_LINUX_STRUCT([task_struct], [sigmask_lock], [sched.h])
801                  AC_CHECK_LINUX_STRUCT([task_struct], [tgid], [sched.h])
802                  AC_CHECK_LINUX_STRUCT([task_struct], [thread_info], [sched.h])
803                  LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM
804
805                  dnl Function existence checks
806
807                  AC_CHECK_LINUX_FUNC([bdi_init],
808                                      [#include <linux/backing-dev.h>],
809                                      [bdi_init(NULL);])
810                  AC_CHECK_LINUX_FUNC([PageChecked],
811                                      [#include <linux/mm.h>
812 #include <linux/page-flags.h>],
813                                      [struct page *_page;
814                                       int bchecked = PageChecked(_page);])
815                  AC_CHECK_LINUX_FUNC([PageFsMisc],
816                                      [#include <linux/mm.h>
817 #include <linux/page-flags.h>],
818                                      [struct page *_page;
819                                       int bchecked = PageFsMisc(_page);])
820                  AC_CHECK_LINUX_FUNC([current_kernel_time],
821                                      [#include <linux/time.h>],
822                                      [struct timespec s;
823                                       s = current_kernel_time();])
824                  AC_CHECK_LINUX_FUNC([d_alloc_anon],
825                                      [#include <linux/dcache.h>],
826                                      [d_alloc_anon(NULL);])
827                  AC_CHECK_LINUX_FUNC([do_sync_read],
828                                      [#include <linux/fs.h>],
829                                      [do_sync_read(NULL, NULL, 0, NULL);])
830                  AC_CHECK_LINUX_FUNC([find_task_by_pid],
831                                      [#include <linux/sched.h>],
832                                      [pid_t p; find_task_by_pid(p);])
833                  AC_CHECK_LINUX_FUNC([generic_file_aio_read],
834                                      [#include <linux/fs.h>],
835                                      [generic_file_aio_read(NULL,NULL,0,0);])
836                  AC_CHECK_LINUX_FUNC([grab_cache_page_write_begin],
837                                      [#include <linux/pagemap.h>],
838                                      [grab_cache_page_write_begin(NULL, 0, 0);])
839                  AC_CHECK_LINUX_FUNC([hlist_unhashed],
840                                      [#include <linux/list.h>],
841                                      [hlist_unhashed(0);])
842                  AC_CHECK_LINUX_FUNC([i_size_read],
843                                      [#include <linux/fs.h>],
844                                      [i_size_read(NULL);])
845                  AC_CHECK_LINUX_FUNC([iget],
846                                      [#include <linux/fs.h>],
847                                      [iget(NULL, NULL);])
848                  AC_CHECK_LINUX_FUNC([kernel_setsockopt],
849                                      [#include <linux/net.h>],
850                                      [kernel_setsockopt(NULL, 0, 0, NULL, 0);])
851                  AC_CHECK_LINUX_FUNC([page_follow_link],
852                                      [#include <linux/fs.h>],
853                                      [page_follow_link(0,0);])
854                  AC_CHECK_LINUX_FUNC([page_offset],
855                                      [#include <linux/pagemap.h>],
856                                      [page_offset(NULL);])
857                  AC_CHECK_LINUX_FUNC([pagevec_lru_add_file],
858                                      [#include <linux/pagevec.h>],
859                                      [__pagevec_lru_add_file(NULL);])
860                  AC_CHECK_LINUX_FUNC([rcu_read_lock],
861                                      [#include <linux/rcupdate.h>],
862                                      [rcu_read_lock();])
863                  AC_CHECK_LINUX_FUNC([splice_direct_to_actor],
864                                      [#include <linux/splice.h>],
865                                      [splice_direct_to_actor(NULL,NULL,NULL);])
866                  AC_CHECK_LINUX_FUNC([svc_addr_in],
867                                      [#include <linux/sunrpc/svc.h>],
868                                      [svc_addr_in(NULL);])
869                  AC_CHECK_LINUX_FUNC([zero_user_segments],
870                                      [#include <linux/highmem.h>],
871                                      [zero_user_segments(NULL, 0, 0, 0, 0);])
872
873                  dnl Consequences - things which get set as a result of the
874                  dnl                above tests
875                  AS_IF([test "x$ac_cv_linux_func_iget" = "xno"],
876                        [AC_DEFINE([LINUX_USE_FH], 1,
877                           [define to use linux file handles for cache files])])
878                  AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
879                        [AC_DEFINE([AFS_NONFSTRANS], 1,
880                                   [define to disable the nfs translator])])
881
882                  dnl Assorted more complex tests
883                  LINUX_EXPORTS_PROC_ROOT_FS
884                  LINUX_KMEM_CACHE_INIT
885                  LINUX_HAVE_KMEM_CACHE_T
886                  LINUX_KMEM_CACHE_CREATE_TAKES_DTOR
887                  LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID
888                  LINUX_D_PATH_TAKES_STRUCT_PATH
889                  LINUX_NEW_EXPORT_OPS
890                  LINUX_INODE_SETATTR_RETURN_TYPE
891                  LINUX_IOP_I_CREATE_TAKES_NAMEIDATA
892                  LINUX_IOP_I_LOOKUP_TAKES_NAMEIDATA
893                  LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA
894                  LINUX_IOP_I_PUT_LINK_TAKES_COOKIE
895                  LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA
896                  LINUX_FOP_F_FLUSH_TAKES_FL_OWNER_T
897                  LINUX_FOP_F_FSYNC_TAKES_DENTRY
898                  LINUX_AOP_WRITEBACK_CONTROL
899                  LINUX_FS_STRUCT_FOP_HAS_SPLICE
900                  LINUX_KERNEL_POSIX_LOCK_FILE_WAIT_ARG
901                  LINUX_POSIX_TEST_LOCK_RETURNS_CONFLICT
902                  LINUX_POSIX_TEST_LOCK_CONFLICT_ARG
903                  LINUX_KERNEL_SOCK_CREATE
904                  LINUX_EXPORTS_KEY_TYPE_KEYRING
905                  LINUX_KEYS_HAVE_SESSION_TO_PARENT
906                  LINUX_NEED_RHCONFIG
907                  LINUX_RECALC_SIGPENDING_ARG_TYPE
908                  LINUX_EXPORTS_TASKLIST_LOCK
909                  LINUX_GET_SB_HAS_STRUCT_VFSMOUNT
910                  LINUX_STATFS_TAKES_DENTRY
911                  LINUX_REFRIGERATOR
912                  LINUX_HAVE_TRY_TO_FREEZE
913                  LINUX_LINUX_KEYRING_SUPPORT
914                  LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK
915                  LINUX_KEY_ALLOC_NEEDS_CRED
916                  LINUX_INIT_WORK_HAS_DATA
917                  LINUX_REGISTER_SYSCTL_TABLE_NOFLAG
918
919                  dnl If we are guaranteed that keyrings will work - that is
920                  dnl  a) The kernel has keyrings enabled
921                  dnl  b) The code is new enough to give us a key_type_keyring
922                  dnl then we just disable syscall probing unless we've been
923                  dnl told otherwise
924
925                  AS_IF([test "$enable_linux_syscall_probing" = "maybe"],
926                    [AS_IF([test "$ac_cv_linux_keyring_support" = "yes" -a "$ac_cv_linux_exports_key_type_keyring" = "yes"],
927                           [enable_linux_syscall_probing="no"],
928                           [enable_linux_syscall_probing="yes"])
929                  ])
930
931                  dnl Syscall probing needs a few tests of its own, and just
932                  dnl won't work if the kernel doesn't export init_mm
933                  AS_IF([test "$enable_linux_syscall_probing" = "yes"], [
934                    LINUX_EXPORTS_INIT_MM
935                    AS_IF([test "$ac_cv_linux_exports_init_mm" = "no"], [
936                      AC_MSG_ERROR(
937                        [Can't do syscall probing without exported init_mm])
938                    ])
939                    LINUX_EXPORTS_SYS_CHDIR
940                    LINUX_EXPORTS_SYS_OPEN
941                    AC_DEFINE(ENABLE_LINUX_SYSCALL_PROBING, 1,
942                              [define to enable syscall table probes])
943                  ])
944
945                  dnl Packaging and SMP build
946                  if test "x$with_linux_kernel_packaging" = "xno" ; then
947                    LINUX_WHICH_MODULES
948                  else
949                    AC_SUBST(MPS,'SP')
950                  fi
951
952                  dnl Syscall probing
953                  if test "x$ac_cv_linux_config_modversions" = "xno" -o $AFS_SYSKVERS -ge 26; then
954                    AS_IF([test "$enable_linux_syscall_probing" = "yes"], [
955                      AC_MSG_WARN([Cannot determine sys_call_table status. assuming it isn't exported])
956                    ])
957                    ac_cv_linux_exports_sys_call_table=no
958                    if test -f "$LINUX_KERNEL_PATH/include/asm/ia32_unistd.h"; then
959                      ac_cv_linux_exports_ia32_sys_call_table=yes
960                    fi
961                  else
962                    LINUX_EXPORTS_KALLSYMS_ADDRESS
963                    LINUX_EXPORTS_KALLSYMS_SYMBOL
964                    LINUX_EXPORTS_SYS_CALL_TABLE
965                    LINUX_EXPORTS_IA32_SYS_CALL_TABLE
966                    if test "x$ac_cv_linux_exports_sys_call_table" = "xno"; then
967                          linux_syscall_method=none
968                          if test "x$ac_cv_linux_exports_init_mm" = "xyes"; then
969                             linux_syscall_method=scan
970                             if test "x$ac_cv_linux_exports_kallsyms_address" = "xyes"; then
971                                linux_syscall_method=scan_with_kallsyms_address
972                             fi
973                          fi
974                          if test "x$ac_cv_linux_exports_kallsyms_symbol" = "xyes"; then
975                             linux_syscall_method=kallsyms_symbol
976                          fi
977                          if test "x$linux_syscall_method" = "xnone"; then
978                             AC_MSG_WARN([no available sys_call_table access method -- guessing scan])
979                             linux_syscall_method=scan
980                          fi
981                    fi
982                  fi
983                  if test -f "$LINUX_KERNEL_PATH/include/linux/in_systm.h"; then
984                   AC_DEFINE(HAVE_IN_SYSTM_H, 1, [define if you have in_systm.h header file])
985                  fi
986                  if test -f "$LINUX_KERNEL_PATH/include/linux/mm_inline.h"; then
987                   AC_DEFINE(HAVE_MM_INLINE_H, 1, [define if you have mm_inline.h header file])
988                  fi
989                  if test "x$ac_cv_linux_kernel_page_follow_link" = "xyes" -o "x$ac_cv_linux_func_i_put_link_takes_cookie" = "xyes"; then
990                   AC_DEFINE(USABLE_KERNEL_PAGE_SYMLINK_CACHE, 1, [define if your kernel has a usable symlink cache API])
991                  else
992                   AC_MSG_WARN([your kernel does not have a usable symlink cache API])
993                  fi
994                 :
995                 fi
996 esac
997
998 AC_CACHE_CHECK([if struct sockaddr has sa_len field],
999     [ac_cv_sockaddr_len],
1000     [AC_TRY_COMPILE( [#include <sys/types.h>
1001 #include <sys/socket.h>],
1002                      [struct sockaddr *a; a->sa_len=0;],
1003                      [ac_cv_sockaddr_len=yes],
1004                      [ac_cv_sockaddr_len=no])
1005 ])
1006 AS_IF([test "$ac_cv_sockaddr_len" = "yes"],
1007       [AC_DEFINE(STRUCT_SOCKADDR_HAS_SA_LEN, 1,
1008                  [define if you struct sockaddr sa_len])])
1009
1010 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
1011         echo Skipping library tests because they confuse Irix.
1012 else
1013   AC_SEARCH_LIBS([socket], [socket inet])
1014   AC_SEARCH_LIBS([connect], [nsl])
1015   AC_SEARCH_LIBS([gethostbyname], [dns nsl resolv])
1016
1017   dnl darwin wants it, aix hates it
1018   AC_MSG_CHECKING(for the useability of arpa/nameser_compat.h)
1019   AC_TRY_COMPILE([
1020   #include <stdlib.h>
1021   #include <stdio.h>
1022   #include <sys/types.h>
1023   #include <sys/socket.h>
1024   #include <netinet/in.h>
1025   #include <arpa/inet.h>
1026   #include <arpa/nameser.h>
1027   #include <arpa/nameser_compat.h>
1028   #include <resolv.h>
1029   ], [static int i; i = 0;],
1030   [AC_MSG_RESULT(yes)
1031    AC_DEFINE(HAVE_ARPA_NAMESER_COMPAT_H, 1, [define if arpa/nameser_compat.h exists])],
1032   [AC_MSG_RESULT(no)
1033    ])
1034
1035   openafs_save_libs="$LIBS"
1036   AC_MSG_CHECKING([for res_search])
1037   AC_FUNC_RES_SEARCH
1038
1039   if test "$ac_cv_func_res_search" = no; then
1040       for lib in dns nsl resolv; do
1041         if test "$ac_cv_func_res_search" != yes; then
1042           LIBS="-l$lib $LIBS"
1043           AC_FUNC_RES_SEARCH
1044           LIBS="$openafs_save_libs"
1045         fi
1046       done    
1047       if test "$ac_cv_func_res_search" = yes; then
1048         LIB_AFSDB="-l$lib"
1049         AC_DEFINE(HAVE_RES_SEARCH, 1, [])
1050         AC_MSG_RESULT([yes, in lib$lib])
1051       else
1052         AC_MSG_RESULT(no)
1053       fi
1054   else
1055     AC_DEFINE(HAVE_RES_SEARCH, 1, [])
1056     AC_MSG_RESULT(yes)
1057   fi
1058   
1059 fi
1060
1061 AC_CHECK_RESOLV_RETRANS
1062
1063 AC_CACHE_CHECK([for setsockopt(, SOL_IP, IP_RECVERR)],
1064     [ac_cv_setsockopt_iprecverr],
1065     [AC_TRY_COMPILE( [
1066 #include <sys/types.h>
1067 #include <sys/socket.h>
1068 #include <netinet/in.h>],
1069 [int on=1;
1070 setsockopt(0, SOL_IP, IP_RECVERR, &on, sizeof(on));],
1071         [ac_cv_setsockopt_iprecverr=yes],
1072         [ac_cv_setsockopt_iprecverr=no])])
1073
1074 AS_IF([test "$ac_cv_setsockopt_iprecverr" = "yes"],
1075       [AC_DEFINE(ADAPT_PMTU_RECVERR, 1,
1076                  [define if asynchronous socket errors can be received])])
1077
1078 PTHREAD_LIBS=error
1079 if test "x$MKAFS_OSTYPE" = OBSD; then
1080         PTHREAD_LIBS="-pthread"
1081 fi
1082 if test "x$MKAFS_OSTYPE" = xDFBSD; then
1083         PTHREAD_LIBS="-pthread"
1084 fi
1085 if test "x$PTHREAD_LIBS" = xerror; then
1086         AC_CHECK_LIB(pthread, pthread_attr_init,
1087                 PTHREAD_LIBS="-lpthread")
1088 fi
1089 if test "x$PTHREAD_LIBS" = xerror; then
1090         AC_CHECK_LIB(pthreads, pthread_attr_init,
1091                 PTHREAD_LIBS="-lpthreads")
1092 fi
1093 if test "x$PTHREAD_LIBS" = xerror; then
1094         AC_CHECK_LIB(c_r, pthread_attr_init,
1095                 PTHREAD_LIBS="-lc_r")
1096 fi
1097 if test "x$PTHREAD_LIBS" = xerror; then
1098         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
1099 fi
1100 if test "x$PTHREAD_LIBS" = xerror; then
1101         # pthread_attr_init is a macro under HPUX 11.0 and 11.11
1102         AC_CHECK_LIB(pthread, pthread_attr_destroy,
1103                 PTHREAD_LIBS="-lpthread")
1104 fi
1105 if test "x$PTHREAD_LIBS" = xerror; then
1106         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
1107 fi
1108 AC_SUBST(PTHREAD_LIBS)
1109
1110 HOST_CPU="$host_cpu"
1111
1112 if test "x$with_bsd_kernel_headers" != "x"; then
1113         BSD_KERNEL_PATH="$with_bsd_kernel_headers"
1114 else
1115         BSD_KERNEL_PATH="/usr/src/sys"
1116 fi
1117
1118 if test "x$with_bsd_kernel_build" != "x"; then
1119         BSD_KERNEL_BUILD="$with_bsd_kernel_build"
1120 else
1121         case $AFS_SYSNAME in
1122                 *_fbsd_*)
1123                         BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"
1124                         ;;
1125                 *_nbsd*)
1126                         BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/arch/${HOST_CPU}/compile/GENERIC"
1127         esac
1128 fi
1129
1130 # Fast restart
1131 if test "$enable_supergroups" = "yes"; then
1132         AC_DEFINE(SUPERGROUPS, 1, [define if you want to have support for nested pts groups])
1133 fi
1134
1135 if test "$enable_fast_restart" = "yes"; then
1136         AC_DEFINE(FAST_RESTART, 1, [define if you want to have fast restart])
1137 fi
1138
1139 if test "$enable_bitmap_later" = "yes"; then
1140         AC_DEFINE(BITMAP_LATER, 1, [define if you want to salvager to check bitmasks later])
1141 fi
1142
1143 if test "$enable_demand_attach_fs" = "yes"; then
1144         AC_DEFINE(DEMAND_ATTACH_ENABLE, 1, [define if you want the demand attach fileserver])
1145         DEMAND_ATTACH="yes"
1146 else
1147         DEMAND_ATTACH="no"
1148 fi
1149 AC_SUBST(DEMAND_ATTACH)
1150
1151 if test "$enable_disconnected" = "yes"; then
1152         AC_DEFINE(AFS_DISCON_ENV, 1, [define if you want support for disconnected operation])
1153 fi
1154
1155 if test "$enable_unix_sockets" = "yes"; then
1156         AC_DEFINE(USE_UNIX_SOCKETS, 1, [define if you want to use UNIX sockets for fssync.])
1157         USE_UNIX_SOCKETS="yes"
1158 else
1159         USE_UNIX_SOCKETS="no"
1160 fi
1161 AC_SUBST(USE_UNIX_SOCKETS)
1162
1163 if test "$enable_fast_restart" = "yes" &&
1164    test "$enable_demand_attach_fs" = "yes" ; then
1165         AC_MSG_ERROR([The Demand Attach and Fast Restart extensions are mutually exclusive.  Demand Attach fileservers automatically salvage volumes in the background, thereby making Fast Restart pointless.])
1166         exit 1
1167 fi
1168
1169 if test "$enable_icmp_pmtu_discovery" = "yes"; then
1170    if test "$ac_cv_setsockopt_iprecverr" = "yes"; then
1171         AC_DEFINE(ADAPT_PMTU, 1, [define if you want to decode icmp unreachable packets to discover path mtu])
1172    fi
1173 fi
1174
1175 if test "$enable_cache_bypass" = "yes"; then
1176         AC_DEFINE(AFS_CACHE_BYPASS, 1, [define to activate cache bypassing Unix client])
1177 fi
1178
1179 if test "$enable_namei_fileserver" = "yes"; then
1180         AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
1181         VFSCK=""
1182 else
1183         if test "$enable_namei_fileserver" = "default"; then
1184                 case $host in
1185                         *-solaris2.10*)
1186                                 AC_MSG_WARN(Some Solaris 10 versions are not safe with the inode fileserver. Forcing namei. Override with --disable-namei-fileserver)
1187                                 AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
1188                                 VFSCK=""
1189                                 ;;
1190                         *-solaris2.11*)
1191                                 AC_MSG_WARN(Solaris 11 versions are not safe with the inode fileserver. Forcing namei. Override with --disable-namei-fileserver)
1192                                 AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
1193                                 VFSCK=""
1194                                 ;;
1195                         *)
1196                                 VFSCK="vfsck"
1197                                 ;;
1198                 esac
1199         else
1200                 VFSCK="vfsck"
1201         fi
1202 fi
1203
1204 dnl check for tivoli
1205 AC_MSG_CHECKING(for tivoli tsm butc support)
1206 XBSA_CFLAGS=""
1207 if test "$enable_tivoli_tsm" = "yes"; then
1208         XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
1209         XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
1210         XBSADIR3=/usr/tivoli/tsm/client/api/bin/sample
1211         XBSADIR4=/opt/tivoli/tsm/client/api/bin/sample
1212
1213         if test -r "$XBSADIR3/dsmapifp.h"; then
1214                 XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR3"
1215                 XBSA_XLIBS="-ldl"
1216                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1217         elif test -r "$XBSADIR4/dsmapifp.h"; then
1218                 XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR4"
1219                 XBSA_XLIBS="-ldl"
1220                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1221         elif test -r "$XBSADIR1/xbsa.h"; then
1222                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
1223                 XBSA_XLIBS=""
1224                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1225         elif test -r "$XBSADIR2/xbsa.h"; then
1226                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
1227                 XBSA_XLIBS=""
1228                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1229         else
1230                 AC_MSG_RESULT([no, missing xbsa.h and dsmapifp.h header files])
1231         fi
1232 else
1233         AC_MSG_RESULT([no])
1234 fi
1235 AC_SUBST(XBSA_CFLAGS)
1236 AC_SUBST(XBSA_XLIBS) 
1237
1238 dnl checks for header files.
1239 AC_HEADER_STDC
1240 AC_HEADER_SYS_WAIT
1241 AC_HEADER_DIRENT
1242 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h grp.h)
1243 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
1244 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h sys/fstyp.h)
1245 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h sys/pag.h)
1246 AC_CHECK_HEADERS(windows.h direct.h sys/ipc.h)
1247 AC_CHECK_HEADERS(security/pam_modules.h ucontext.h regex.h sys/statvfs.h sys/statfs.h sys/bitypes.h)
1248 AC_CHECK_HEADERS(linux/errqueue.h,,,[#include <linux/types.h>])
1249 AC_CHECK_HEADERS(et/com_err.h)
1250
1251 AC_CHECK_TYPES([fsblkcnt_t],,,[
1252 #include <sys/types.h>
1253 #ifdef HAVE_SYS_BITYPES_H
1254 #include <sys/bitypes.h>
1255 #endif
1256 #ifdef HAVE_SYS_STATFS_H
1257 #include <sys/statfs.h>
1258 #endif
1259 #ifdef HAVE_SYS_STATVFS_H
1260 #include <sys/statvfs.h>
1261 #endif
1262 ])
1263
1264 OPENAFS_TEST_PACKAGE(libintl,[#include <libintl.h>],[-lintl],,,INTL)
1265
1266 dnl Don't build PAM on IRIX; the interface doesn't work for us.
1267 if test "$ac_cv_header_security_pam_modules_h" = yes -a "$enable_pam" = yes; then
1268         case $AFS_SYSNAME in
1269         sgi_*)
1270                 HAVE_PAM="no"
1271                 ;;
1272         *)
1273                 HAVE_PAM="yes"
1274                 ;;
1275         esac
1276 else
1277         HAVE_PAM="no"
1278 fi
1279 AC_SUBST(HAVE_PAM)
1280
1281 if test "$enable_login" = yes; then
1282         BUILD_LOGIN="yes"
1283 else
1284         BUILD_LOGIN="no"
1285 fi
1286 AC_SUBST(BUILD_LOGIN)
1287
1288 AC_CHECK_FUNCS(snprintf strlcat strlcpy flock)
1289 AC_CHECK_FUNCS(setprogname getprogname sigaction mkstemp vsnprintf strerror strcasestr)
1290 AC_CHECK_FUNCS(setvbuf vsyslog getcwd)
1291 AC_CHECK_FUNCS(regcomp regexec regerror)
1292 AC_MSG_CHECKING([for POSIX regex library])
1293 if test "$ac_cv_header_regex_h" = "yes" && \
1294         test "$ac_cv_func_regcomp" = "yes" && \
1295         test "$ac_cv_func_regexec" = "yes" && \
1296         test "$ac_cv_func_regerror" = "yes"; then
1297     AC_DEFINE(HAVE_POSIX_REGEX, 1, [define if you have POSIX regex library])
1298     AC_MSG_RESULT(yes)
1299 else
1300     AC_MSG_RESULT(no)
1301 fi
1302
1303 AC_TYPE_SIGNAL
1304 AC_CHECK_SIZEOF(void *)
1305 AC_CHECK_SIZEOF(unsigned long long)
1306 AC_CHECK_SIZEOF(unsigned long)
1307 AC_CHECK_SIZEOF(unsigned int)
1308 AC_TYPE_INTPTR_T
1309 AC_TYPE_UINTPTR_T
1310 AC_TYPE_SSIZE_T
1311 AC_CHECK_TYPE([sig_atomic_t],[],
1312     [AC_DEFINE([sig_atomic_t], [int],
1313         [Define to int if <signal.h> does not define.])],
1314 [#include <sys/types.h>
1315 #include <signal.h>])
1316 AC_CHECK_TYPE([socklen_t],[],
1317     [AC_DEFINE([socklen_t], [int],
1318         [Define to int if <sys/socket.h> does not define.])],
1319 [#include <sys/types.h>
1320 #include <sys/socket.h>])
1321 AC_SIZEOF_TYPE(long)
1322
1323 AC_HEADER_PAM_CONST
1324
1325 AC_CHECK_FUNCS(timegm)
1326 AC_CHECK_FUNCS(daemon)
1327
1328 dnl Directory PATH handling
1329 if test "x$enable_transarc_paths" = "xyes"  ; then 
1330     afsconfdir=${afsconfdir=/usr/afs/etc}
1331     viceetcdir=${viceetcdir=/usr/vice/etc}
1332     afskerneldir=${afskerneldir=${viceetcdir}}
1333     afssrvbindir=${afssrvbindir=/usr/afs/bin}
1334     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
1335     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
1336     afsdbdir=${afsdbdir=/usr/afs/db}
1337     afslogsdir=${afslogsdir=/usr/afs/logs}
1338     afslocaldir=${afslocaldir=/usr/afs/local}
1339     afsbackupdir=${afsbackupdir=/usr/afs/backup}
1340     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
1341     afsdatadir=${afsdatadir=/usr/vice/etc}
1342 else 
1343     afsconfdir=${afsconfdir='${sysconfdir}/openafs/server'}
1344     viceetcdir=${viceetcdir='${sysconfdir}/openafs'}
1345     afskerneldir=${afskerneldir='${libdir}/openafs'}
1346     afssrvbindir=${afssrvbindir='${bindir}'}
1347     afssrvsbindir=${afssrvsbindir='${sbindir}'}
1348     afssrvlibexecdir=${afssrvlibexecdir='${libexecdir}/openafs'}
1349     afsdbdir=${afsdbdir='${localstatedir}/openafs/db'}
1350     afslogsdir=${afslogsdir='${localstatedir}/openafs/logs'}
1351     afslocaldir=${afslocaldir='${localstatedir}/openafs'}
1352     afsbackupdir=${afsbackupdir='${localstatedir}/openafs/backup'}
1353     afsbosconfigdir=${afsbosconfigdir='${sysconfdir}/openafs'}
1354     afsdatadir=${afsdatadir='${datadir}/openafs'}
1355 fi
1356 AC_SUBST(afsconfdir)
1357 AC_SUBST(viceetcdir)
1358 AC_SUBST(afskerneldir)
1359 AC_SUBST(afssrvbindir)
1360 AC_SUBST(afssrvsbindir)
1361 AC_SUBST(afssrvlibexecdir)
1362 AC_SUBST(afsdbdir)
1363 AC_SUBST(afslogsdir)
1364 AC_SUBST(afslocaldir)
1365 AC_SUBST(afsbackupdir)
1366 AC_SUBST(afsbosconfigdir)
1367 AC_SUBST(afsdatadir)
1368
1369 if test "x$enable_kernel_module" = "xyes"; then
1370 ENABLE_KERNEL_MODULE=libafs
1371 fi
1372
1373 if test "x$enable_pthreaded_ubik" = "xyes"; then
1374 ENABLE_PTHREADED_UBIK=yes
1375 fi
1376
1377 AC_SUBST(VFSCK)
1378 AC_SUBST(AFS_SYSNAME)
1379 AC_SUBST(AFS_PARAM_COMMON)
1380 AC_SUBST(ENABLE_KERNEL_MODULE)
1381 AC_SUBST(ENABLE_PTHREADED_UBIK)
1382 AC_SUBST(LIB_AFSDB)
1383 AC_SUBST(LINUX_KERNEL_PATH)
1384 AC_SUBST(LINUX_KERNEL_BUILD)
1385 AC_SUBST(HOST_CPU)
1386 AC_SUBST(BSD_KERNEL_PATH)
1387 AC_SUBST(BSD_KERNEL_BUILD)
1388 AC_SUBST(LINUX_VERSION)
1389 AC_SUBST(MKAFS_OSTYPE)
1390 AC_SUBST(TOP_OBJDIR)
1391 AC_SUBST(TOP_SRCDIR)
1392 AC_SUBST(TOP_INCDIR)
1393 AC_SUBST(TOP_LIBDIR)
1394 AC_SUBST(DEST)
1395 AC_SUBST(DARWIN_INFOFILE)
1396 AC_SUBST(IRIX_BUILD_IP35)
1397 AC_SUBST(HTML_XSL)
1398 AC_SUBST(XSLTPROC)
1399
1400 OPENAFS_OSCONF
1401 OPENAFS_FUSE
1402
1403 TOP_SRCDIR="${srcdir}/src"
1404 dnl
1405 dnl If we're using ./configure, need a more reasonable TOP_SRCDIR, since relative links don't work everywhere
1406 dnl
1407 case $TOP_SRCDIR in
1408         /*)
1409                 ;;
1410         *)
1411                 TOP_SRCDIR=`cd $TOP_SRCDIR; pwd`
1412                 ;;
1413 esac
1414
1415 TOP_OBJDIR="${SRCDIR_PARENT}"
1416 TOP_INCDIR="${SRCDIR_PARENT}/include"
1417 TOP_LIBDIR="${SRCDIR_PARENT}/lib"
1418 if test "${DEST}x" = "x"; then
1419         DEST="${SRCDIR_PARENT}/${AFS_SYSNAME}/dest"
1420 fi
1421
1422 HELPER_SPLINT="${TOP_SRCDIR}/helper-splint.sh"
1423 HELPER_SPLINTCFG="${TOP_SRCDIR}/splint.cfg"
1424 AC_SUBST(HELPER_SPLINT)
1425 AC_SUBST(HELPER_SPLINTCFG)
1426
1427 mkdir -p ${TOP_OBJDIR}/src/JAVA/libjafs
1428
1429 ])