ihandle: Fix fdInUseCount leak on EMFILE
[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 /* glue for RedHat kernel bug */
63 #undef ENABLE_REDHAT_BUILDSYS
64 #if defined(ENABLE_REDHAT_BUILDSYS) && defined(KERNEL) && defined(REDHAT_FIX)
65 #include "redhat-fix.h"
66 #endif])
67
68 AC_CANONICAL_HOST
69 SRCDIR_PARENT=`pwd`
70
71 #BOZO_SAVE_CORES pam
72
73 dnl System identity.
74 AC_ARG_WITH([afs-sysname],
75     [AS_HELP_STRING([--with-afs-sysname=sys], [use sys for the afs sysname])])
76
77 dnl General feature options.
78 AC_ARG_ENABLE([pam],
79     [AS_HELP_STRING([--disable-pam], [disable PAM support])],
80     ,
81     [enable_pam="yes"])
82 AC_ARG_ENABLE([gtx],
83     AS_HELP_STRING([--disable-gtx], [disable gtx curses-based terminal tools]))
84 AC_ARG_ENABLE([uss],
85     AS_HELP_STRING([--disable-uss], [disable uss bulk creation tool]))
86 AC_ARG_ENABLE([namei-fileserver],
87     [AS_HELP_STRING([--enable-namei-fileserver],
88         [force compilation of namei fileserver in preference to inode
89          fileserver])],
90     , 
91     [enable_namei_fileserver="default"])
92 AC_ARG_ENABLE([supergroups],
93     [AS_HELP_STRING([--enable-supergroups],
94         [enable support for nested pts groups])],
95     , 
96     [enable_supergroups="no"])
97 AC_ARG_ENABLE([bitmap-later],
98     [AS_HELP_STRING([--enable-bitmap-later],
99         [enable fast startup of file server by not reading bitmap till
100          needed])],
101     , 
102     [enable_bitmap_later="no"])
103 AC_ARG_ENABLE([unix-sockets],
104     [AS_HELP_STRING([--disable-unix-sockets],
105         [disable use of unix domain sockets for fssync (defaults to enabled)])],
106     ,
107     [enable_unix_sockets="yes"])
108 AC_ARG_ENABLE([tivoli-tsm],
109     [AS_HELP_STRING([--enable-tivoli-tsm],
110         [enable use of the Tivoli TSM API libraries for butc support])],
111     , 
112     [enable_tivoli_tsm="no"])
113 AC_ARG_ENABLE([pthreaded-ubik],
114     [AS_HELP_STRING([--enable-pthreaded-ubik],
115         [enable installation of pthreaded ubik applications (defaults to
116          disabled)])],
117     ,
118     [enable_pthreaded_ubik="no"])
119
120 dnl Kernel module build options.
121 AC_ARG_WITH([linux-kernel-headers],
122     [AS_HELP_STRING([--with-linux-kernel-headers=path],
123         [use the kernel headers found at path (optional, defaults to
124          /lib/modules/`uname -r`/build, then /lib/modules/`uname -r`/source,
125          then /usr/src/linux-2.4, and lastly /usr/src/linux)])])
126 AC_ARG_WITH([linux-kernel-build],
127     [AS_HELP_STRING([--with-linux-kernel-build=path],
128         [use the kernel build found at path(optional, defaults to 
129         kernel headers path)])])
130 AC_ARG_WITH([bsd-kernel-headers],
131     [AS_HELP_STRING([--with-bsd-kernel-headers=path],
132         [use the kernel headers found at path (optional, defaults to
133          /usr/src/sys)])])
134 AC_ARG_WITH([bsd-kernel-build],
135     [AS_HELP_STRING([--with-bsd-kernel-build=path], 
136         [use the kernel build found at path (optional, defaults to
137          KSRC/i386/compile/GENERIC)])])
138 AC_ARG_WITH([linux-kernel-packaging],
139     [AS_HELP_STRING([--with-linux-kernel-packaging],
140         [use standard naming conventions to aid Linux kernel build packaging
141          (disables MPS, sets the kernel module name to openafs.ko, and
142          installs kernel modules into the standard Linux location)])],
143     [AC_SUBST(LINUX_KERNEL_PACKAGING, "yes")
144      AC_SUBST(LINUX_LIBAFS_NAME, "openafs")],
145     [AC_SUBST(LINUX_LIBAFS_NAME, "libafs")])
146 AC_ARG_ENABLE([kernel-module],
147     [AS_HELP_STRING([--disable-kernel-module],
148         [disable compilation of the kernel module (defaults to enabled)])],
149     , 
150     [enable_kernel_module="yes"])
151 AC_ARG_ENABLE([redhat-buildsys],
152     [AS_HELP_STRING([--enable-redhat-buildsys],
153         [enable compilation of the redhat build system kernel (defaults to
154          disabled)])],
155     ,
156     [enable_redhat_buildsys="no"])
157
158 dnl Installation locations.
159 AC_ARG_ENABLE([transarc-paths],
160     [AS_HELP_STRING([--enable-transarc-paths],
161         [use Transarc style paths like /usr/afs and /usr/vice])],
162     , 
163     [enable_transarc_paths="no"])
164
165 dnl Deprecated crypto
166 AC_ARG_ENABLE([kauth],
167     [AS_HELP_STRING([--disable-kauth],
168         [do not install the deprecated kauth server and utilities (defaults to
169          enabled)])],
170     ,
171     [enable_kauth="yes"])
172
173 dnl Optimization and debugging flags.
174 AC_ARG_ENABLE([strip-binaries],
175     [AS_HELP_STRING([--disable-strip-binaries],
176         [disable stripping of symbol information from binaries (defaults to
177          enabled)])],
178     ,
179     [enable_strip_binaries="maybe"])
180 AC_ARG_ENABLE([debug],
181     [AS_HELP_STRING([--enable-debug],
182         [enable compilation of the user space code with debugging information
183          (defaults to disabled)])],
184     , 
185     [enable_debug="no"])
186 AC_ARG_ENABLE([optimize],
187     [AS_HELP_STRING([--disable-optimize],
188         [disable optimization for compilation of the user space code (defaults
189          to enabled)])],
190     , 
191     [enable_optimize="yes"])
192 AC_ARG_ENABLE([warnings],
193     [AS_HELP_STRING([--enable-warnings],
194         [enable compilation warnings when building with gcc (defaults to
195          disabled)])],
196     ,
197     [enable_warnings="no"])
198 AC_ARG_ENABLE([checking],
199     [AS_HELP_STRING([--enable-checking],
200         [turn compilation warnings into errors when building with gcc (defaults
201          to disabled)])],
202     [enable_checking="$enableval"],
203     [enable_checking="no"])
204 AC_ARG_ENABLE([debug-locks],
205     [AS_HELP_STRING([--enable-debug-locks],
206         [turn on lock debugging assertions (defaults to disabled)])],
207     [enable_debug_locks="$enableval"],
208     [enable_debug_locks="no"])
209 AC_ARG_ENABLE([debug-kernel],
210     [AS_HELP_STRING([--enable-debug-kernel],
211         [enable compilation of the kernel module with debugging information
212          (defaults to disabled)])],
213     ,
214     [enable_debug_kernel="no"])
215 AC_ARG_ENABLE([optimize-kernel],
216     [AS_HELP_STRING([--disable-optimize-kernel],
217         [disable compilation of the kernel module with optimization (defaults
218          based on platform)])],
219     , 
220     [enable_optimize_kernel=""])
221 AC_ARG_ENABLE([debug-lwp],
222     [AS_HELP_STRING([--enable-debug-lwp],
223         [enable compilation of the LWP code with debugging information
224          (defaults to disabled)])],
225     ,
226     [enable_debug_lwp="no"])
227 AC_ARG_ENABLE([optimize-lwp],
228     [AS_HELP_STRING([--disable-optimize-lwp],
229         [disable optimization for compilation of the LWP code (defaults to
230          enabled)])],
231     ,
232     [enable_optimize_lwp="yes"])
233 AC_ARG_ENABLE([debug-pam],
234     [AS_HELP_STRING([--enable-debug-pam],
235         [enable compilation of the PAM code with debugging information
236          (defaults to disabled)])],
237     ,
238     [enable_debug_pam="no"])
239 AC_ARG_ENABLE([optimize-pam],
240     [AS_HELP_STRING([--disable-optimize-pam],
241         [disable optimization for compilation of the PAM code (defaults to
242          enabled)])],
243     ,
244     [enable_optimize_pam="yes"])
245 AC_ARG_ENABLE([linux-syscall-probing],
246     [AS_HELP_STRING([--enable-linux-syscall-probing],
247         [enable Linux syscall probing (defaults to autodetect)])],
248     ,
249     [enable_linux_syscall_probing="maybe"])
250 AC_ARG_WITH([crosstools-dir],
251     [AS_HELP_STRING([--with-crosstools-dir=path], [use path for native versions of rxgen, compile_et and config])])
252     
253 AC_ARG_WITH([xslt-processor],
254         AS_HELP_STRING([--with-xslt-processor=ARG],
255         [which XSLT processor to use (possible choices are: libxslt, saxon, xalan-j, xsltproc)]),
256         [XSLTPROC="$withval"],
257         AC_CHECK_PROGS([XSLTPROC], [libxslt saxon xalan-j xsltproc], [echo]))
258
259 AC_ARG_WITH([html-xsl], 
260         AS_HELP_STRING([--with-html-xsl],
261         [build HTML documentation using this stylesheet (default is html/chunk.dsl; specify either html/chunk.xsl or html/docbook.xsl)]),
262         [HTML_XSL="$withval"],
263         [HTML_XSL="html/chunk.xsl"])
264
265 AC_ARG_WITH([docbook2pdf],
266         AS_HELP_STRING([--with-docbook2pdf=ARG],
267         [which Docbook to PDF utility to use (possible choices are: fop, dblatex, docbook2pdf)]),
268         [DOCBOOK2PDF="$withval"],
269         AC_CHECK_PROGS([DOCBOOK2PDF], [fop dblatex docbook2pdf], [echo]))
270
271 AC_ARG_WITH([docbook-stylesheets],
272         AS_HELP_STRING([--with-docbook-stylesheets=ARG],
273         [location of DocBook stylesheets (default is to search a set of likely paths)]),
274         [DOCBOOK_STYLESHEETS="$withval"],
275         OPENAFS_SEARCH_DIRLIST([DOCBOOK_STYLESHEETS], [/usr/share/xml/docbook/stylesheet/nwalsh/current /usr/share/xml/docbook/stylesheet/nwalsh /usr/share/xml/docbook/xsl-stylesheets /usr/share/sgml/docbook/docbook-xsl-stylesheets /usr/share/sgml/docbook/xsl-stylesheets /usr/share/docbook-xsl /usr/share/sgml/docbkxsl /usr/local/share/xsl/docbook /sw/share/xml/xsl/docbook-xsl /opt/local/share/xsl/docbook-xsl], [$HTML_XSL])
276         if test "x$DOCBOOK_STYLESHEETS" = "x"; then
277                 AC_WARN([Docbook stylesheets not found; some documentation can't be built])
278         fi)
279
280 enable_login="no"
281
282 dnl Check whether kindlegen exists.  If not, we'll suppress that part of the
283 dnl documentation build.
284 AC_CHECK_PROGS([KINDLEGEN], [kindlegen])
285
286 dnl weird ass systems
287 dnl AC_AIX
288 AC_ISC_POSIX
289 dnl AC_MINIX
290
291 dnl Various compiler setup.
292 AC_TYPE_PID_T
293 AC_TYPE_SIZE_T
294
295 dnl Checks for programs.
296 AC_PROG_INSTALL
297 AC_PROG_LN_S
298 AC_PROG_RANLIB
299 AC_PROG_YACC
300 AM_PROG_LEX
301 dnl if we are flex, be lex-compatible
302 OPENAFS_LEX_IS_FLEX([AC_SUBST([LEX], ["$LEX -l"])])
303
304 OPENAFS_FORCE_ABS_INSTALL
305 OPENAFS_CHECK_BIGENDIAN
306 OPENAFS_PRINTF_TAKES_Z_LEN
307
308 AC_MSG_CHECKING(your OS)
309 system=$host
310 case $system in
311         *-linux*)
312
313                 MKAFS_OSTYPE=LINUX
314                 if test "x$enable_redhat_buildsys" = "xyes"; then
315                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS, 1, [define if you have redhat buildsystem])
316                 fi
317                 if test "x$enable_kernel_module" = "xyes"; then
318                  if test "x$with_linux_kernel_headers" != "x"; then
319                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
320                  else
321                    for utsdir in "/lib/modules/`uname -r`/build" \
322                                  "/lib/modules/`uname -r`/source" \
323                                  "/usr/src/linux-2.4" \
324                                  "/usr/src/linux"; do
325                      LINUX_KERNEL_PATH="$utsdir"
326                      for utsfile in "include/generated/utsrelease.h" \
327                                     "include/linux/utsrelease.h" \
328                                     "include/linux/version.h" \
329                                     "include/linux/version-up.h"; do
330                        if grep "UTS_RELEASE" "$utsdir/$utsfile" >/dev/null 2>&1; then
331                          break 2
332                        fi
333                      done
334                    done
335                  fi
336                  if test "x$with_linux_kernel_build" != "x"; then
337                          LINUX_KERNEL_BUILD="$with_linux_kernel_build"
338                  else
339                    LINUX_KERNEL_BUILD=$LINUX_KERNEL_PATH
340                  fi
341                  if test -f "$LINUX_KERNEL_BUILD/include/generated/utsrelease.h"; then
342                    linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/generated/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
343                    LINUX_VERSION="$linux_kvers"
344                  else
345                    if test -f "$LINUX_KERNEL_BUILD/include/linux/utsrelease.h"; then
346                      linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
347                      LINUX_VERSION="$linux_kvers"
348                    else
349                      if test -f "$LINUX_KERNEL_BUILD/include/linux/version.h"; then
350                        linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
351                        if test "x$linux_kvers" = "x"; then
352                          if test -f "$LINUX_KERNEL_BUILD/include/linux/version-up.h"; then
353                            linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
354                            if test "x$linux_kvers" = "x"; then
355                              AC_MSG_ERROR(Linux headers lack version definition [2])
356                              exit 1
357                            else
358                              LINUX_VERSION="$linux_kvers"
359                            fi
360                          else
361                            AC_MSG_ERROR(Linux headers lack version definition)
362                            exit 1
363                          fi
364                        else
365                          LINUX_VERSION="$linux_kvers"
366                        fi
367                      else
368                        enable_kernel_module="no"
369                      fi
370                    fi
371                  fi
372                  if test ! -f "$LINUX_KERNEL_BUILD/include/generated/autoconf.h" &&
373                     test ! -f "$LINUX_KERNEL_BUILD/include/linux/autoconf.h"; then
374                      enable_kernel_module="no"
375                  fi
376                  if test "x$enable_kernel_module" = "xno"; then
377                   if test "x$with_linux_kernel_headers" != "x"; then
378                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
379                    exit 1
380                   else
381                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
382                   fi
383                  fi
384                  dnl do we need to determine SUBARCH from autoconf.h
385                  SUBARCH=default
386                 fi
387                 AC_MSG_RESULT(linux)
388                 if test "x$enable_kernel_module" = "xyes"; then
389                  case "$LINUX_VERSION" in
390                   2.2.*) AFS_SYSKVERS=22 ;;
391                   2.4.*) AFS_SYSKVERS=24 ;;
392                   2.6.* | 3.*) AFS_SYSKVERS=26 ;;
393                   *) AC_MSG_ERROR(Couldn't guess your Linux version [2]) ;;
394                  esac
395                 fi
396                 ;;
397         *-solaris*)
398                 MKAFS_OSTYPE=SOLARIS
399                 AC_MSG_RESULT(sun4)
400                 AC_PATH_PROG(SOLARISCC, [cc], ,
401                     [/opt/SUNWspro/bin:/opt/SunStudioExpress/bin:/opt/solarisstudio12.3/bin:/opt/solstudio12.2/bin:/opt/sunstudio12.1/bin])
402                 if test "x$SOLARISCC" = "x" ; then
403                     AC_MSG_FAILURE(Could not find the solaris cc program.  Please define the environment variable SOLARISCC to specify the path.)
404                 fi
405                 SOLARIS_UFSVFS_HAS_DQRWLOCK
406                 SOLARIS_FS_HAS_FS_ROLLED
407                 SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS
408                 SOLARIS_HAVE_VN_RENAMEPATH
409                 ;;
410         *-sunos*)
411                 MKAFS_OSTYPE=SUNOS
412                 enable_kernel_module=no
413                 AC_MSG_RESULT(sun4)
414                 ;;
415         *-hpux*)
416                 MKAFS_OSTYPE=HPUX
417                 AC_MSG_RESULT(hp_ux)
418                 if test -f "/usr/old/usr/include/ndir.h"; then
419                  AC_DEFINE(HAVE_USR_OLD_USR_INCLUDE_NDIR_H, 1, [define if you have old ndir.h])
420                 fi
421                 ;;
422         *-irix*)
423                 if test -d /usr/include/sys/SN/SN1; then
424                  IRIX_BUILD_IP35="IP35"
425                 fi
426                 MKAFS_OSTYPE=IRIX
427                 AC_MSG_RESULT(sgi)
428                 ;;
429         *-aix*)
430                 MKAFS_OSTYPE=AIX
431                 AC_MSG_RESULT(rs_aix)
432                 ;;
433         arm-*-darwin*)
434                 MKAFS_OSTYPE=DARWIN
435                 AC_MSG_RESULT(arm_darwin)
436                 ;;
437         powerpc-*-darwin*)
438                 MKAFS_OSTYPE=DARWIN
439                 AC_MSG_RESULT(ppc_darwin)
440                 ;;
441         i386-*-darwin*)
442                 MKAFS_OSTYPE=DARWIN
443                 AC_MSG_RESULT(x86_darwin)
444                 ;;
445         x86_64-*-darwin*)
446                 MKAFS_OSTYPE=DARWIN
447                 AC_MSG_RESULT(x86_darwin)
448                 ;;
449         i386-*-freebsd*)
450                 MKAFS_OSTYPE=FBSD
451                 AC_MSG_RESULT(i386_fbsd)
452                 ;;
453         x86_64-*-freebsd*)
454                 MKAFS_OSTYPE=FBSD
455                 AC_MSG_RESULT(amd64_fbsd)
456                 ;;
457         *-netbsd*)
458                 MKAFS_OSTYPE=NBSD
459                 AC_MSG_RESULT(nbsd)
460                 ;;
461         x86_64-*-openbsd*)
462                 MKAFS_OSTYPE=OBSD
463                 AC_MSG_RESULT(amd64_obsd)
464                 ;;
465         i386-*-openbsd*)
466                 MKAFS_OSTYPE=OBSD
467                 AC_MSG_RESULT(i386_obsd)
468                 ;;
469         *-dragonfly*)
470                 MKAFS_OSTYPE=DFBSD
471                 AC_MSG_RESULT(i386_dfbsd)
472                 ;;
473         *)
474                 AC_MSG_RESULT($system)
475                 ;;
476 esac
477
478 if test "x$with_afs_sysname" != "x"; then
479         AFS_SYSNAME="$with_afs_sysname"
480 else
481         AC_MSG_CHECKING(your AFS sysname)
482         case $host in
483                 i?86-*-openbsd?.?)
484                         v=${host#*openbsd}
485                         vM=${v%.*}
486                         vm=${v#*.}
487                         AFS_SYSNAME="i386_obsd${vM}${vm}"
488                         ;;
489                 sparc64-*-openbsd?.?)
490                         v=${host#*openbsd}
491                         vM=${v%.*}
492                         vm=${v#*.}
493                         AFS_SYSNAME="sparc64_obsd${vM}${vm}"
494                         ;;
495                 x86_64-*-openbsd?.?)
496                         v=${host#*openbsd}
497                         vM=${v%.*}
498                         vm=${v#*.}
499                         AFS_SYSNAME="amd64_obsd${vM}${vm}"
500                         ;;
501                 i?86-*-freebsd*.*)
502                         v=${host#*freebsd}
503                         vM=${v%.*}
504                         vm=${v#*.}
505                         AFS_SYSNAME="i386_fbsd_${vM}${vm}"
506                         ;;
507                 x86_64-*-freebsd*.*)
508                         v=${host#*freebsd}
509                         vM=${v%.*}
510                         vm=${v#*.}
511                         AFS_SYSNAME="amd64_fbsd_${vM}${vm}"
512                         ;;
513                 i386-*-dragonfly?.*)
514                         v=${host#*dragonfly}
515                         vM=${v%.*}
516                         vm=${v#*.}
517                         AFS_SYSNAME="i386_dfbsd_${vM}${vm}"
518                         ;;
519                 i?86-*-netbsd*1.6[[M-Z]]*)
520                         AFS_SYSNAME="i386_nbsd20"
521                         ;;
522                 powerpc-*-netbsd*1.6[[M-Z]]*)
523                         AFS_SYSNAME="ppc_nbsd20"
524                         ;;
525                 *-*-netbsd*)
526                         arch=${host%%-unknown*}
527                         arch=$(echo $arch |sed -e 's/x86_64/amd64/g' \
528                                                -e 's/powerpc/ppc/g')
529                         v=${host#*netbsd}
530                         v=${v#*aout}
531                         v=${v#*ecoff}
532                         v=${v#*elf}
533                         vM=${v%%.*}
534                         vM=${vM%.*}
535                         v=${v#*.}
536                         vm=${v%%.*}
537                         vm=${vm%.*}
538                         vm=${vm%%[[_A-Z]]*}
539                         if test $vm -eq 99 ; then
540                                 vM=$((vM+1))
541                         fi
542                         if test $vM -gt 1 ; then
543                                 vm=0
544                         fi
545                         AFS_SYSNAME="${arch}_nbsd${vM}${vm}"
546                         ;;
547                 hppa*-hp-hpux11.0*)
548                         AFS_SYSNAME="hp_ux110"
549                         ;;
550                 hppa*-hp-hpux11.11)
551                         AFS_SYSNAME="hp_ux11i"
552                         ;;
553                 hppa*-hp-hpux11.23)
554                         AFS_SYSNAME="hp_ux1123"
555                         ;;
556                 ia64-hp-hpux11.22)
557                         AFS_SYSNAME="ia64_hpux1122"
558                         ;;
559                 ia64-hp-hpux*)
560                         AFS_SYSNAME="ia64_hpux1123"
561                         ;;
562                 hppa*-hp-hpux10*)
563                         AFS_SYSNAME="hp_ux102"
564                         ;;
565                 powerpc-apple-darwin7*)
566                         AFS_SYSNAME="ppc_darwin_70"
567                         OSXSDK="macosx10.3"
568                         ;;
569                 powerpc-apple-darwin8.*)
570                         AFS_SYSNAME="ppc_darwin_80"
571                         OSXSDK="macosx10.4"
572                         ;;
573                 i386-apple-darwin8.*)
574                         AFS_SYSNAME="x86_darwin_80"
575                         OSXSDK="macosx10.4"
576                         ;;
577                 powerpc-apple-darwin9.*)
578                         AFS_SYSNAME="ppc_darwin_90"
579                         OSXSDK="macosx10.5"
580                         ;;
581                 i386-apple-darwin9.*)
582                         AFS_SYSNAME="x86_darwin_90"
583                         OSXSDK="macosx10.5"
584                         ;;
585                 i?86-apple-darwin10.*)
586                         AFS_SYSNAME="x86_darwin_100"
587                         OSXSDK="macosx10.6"
588                         ;;
589                 x86_64-apple-darwin10.*)
590                         AFS_SYSNAME="x86_darwin_100"
591                         OSXSDK="macosx10.6"
592                         ;;
593                 arm-apple-darwin10.*)
594                         AFS_SYSNAME="arm_darwin_100"
595                         OSXSDK="iphoneos4.0"
596                         ;;
597                 x86_64-apple-darwin11.*)
598                         AFS_SYSNAME="x86_darwin_110"
599                         OSXSDK="macosx10.7"
600                         ;;
601                 i?86-apple-darwin11.*)
602                         AFS_SYSNAME="x86_darwin_110"
603                         OSXSDK="macosx10.7"
604                         ;;
605                 x86_64-apple-darwin12.*)
606                         AFS_SYSNAME="x86_darwin_120"
607                         OSXSDK="macosx10.8"
608                         ;;
609                 i?86-apple-darwin12.*)
610                         AFS_SYSNAME="x86_darwin_120"
611                         OSXSDK="macosx10.8"
612                         ;;
613                 sparc-sun-solaris2.8)
614                         AFS_SYSNAME="sun4x_58"
615                         ;;
616                 sparc-sun-solaris2.9)
617                         AFS_SYSNAME="sun4x_59"
618                         ;;
619                 sparc-sun-solaris2.10)
620                         AFS_SYSNAME="sun4x_510"
621                         ;;
622                 sparc-sun-solaris2.11)
623                         AFS_SYSNAME="sun4x_511"
624                         ;;
625                 i386-pc-solaris2.8)
626                         AFS_SYSNAME="sunx86_58"
627                         ;;
628                 i386-pc-solaris2.9)
629                         AFS_SYSNAME="sunx86_59"
630                         ;;
631                 i386-pc-solaris2.10)
632                         AFS_SYSNAME="sunx86_510"
633                         ;;
634                 i386-pc-solaris2.11)
635                         AFS_SYSNAME="sunx86_511"
636                         ;;
637                 alpha*-dec-osf4.0*)
638                         AFS_SYSNAME="alpha_dux40"
639                         ;;
640                 alpha*-dec-osf5.0*)
641                         AFS_SYSNAME="alpha_dux50"
642                         ;;
643                 alpha*-dec-osf5.1*)
644                         AFS_SYSNAME="alpha_dux51"
645                         ;;
646                 mips-sgi-irix6.5)
647                         AFS_SYSNAME="sgi_65"
648                         ;;
649                 ia64-*-linux*)
650                         AFS_SYSNAME="ia64_linuxXX"
651                         ;;
652                 powerpc-*-linux*)
653                         AFS_SYSNAME="`/bin/arch`_linuxXX"
654                         ;;
655                 powerpc64-*-linux*)
656                         AFS_SYSNAME="ppc64_linuxXX"
657                         ;;
658                 alpha*-linux*)
659                         AFS_SYSNAME="alpha_linux_XX"
660                         ;;
661                 s390-*-linux*)
662                         AFS_SYSNAME="s390_linuxXX"
663                         ;;
664                 s390x-*-linux*)
665                         AFS_SYSNAME="s390x_linuxXX"
666                         ;;
667                 sparc-*-linux*)
668                         AFS_SYSNAME="`/bin/arch`_linuxXX"
669                         ;;
670                 sparc64-*-linux*)
671                         AFS_SYSNAME="sparc64_linuxXX"
672                         ;;
673                 i?86-*-linux*)
674                         AFS_SYSNAME="i386_linuxXX"
675                         ;;
676                 arm*-linux*)
677                         AFS_SYSNAME="arm_linuxXX"
678                         ;;
679                 parisc-*-linux-gnu|hppa-*-linux-gnu)
680                         AFS_SYSNAME="parisc_linuxXX"
681                         enable_pam="no"
682                         ;;
683                 power*-ibm-aix4.2*)
684                         AFS_SYSNAME="rs_aix42"
685                         enable_pam="no"
686                         ;;
687                 power*-ibm-aix4.3*)
688                         AFS_SYSNAME="rs_aix42"
689                         enable_pam="no"
690                         ;;
691                 power*-ibm-aix5.1*)
692                         AFS_SYSNAME="rs_aix51"
693                         enable_pam="no"
694                         ;;
695                 power*-ibm-aix5.2*)
696                         AFS_SYSNAME="rs_aix52"
697                         enable_pam="no"
698                         ;;
699                 power*-ibm-aix5.3*)
700                         AFS_SYSNAME="rs_aix53"
701                         enable_pam="no"
702                         ;;
703                 power*-ibm-aix6.1*)
704                         AFS_SYSNAME="rs_aix61"
705                         enable_pam="no"
706                         ;;
707                 x86_64-*-linux-gnu)
708                         AFS_SYSNAME="amd64_linuxXX"
709                         enable_pam="yes"
710                         ;;
711                 *)
712                         AC_MSG_ERROR(An AFS sysname is required)
713                         exit 1
714                         ;;
715         esac
716         case $AFS_SYSNAME in
717                 *_linux* | *_umlinux*)
718                         if test "x${AFS_SYSKVERS}" = "x"; then
719                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
720                         fi
721                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
722                         AFS_SYSNAME="$_AFS_SYSNAME"
723                         AC_TRY_KBUILD(
724                          [],
725                          [#ifndef CONFIG_USERMODE
726                           #error not UML
727                           #endif],
728                          ac_cv_linux_is_uml=yes,)
729                         if test "${ac_cv_linux_is_uml}" = yes; then
730                          _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/linux/umlinux/`
731                         fi
732                         AFS_SYSNAME="$_AFS_SYSNAME"
733                         ;;
734         esac
735         AC_MSG_RESULT($AFS_SYSNAME)
736 fi
737
738 case $AFS_SYSNAME in
739         *_darwin*)
740                 AC_CHECK_HEADERS(crt_externs.h)
741                 DARWIN_PLIST=src/libafs/afs.${AFS_SYSNAME}.plist
742                 DARWIN_INFOFILE=afs.${AFS_SYSNAME}.plist
743                 AC_SUBST(OSXSDK)
744                 ;;
745 esac
746
747 dnl Some hosts have a separate common param file they should include.  Figure
748 dnl out if we're on one of them now that we know the sysname.
749 case $AFS_SYSNAME in
750     *_nbsd15)   AFS_PARAM_COMMON=param.nbsd15.h  ;;
751     *_nbsd16)   AFS_PARAM_COMMON=param.nbsd16.h  ;;
752     *_nbsd20)   AFS_PARAM_COMMON=param.nbsd20.h  ;;
753     *_nbsd21)   AFS_PARAM_COMMON=param.nbsd21.h  ;;
754     *_nbsd30)   AFS_PARAM_COMMON=param.nbsd30.h  ;;
755     *_nbsd40)   AFS_PARAM_COMMON=param.nbsd40.h  ;;
756     *_nbsd50)   AFS_PARAM_COMMON=param.nbsd50.h  ;;
757     *_nbsd60)   AFS_PARAM_COMMON=param.nbsd60.h  ;;
758     *_obsd31)   AFS_PARAM_COMMON=param.obsd31.h  ;;
759     *_obsd32)   AFS_PARAM_COMMON=param.obsd32.h  ;;
760     *_obsd33)   AFS_PARAM_COMMON=param.obsd33.h  ;;
761     *_obsd34)   AFS_PARAM_COMMON=param.obsd34.h  ;;
762     *_obsd35)   AFS_PARAM_COMMON=param.obsd35.h  ;;
763     *_obsd36)   AFS_PARAM_COMMON=param.obsd36.h  ;;
764     *_obsd37)   AFS_PARAM_COMMON=param.obsd37.h  ;;
765     *_obsd38)   AFS_PARAM_COMMON=param.obsd38.h  ;;
766     *_obsd39)   AFS_PARAM_COMMON=param.obsd39.h  ;;
767     *_obsd40)   AFS_PARAM_COMMON=param.obsd40.h  ;;
768     *_obsd41)   AFS_PARAM_COMMON=param.obsd41.h  ;;
769     *_obsd42)   AFS_PARAM_COMMON=param.obsd42.h  ;;
770     *_obsd43)   AFS_PARAM_COMMON=param.obsd43.h  ;;
771     *_obsd44)   AFS_PARAM_COMMON=param.obsd44.h  ;;
772     *_obsd45)   AFS_PARAM_COMMON=param.obsd45.h  ;;
773     *_obsd46)   AFS_PARAM_COMMON=param.obsd46.h  ;;
774     *_obsd47)   AFS_PARAM_COMMON=param.obsd47.h  ;;
775     *_obsd48)   AFS_PARAM_COMMON=param.obsd48.h  ;;
776     *_obsd49)   AFS_PARAM_COMMON=param.obsd49.h  ;;
777     *_obsd50)   AFS_PARAM_COMMON=param.obsd50.h  ;;
778     *_obsd51)   AFS_PARAM_COMMON=param.obsd51.h  ;;
779     *_obsd52)   AFS_PARAM_COMMON=param.obsd52.h  ;;
780     *_obsd53)   AFS_PARAM_COMMON=param.obsd53.h  ;;
781     *_linux22)  AFS_PARAM_COMMON=param.linux22.h ;;
782     *_linux24)  AFS_PARAM_COMMON=param.linux24.h ;;
783     *_linux26)  AFS_PARAM_COMMON=param.linux26.h ;;
784 # Linux alpha adds an extra underscore for no good reason.
785     *_linux_22) AFS_PARAM_COMMON=param.linux22.h ;;
786     *_linux_24) AFS_PARAM_COMMON=param.linux24.h ;;
787     *_linux_26) AFS_PARAM_COMMON=param.linux26.h ;;
788 esac
789
790 OPENAFS_OSCONF
791
792 case $AFS_SYSNAME in *_linux* | *_umlinux*)
793
794                 # Add (sub-) architecture-specific paths needed by conftests
795                 case $AFS_SYSNAME  in
796                         *_umlinux26)
797                                 UMLINUX26_FLAGS="-I$LINUX_KERNEL_PATH/arch/um/include"
798                                 UMLINUX26_FLAGS="$UMLINUX26_FLAGS -I$LINUX_KERNEL_PATH/arch/um/kernel/tt/include"
799                                 UMLINUX26_FLAGS="$UMLINUX26_FLAGS -I$LINUX_KERNEL_PATH/arch/um/kernel/skas/include"
800                                 CPPFLAGS="$CPPFLAGS $UMLINUX26_FLAGS"
801                 esac
802
803                 if test "x$enable_kernel_module" = "xyes"; then
804                  if test "x$enable_debug_kernel" = "xno"; then
805                         LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -fomit-frame-pointer"
806                  fi
807                  OPENAFS_GCC_SUPPORTS_MARCH
808                  AC_SUBST(P5PLUS_KOPTS)
809                  OPENAFS_GCC_NEEDS_NO_STRENGTH_REDUCE
810                  OPENAFS_GCC_NEEDS_NO_STRICT_ALIASING
811                  OPENAFS_GCC_SUPPORTS_NO_COMMON
812                  OPENAFS_GCC_SUPPORTS_PIPE
813                  AC_SUBST(LINUX_GCC_KOPTS)
814
815                  dnl Setup the kernel build environment
816                  LINUX_KBUILD_USES_EXTRA_CFLAGS
817                  LINUX_KERNEL_COMPILE_WORKS
818
819                  dnl Check for header files
820                  AC_CHECK_LINUX_HEADER([config.h])
821                  AC_CHECK_LINUX_HEADER([completion.h])
822                  AC_CHECK_LINUX_HEADER([exportfs.h])
823                  AC_CHECK_LINUX_HEADER([freezer.h])
824                  AC_CHECK_LINUX_HEADER([key-type.h])
825                  AC_CHECK_LINUX_HEADER([semaphore.h])
826                  AC_CHECK_LINUX_HEADER([seq_file.h])
827
828                  dnl Type existence checks
829                  AC_CHECK_LINUX_TYPE([struct vfs_path], [dcache.h])
830
831                  dnl Check for structure elements
832                  AC_CHECK_LINUX_STRUCT([address_space_operations],
833                                        [write_begin], [fs.h])
834                  AC_CHECK_LINUX_STRUCT([backing_dev_info], [name],
835                                        [backing-dev.h])
836                  AC_CHECK_LINUX_STRUCT([cred], [session_keyring], [cred.h])
837                  AC_CHECK_LINUX_STRUCT([ctl_table], [ctl_name], [sysctl.h])
838                  AC_CHECK_LINUX_STRUCT([dentry_operations], [d_automount], [dcache.h])
839                  AC_CHECK_LINUX_STRUCT([inode], [i_alloc_sem], [fs.h])
840                  AC_CHECK_LINUX_STRUCT([inode], [i_blkbits], [fs.h])
841                  AC_CHECK_LINUX_STRUCT([inode], [i_blksize], [fs.h])
842                  AC_CHECK_LINUX_STRUCT([inode], [i_mutex], [fs.h])
843                  AC_CHECK_LINUX_STRUCT([inode], [i_security], [fs.h])
844                  AC_CHECK_LINUX_STRUCT([file_operations], [flock], [fs.h])
845                  AC_CHECK_LINUX_STRUCT([file_operations], [sendfile], [fs.h])
846                  AC_CHECK_LINUX_STRUCT([file_system_type], [mount], [fs.h])
847                  AC_CHECK_LINUX_STRUCT([filename], [name], [fs.h])
848                  AC_CHECK_LINUX_STRUCT([inode_operations], [truncate], [fs.h])
849                  AC_CHECK_LINUX_STRUCT([key_type], [preparse], [key-type.h])
850                  AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
851                  AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
852                  AC_CHECK_LINUX_STRUCT([super_block], [s_bdi], [fs.h])
853                  AC_CHECK_LINUX_STRUCT([super_block], [s_d_op], [fs.h])
854                  AC_CHECK_LINUX_STRUCT([super_operations], [alloc_inode],
855                                        [fs.h])
856                  AC_CHECK_LINUX_STRUCT([super_operations], [evict_inode],
857                                        [fs.h])
858                  AC_CHECK_LINUX_STRUCT([task_struct], [cred], [sched.h])
859                  AC_CHECK_LINUX_STRUCT([task_struct], [exit_state], [sched.h])
860                  AC_CHECK_LINUX_STRUCT([task_struct], [parent], [sched.h])
861                  AC_CHECK_LINUX_STRUCT([task_struct], [real_parent], [sched.h])
862                  AC_CHECK_LINUX_STRUCT([task_struct], [rlim], [sched.h])
863                  AC_CHECK_LINUX_STRUCT([task_struct], [sig], [sched.h])
864                  AC_CHECK_LINUX_STRUCT([task_struct], [sighand], [sched.h])
865                  AC_CHECK_LINUX_STRUCT([task_struct], [sigmask_lock], [sched.h])
866                  AC_CHECK_LINUX_STRUCT([task_struct], [tgid], [sched.h])
867                  AC_CHECK_LINUX_STRUCT([task_struct], [thread_info], [sched.h])
868                  LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM
869
870                  dnl Check for typed structure elements
871                  AC_CHECK_LINUX_TYPED_STRUCT([read_descriptor_t],
872                                              [buf], [fs.h])
873
874                  dnl Function existence checks
875
876                  AC_CHECK_LINUX_FUNC([bdi_init],
877                                      [#include <linux/backing-dev.h>],
878                                      [bdi_init(NULL);])
879                  AC_CHECK_LINUX_FUNC([PageChecked],
880                                      [#include <linux/mm.h>
881 #include <linux/page-flags.h>],
882                                      [struct page *_page;
883                                       int bchecked = PageChecked(_page);])
884                  AC_CHECK_LINUX_FUNC([PageFsMisc],
885                                      [#include <linux/mm.h>
886 #include <linux/page-flags.h>],
887                                      [struct page *_page;
888                                       int bchecked = PageFsMisc(_page);])
889                  AC_CHECK_LINUX_FUNC([clear_inode],
890                                      [#include <linux/fs.h>],
891                                      [clear_inode(NULL);])
892                  AC_CHECK_LINUX_FUNC([current_kernel_time],
893                                      [#include <linux/time.h>],
894                                      [struct timespec s;
895                                       s = current_kernel_time();])
896                  AC_CHECK_LINUX_FUNC([d_alloc_anon],
897                                      [#include <linux/fs.h>],
898                                      [d_alloc_anon(NULL);])
899                  AC_CHECK_LINUX_FUNC([d_make_root],
900                                      [#include <linux/fs.h>],
901                                      [d_make_root(NULL);])
902                  AC_CHECK_LINUX_FUNC([do_sync_read],
903                                      [#include <linux/fs.h>],
904                                      [do_sync_read(NULL, NULL, 0, NULL);])
905                  AC_CHECK_LINUX_FUNC([find_task_by_pid],
906                                      [#include <linux/sched.h>],
907                                      [pid_t p; find_task_by_pid(p);])
908                  AC_CHECK_LINUX_FUNC([generic_file_aio_read],
909                                      [#include <linux/fs.h>],
910                                      [generic_file_aio_read(NULL,NULL,0,0);])
911                  AC_CHECK_LINUX_FUNC([grab_cache_page_write_begin],
912                                      [#include <linux/pagemap.h>],
913                                      [grab_cache_page_write_begin(NULL, 0, 0);])
914                  AC_CHECK_LINUX_FUNC([hlist_unhashed],
915                                      [#include <linux/list.h>],
916                                      [hlist_unhashed(0);])
917                  AC_CHECK_LINUX_FUNC([i_size_read],
918                                      [#include <linux/fs.h>],
919                                      [i_size_read(NULL);])
920                  AC_CHECK_LINUX_FUNC([inode_setattr],
921                                      [#include <linux/fs.h>],
922                                      [inode_setattr(NULL, NULL);])
923                  AC_CHECK_LINUX_FUNC([kernel_setsockopt],
924                                      [#include <linux/net.h>],
925                                      [kernel_setsockopt(NULL, 0, 0, NULL, 0);])
926                  AC_CHECK_LINUX_FUNC([page_follow_link],
927                                      [#include <linux/fs.h>],
928                                      [page_follow_link(0,0);])
929                  AC_CHECK_LINUX_FUNC([page_offset],
930                                      [#include <linux/pagemap.h>],
931                                      [page_offset(NULL);])
932                  AC_CHECK_LINUX_FUNC([pagevec_lru_add_file],
933                                      [#include <linux/pagevec.h>],
934                                      [__pagevec_lru_add_file(NULL);])
935                  AC_CHECK_LINUX_FUNC([path_lookup],
936                                      [#include <linux/fs.h>
937                                       #include <linux/namei.h>],
938                                      [path_lookup(NULL, 0, NULL);])
939                  AC_CHECK_LINUX_FUNC([proc_create],
940                                      [#include <linux/proc_fs.h>],
941                                      [proc_create(NULL, 0, NULL, NULL);])
942                  AC_CHECK_LINUX_FUNC([rcu_read_lock],
943                                      [#include <linux/rcupdate.h>],
944                                      [rcu_read_lock();])
945                  AC_CHECK_LINUX_FUNC([set_nlink],
946                                      [#include <linux/fs.h>],
947                                      [set_nlink(NULL, 1);])
948                  AC_CHECK_LINUX_FUNC([splice_direct_to_actor],
949                                      [#include <linux/splice.h>],
950                                      [splice_direct_to_actor(NULL,NULL,NULL);])
951                  AC_CHECK_LINUX_FUNC([svc_addr_in],
952                                      [#include <linux/sunrpc/svc.h>],
953                                      [svc_addr_in(NULL);])
954                  AC_CHECK_LINUX_FUNC([zero_user_segments],
955                                      [#include <linux/highmem.h>],
956                                      [zero_user_segments(NULL, 0, 0, 0, 0);])
957                  AC_CHECK_LINUX_FUNC([noop_fsync],
958                                      [#include <linux/fs.h>],
959                                      [void *address = &noop_fsync; printk("%p\n", address)];)
960                  AC_CHECK_LINUX_FUNC([kthread_run],
961                                      [#include <linux/kernel.h>
962                                       #include <linux/kthread.h>],
963                                      [kthread_run(NULL, NULL, "test");])
964
965                  dnl Consequences - things which get set as a result of the
966                  dnl                above tests
967                  AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
968                        [AC_DEFINE([AFS_NONFSTRANS], 1,
969                                   [define to disable the nfs translator])])
970
971                  dnl Assorted more complex tests
972                  LINUX_AIO_NONVECTOR
973                  LINUX_EXPORTS_PROC_ROOT_FS
974                  LINUX_KMEM_CACHE_INIT
975                  LINUX_HAVE_KMEM_CACHE_T
976                  LINUX_KMEM_CACHE_CREATE_TAKES_DTOR
977                  LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID
978                  LINUX_D_PATH_TAKES_STRUCT_PATH
979                  LINUX_NEW_EXPORT_OPS
980                  LINUX_INODE_SETATTR_RETURN_TYPE
981                  LINUX_IOP_I_CREATE_TAKES_NAMEIDATA
982                  LINUX_IOP_I_LOOKUP_TAKES_NAMEIDATA
983                  LINUX_IOP_I_PERMISSION_TAKES_FLAGS
984                  LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA
985                  LINUX_IOP_I_PUT_LINK_TAKES_COOKIE
986                  LINUX_DOP_D_DELETE_TAKES_CONST
987                  LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA
988                  LINUX_FOP_F_FLUSH_TAKES_FL_OWNER_T
989                  LINUX_FOP_F_FSYNC_TAKES_DENTRY
990                  LINUX_FOP_F_FSYNC_TAKES_RANGE
991                  LINUX_AOP_WRITEBACK_CONTROL
992                  LINUX_FS_STRUCT_FOP_HAS_SPLICE
993                  LINUX_KERNEL_POSIX_LOCK_FILE_WAIT_ARG
994                  LINUX_POSIX_TEST_LOCK_RETURNS_CONFLICT
995                  LINUX_POSIX_TEST_LOCK_CONFLICT_ARG
996                  LINUX_KERNEL_SOCK_CREATE
997                  LINUX_EXPORTS_KEY_TYPE_KEYRING
998                  LINUX_NEED_RHCONFIG
999                  LINUX_RECALC_SIGPENDING_ARG_TYPE
1000                  LINUX_EXPORTS_TASKLIST_LOCK
1001                  LINUX_GET_SB_HAS_STRUCT_VFSMOUNT
1002                  LINUX_STATFS_TAKES_DENTRY
1003                  LINUX_REFRIGERATOR
1004                  LINUX_HAVE_TRY_TO_FREEZE
1005                  LINUX_LINUX_KEYRING_SUPPORT
1006                  LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK
1007                  LINUX_KEY_ALLOC_NEEDS_CRED
1008                  LINUX_INIT_WORK_HAS_DATA
1009                  LINUX_REGISTER_SYSCTL_TABLE_NOFLAG
1010                  LINUX_HAVE_DCACHE_LOCK
1011                  LINUX_D_COUNT_IS_INT
1012                  LINUX_IOP_MKDIR_TAKES_UMODE_T
1013                  LINUX_IOP_CREATE_TAKES_UMODE_T
1014                  LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES
1015                  LINUX_KMAP_ATOMIC_TAKES_NO_KM_TYPE
1016                  LINUX_DENTRY_OPEN_TAKES_PATH
1017                  LINUX_D_ALIAS_IS_HLIST
1018                  LINUX_HLIST_ITERATOR_NO_NODE
1019                  LINUX_IOP_I_CREATE_TAKES_BOOL
1020                  LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED
1021                  LINUX_IOP_LOOKUP_TAKES_UNSIGNED
1022
1023                  dnl If we are guaranteed that keyrings will work - that is
1024                  dnl  a) The kernel has keyrings enabled
1025                  dnl  b) The code is new enough to give us a key_type_keyring
1026                  dnl then we just disable syscall probing unless we've been
1027                  dnl told otherwise
1028
1029                  AS_IF([test "$enable_linux_syscall_probing" = "maybe"],
1030                    [AS_IF([test "$ac_cv_linux_keyring_support" = "yes" -a "$ac_cv_linux_exports_key_type_keyring" = "yes"],
1031                           [enable_linux_syscall_probing="no"],
1032                           [enable_linux_syscall_probing="yes"])
1033                  ])
1034
1035                  dnl Syscall probing needs a few tests of its own, and just
1036                  dnl won't work if the kernel doesn't export init_mm
1037                  AS_IF([test "$enable_linux_syscall_probing" = "yes"], [
1038                    LINUX_EXPORTS_INIT_MM
1039                    AS_IF([test "$ac_cv_linux_exports_init_mm" = "no"], [
1040                      AC_MSG_ERROR(
1041                        [Can't do syscall probing without exported init_mm])
1042                    ])
1043                    LINUX_EXPORTS_SYS_CHDIR
1044                    LINUX_EXPORTS_SYS_OPEN
1045                    AC_DEFINE(ENABLE_LINUX_SYSCALL_PROBING, 1,
1046                              [define to enable syscall table probes])
1047                  ])
1048
1049                  dnl Packaging and SMP build
1050                  if test "x$with_linux_kernel_packaging" != "xyes" ; then
1051                    LINUX_WHICH_MODULES
1052                  else
1053                    AC_SUBST(MPS,'SP')
1054                  fi
1055
1056                  dnl Syscall probing
1057                  if test "x$ac_cv_linux_config_modversions" = "xno" -o $AFS_SYSKVERS -ge 26; then
1058                    AS_IF([test "$enable_linux_syscall_probing" = "yes"], [
1059                      AC_MSG_WARN([Cannot determine sys_call_table status. assuming it isn't exported])
1060                    ])
1061                    ac_cv_linux_exports_sys_call_table=no
1062                    if test -f "$LINUX_KERNEL_PATH/include/asm/ia32_unistd.h"; then
1063                      ac_cv_linux_exports_ia32_sys_call_table=yes
1064                    fi
1065                  else
1066                    LINUX_EXPORTS_KALLSYMS_ADDRESS
1067                    LINUX_EXPORTS_KALLSYMS_SYMBOL
1068                    LINUX_EXPORTS_SYS_CALL_TABLE
1069                    LINUX_EXPORTS_IA32_SYS_CALL_TABLE
1070                    if test "x$ac_cv_linux_exports_sys_call_table" = "xno"; then
1071                          linux_syscall_method=none
1072                          if test "x$ac_cv_linux_exports_init_mm" = "xyes"; then
1073                             linux_syscall_method=scan
1074                             if test "x$ac_cv_linux_exports_kallsyms_address" = "xyes"; then
1075                                linux_syscall_method=scan_with_kallsyms_address
1076                             fi
1077                          fi
1078                          if test "x$ac_cv_linux_exports_kallsyms_symbol" = "xyes"; then
1079                             linux_syscall_method=kallsyms_symbol
1080                          fi
1081                          if test "x$linux_syscall_method" = "xnone"; then
1082                             AC_MSG_WARN([no available sys_call_table access method -- guessing scan])
1083                             linux_syscall_method=scan
1084                          fi
1085                    fi
1086                  fi
1087                  if test -f "$LINUX_KERNEL_PATH/include/linux/in_systm.h"; then
1088                   AC_DEFINE(HAVE_IN_SYSTM_H, 1, [define if you have in_systm.h header file])
1089                  fi
1090                  if test -f "$LINUX_KERNEL_PATH/include/linux/mm_inline.h"; then
1091                   AC_DEFINE(HAVE_MM_INLINE_H, 1, [define if you have mm_inline.h header file])
1092                  fi
1093                  if test "x$ac_cv_linux_kernel_page_follow_link" = "xyes" -o "x$ac_cv_linux_func_i_put_link_takes_cookie" = "xyes"; then
1094                   AC_DEFINE(USABLE_KERNEL_PAGE_SYMLINK_CACHE, 1, [define if your kernel has a usable symlink cache API])
1095                  else
1096                   AC_MSG_WARN([your kernel does not have a usable symlink cache API])
1097                  fi
1098                 :
1099                 fi
1100 dnl Linux-only, but just enable always.
1101                 AC_DEFINE(AFS_CACHE_BYPASS, 1, [define to activate cache bypassing Unix client])
1102 esac
1103
1104 AC_CACHE_CHECK([if compiler has __sync_add_and_fetch],
1105     [ac_cv_sync_fetch_and_add],
1106     [AC_TRY_LINK(, [int var; return __sync_add_and_fetch(&var, 1);],
1107                     [ac_cv_sync_fetch_and_add=yes],
1108                     [ac_cv_sync_fetch_and_add=no])
1109 ])
1110 AS_IF([test "$ac_cv_sync_fetch_and_add" = "yes"],
1111       [AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD, 1,
1112                 [define if your C compiler has __sync_add_and_fetch])])
1113
1114 AC_CACHE_CHECK([if struct sockaddr has sa_len field],
1115     [ac_cv_sockaddr_len],
1116     [AC_TRY_COMPILE( [#include <sys/types.h>
1117 #include <sys/socket.h>],
1118                      [struct sockaddr *a; a->sa_len=0;],
1119                      [ac_cv_sockaddr_len=yes],
1120                      [ac_cv_sockaddr_len=no])
1121 ])
1122 AS_IF([test "$ac_cv_sockaddr_len" = "yes"],
1123       [AC_DEFINE(STRUCT_SOCKADDR_HAS_SA_LEN, 1,
1124                  [define if you struct sockaddr sa_len])])
1125
1126 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
1127         echo Skipping library tests because they confuse Irix.
1128 else
1129   AC_SEARCH_LIBS([socket], [socket inet])
1130   AC_SEARCH_LIBS([connect], [nsl])
1131   AC_SEARCH_LIBS([gethostbyname], [dns nsl resolv])
1132
1133   dnl darwin wants it, aix hates it
1134   AC_MSG_CHECKING(for the useability of arpa/nameser_compat.h)
1135   AC_TRY_COMPILE([
1136   #include <stdlib.h>
1137   #include <stdio.h>
1138   #include <sys/types.h>
1139   #include <sys/socket.h>
1140   #include <netinet/in.h>
1141   #include <arpa/inet.h>
1142   #include <arpa/nameser.h>
1143   #include <arpa/nameser_compat.h>
1144   #include <resolv.h>
1145   ], [static int i; i = 0;],
1146   [AC_MSG_RESULT(yes)
1147    AC_DEFINE(HAVE_ARPA_NAMESER_COMPAT_H, 1, [define if arpa/nameser_compat.h exists])],
1148   [AC_MSG_RESULT(no)
1149    ])
1150
1151   openafs_save_libs="$LIBS"
1152   AC_MSG_CHECKING([for res_search])
1153   AC_FUNC_RES_SEARCH
1154
1155   if test "$ac_cv_func_res_search" = no; then
1156       for lib in dns nsl resolv; do
1157         if test "$ac_cv_func_res_search" != yes; then
1158           LIBS="-l$lib $LIBS"
1159           AC_FUNC_RES_SEARCH
1160           LIBS="$openafs_save_libs"
1161         fi
1162       done    
1163       if test "$ac_cv_func_res_search" = yes; then
1164         LIB_AFSDB="-l$lib"
1165         AC_DEFINE(HAVE_RES_SEARCH, 1, [])
1166         AC_MSG_RESULT([yes, in lib$lib])
1167       else
1168         AC_MSG_RESULT(no)
1169       fi
1170   else
1171     AC_DEFINE(HAVE_RES_SEARCH, 1, [])
1172     AC_MSG_RESULT(yes)
1173   fi
1174   
1175 fi
1176 XLIBS="$LIB_AFSDB $XLIBS"
1177
1178 AC_CHECK_RESOLV_RETRANS
1179
1180 AC_CACHE_CHECK([for setsockopt(, SOL_IP, IP_RECVERR)],
1181     [ac_cv_setsockopt_iprecverr],
1182     [AC_TRY_COMPILE( [
1183 #include <sys/types.h>
1184 #include <sys/socket.h>
1185 #include <netinet/in.h>],
1186 [int on=1;
1187 setsockopt(0, SOL_IP, IP_RECVERR, &on, sizeof(on));],
1188         [ac_cv_setsockopt_iprecverr=yes],
1189         [ac_cv_setsockopt_iprecverr=no])])
1190
1191 AS_IF([test "$ac_cv_setsockopt_iprecverr" = "yes"],
1192       [AC_DEFINE([HAVE_SETSOCKOPT_IP_RECVERR], [1],
1193                  [define if we can receive socket errors via IP_RECVERR])])
1194
1195 PTHREAD_LIBS=error
1196 if test "x$MKAFS_OSTYPE" = OBSD; then
1197         PTHREAD_LIBS="-pthread"
1198 fi
1199 if test "x$MKAFS_OSTYPE" = xDFBSD; then
1200         PTHREAD_LIBS="-pthread"
1201 fi
1202 if test "x$PTHREAD_LIBS" = xerror; then
1203         AC_CHECK_LIB(pthread, pthread_attr_init,
1204                 PTHREAD_LIBS="-lpthread")
1205 fi
1206 if test "x$PTHREAD_LIBS" = xerror; then
1207         AC_CHECK_LIB(pthreads, pthread_attr_init,
1208                 PTHREAD_LIBS="-lpthreads")
1209 fi
1210 if test "x$PTHREAD_LIBS" = xerror; then
1211         AC_CHECK_LIB(c_r, pthread_attr_init,
1212                 PTHREAD_LIBS="-lc_r")
1213 fi
1214 if test "x$PTHREAD_LIBS" = xerror; then
1215         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
1216 fi
1217 if test "x$PTHREAD_LIBS" = xerror; then
1218         # pthread_attr_init is a macro under HPUX 11.0 and 11.11
1219         AC_CHECK_LIB(pthread, pthread_attr_destroy,
1220                 PTHREAD_LIBS="-lpthread")
1221 fi
1222 if test "x$PTHREAD_LIBS" = xerror; then
1223         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
1224 fi
1225 AC_SUBST(PTHREAD_LIBS)
1226
1227 HOST_CPU="$host_cpu"
1228
1229 if test "x$with_bsd_kernel_headers" != "x"; then
1230         BSD_KERNEL_PATH="$with_bsd_kernel_headers"
1231 else
1232         BSD_KERNEL_PATH="/usr/src/sys"
1233 fi
1234
1235 if test "x$with_bsd_kernel_build" != "x"; then
1236         BSD_KERNEL_BUILD="$with_bsd_kernel_build"
1237 else
1238         case $AFS_SYSNAME in
1239                 *_fbsd_*)
1240                         BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"
1241                         ;;
1242                 *_nbsd*)
1243                         BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/arch/${HOST_CPU}/compile/GENERIC"
1244         esac
1245 fi
1246
1247 # Fast restart
1248 if test "$enable_supergroups" = "yes"; then
1249         AC_DEFINE(SUPERGROUPS, 1, [define if you want to have support for nested pts groups])
1250 fi
1251
1252 if test "$enable_bitmap_later" = "yes"; then
1253         AC_DEFINE(BITMAP_LATER, 1, [define if you want to salvager to check bitmasks later])
1254 fi
1255
1256 if test "$enable_unix_sockets" = "yes"; then
1257         AC_DEFINE(USE_UNIX_SOCKETS, 1, [define if you want to use UNIX sockets for fssync.])
1258         USE_UNIX_SOCKETS="yes"
1259 else
1260         USE_UNIX_SOCKETS="no"
1261 fi
1262 AC_SUBST(USE_UNIX_SOCKETS)
1263
1264 if test "$enable_namei_fileserver" = "yes"; then
1265         AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
1266         VFSCK=""
1267 else
1268         if test "$enable_namei_fileserver" = "default"; then
1269                 case $host in
1270                         *-solaris2.10*)
1271                                 AC_MSG_WARN(Some Solaris 10 versions are not safe with the inode fileserver. Forcing namei. Override with --disable-namei-fileserver)
1272                                 AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
1273                                 VFSCK=""
1274                                 ;;
1275                         *-solaris2.11*)
1276                                 AC_MSG_WARN(Solaris 11 versions are not safe with the inode fileserver. Forcing namei. Override with --disable-namei-fileserver)
1277                                 AC_DEFINE(AFS_NAMEI_ENV, 1, [define if you want to want namei fileserver])
1278                                 VFSCK=""
1279                                 ;;
1280                         *)
1281                                 VFSCK="vfsck"
1282                                 ;;
1283                 esac
1284         else
1285                 VFSCK="vfsck"
1286         fi
1287 fi
1288
1289 dnl check for tivoli
1290 AC_MSG_CHECKING(for tivoli tsm butc support)
1291 XBSA_CFLAGS=""
1292 if test "$enable_tivoli_tsm" = "yes"; then
1293         XBSADIR1=/usr/tivoli/tsm/client/api/bin/xopen
1294         XBSADIR2=/opt/tivoli/tsm/client/api/bin/xopen
1295         XBSADIR3=/usr/tivoli/tsm/client/api/bin/sample
1296         XBSADIR4=/opt/tivoli/tsm/client/api/bin/sample
1297
1298         if test -r "$XBSADIR3/dsmapifp.h"; then
1299                 XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR3"
1300                 XBSA_XLIBS="-ldl"
1301                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1302         elif test -r "$XBSADIR4/dsmapifp.h"; then
1303                 XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I$XBSADIR4"
1304                 XBSA_XLIBS="-ldl"
1305                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1306         elif test -r "$XBSADIR1/xbsa.h"; then
1307                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR1"
1308                 XBSA_XLIBS=""
1309                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1310         elif test -r "$XBSADIR2/xbsa.h"; then
1311                 XBSA_CFLAGS="-Dxbsa -I$XBSADIR2"
1312                 XBSA_XLIBS=""
1313                 AC_MSG_RESULT([yes, $XBSA_CFLAGS])
1314         else
1315                 AC_MSG_RESULT([no, missing xbsa.h and dsmapifp.h header files])
1316         fi
1317 else
1318         AC_MSG_RESULT([no])
1319 fi
1320 AC_SUBST(XBSA_CFLAGS)
1321 AC_SUBST(XBSA_XLIBS) 
1322
1323 dnl checks for header files.
1324 AC_HEADER_STDC
1325 AC_HEADER_SYS_WAIT
1326 AC_HEADER_DIRENT
1327 AC_CHECK_HEADERS([ \
1328                    arpa/inet.h \
1329                    arpa/nameser.h \
1330                    curses.h\
1331                    direct.h \
1332                    et/com_err.h \
1333                    errno.h \
1334                    fcntl.h \
1335                    grp.h \
1336                    math.h \
1337                    mntent.h \
1338                    ncurses.h \
1339                    ncurses/ncurses.h \
1340                    netdb.h \
1341                    netinet/in.h \
1342                    pthread_np.h \
1343                    pwd.h \
1344                    regex.h \
1345                    security/pam_appl.h \
1346                    signal.h \
1347                    stdint.h \
1348                    stdio_ext.h \
1349                    stdlib.h \
1350                    string.h \
1351                    strings.h \
1352                    sys/bitypes.h \
1353                    sys/bswap.h \
1354                    sys/dk.h \
1355                    sys/fcntl.h \
1356                    sys/file.h \
1357                    sys/fs_types.h \
1358                    sys/fstyp.h \
1359                    sys/ioctl.h \
1360                    sys/ipc.h \
1361                    sys/lockf.h \
1362                    sys/map.h \
1363                    sys/mount.h \
1364                    sys/mntent.h \
1365                    sys/mnttab.h \
1366                    sys/pag.h \
1367                    sys/param.h \
1368                    sys/resource.h \
1369                    sys/select.h \
1370                    sys/statfs.h \
1371                    sys/statvfs.h \
1372                    sys/socket.h \
1373                    sys/sysctl.h \
1374                    sys/time.h \
1375                    sys/types.h \
1376                    sys/uio.h \
1377                    sys/un.h \
1378                    sys/vfs.h \
1379                    syslog.h \
1380                    termios.h \
1381                    time.h \
1382                    ucontext.h \
1383                    unistd.h \
1384                    windows.h \
1385                 ])
1386
1387 AC_CHECK_HEADERS([resolv.h], [], [], [AC_INCLUDES_DEFAULT
1388 #ifdef HAVE_NETINET_IN_H
1389 # include <netinet/in.h>
1390 #endif])
1391
1392 AC_CHECK_HEADERS([net/if.h],[],[],[AC_INCLUDES_DEFAULT
1393 #ifdef HAVE_SYS_SOCKET_H
1394 # include <sys/socket.h>
1395 #endif])
1396
1397 AC_CHECK_HEADERS([netinet/if_ether.h],[],[],[AC_INCLUDES_DEFAULT
1398 #ifdef HAVE_SYS_SOCKET_H
1399 # include <sys/socket.h>
1400 #endif
1401 #ifdef HAVE_NETINET_IN_H
1402 # include <netinet/in.h>
1403 #endif
1404 #ifdef HAVE_NET_IF_H
1405 # include <net/if.h>
1406 #endif])
1407
1408 AC_CHECK_HEADERS([security/pam_modules.h],[],[],[AC_INCLUDES_DEFAULT
1409 #ifdef HAVE_SECURITY_PAM_APPL_H
1410 # include <security/pam_appl.h>
1411 #endif])
1412
1413 AC_CHECK_HEADERS(linux/errqueue.h,,,[#include <linux/types.h>])
1414
1415 AC_CHECK_TYPES([fsblkcnt_t],,,[
1416 #include <sys/types.h>
1417 #ifdef HAVE_SYS_BITYPES_H
1418 #include <sys/bitypes.h>
1419 #endif
1420 #ifdef HAVE_SYS_STATFS_H
1421 #include <sys/statfs.h>
1422 #endif
1423 #ifdef HAVE_SYS_STATVFS_H
1424 #include <sys/statvfs.h>
1425 #endif
1426 ])
1427
1428 dnl see what struct stat has for timestamps
1429 AC_CHECK_MEMBERS([struct stat.st_ctimespec, struct stat.st_ctimensec])
1430
1431 dnl check for curses-lib
1432 AS_IF([test "x$enable_gtx" != "xno"],
1433       [save_LIBS=$LIBS
1434       AC_CHECK_LIB( [ncurses], [setupterm],
1435       [LIB_curses=-lncurses],
1436         [AC_CHECK_LIB([Hcurses], [setupterm], [LIB_curses=-lHcurses],
1437           [AC_CHECK_LIB([curses], [setupterm], [LIB_curses=-lcurses])])
1438       ])
1439       LIBS=$save_LIBS
1440       AC_SUBST(LIB_curses)])
1441         
1442 OPENAFS_TEST_PACKAGE(libintl,[#include <libintl.h>],[-lintl],,,INTL)
1443
1444 if test "$enable_debug_locks" = yes; then
1445         AC_DEFINE(OPR_DEBUG_LOCKS, 1, [turn on lock debugging in opr])
1446 fi
1447
1448 dnl Don't build PAM on IRIX; the interface doesn't work for us.
1449 if test "$ac_cv_header_security_pam_modules_h" = yes -a "$enable_pam" = yes; then
1450         case $AFS_SYSNAME in
1451         sgi_*)
1452                 HAVE_PAM="no"
1453                 ;;
1454         *)
1455                 HAVE_PAM="yes"
1456                 ;;
1457         esac
1458 else
1459         HAVE_PAM="no"
1460 fi
1461 AC_SUBST(HAVE_PAM)
1462
1463 if test "$enable_login" = yes; then
1464         BUILD_LOGIN="yes"
1465 else
1466         BUILD_LOGIN="no"
1467 fi
1468 AC_SUBST(BUILD_LOGIN)
1469
1470 if test "$enable_uss" = yes; then
1471         BUILD_USS="yes"
1472 else
1473         BUILD_USS="no"
1474 fi
1475 AC_SUBST(BUILD_USS)
1476
1477 if test "$enable_kauth" = yes; then
1478         INSTALL_KAUTH="yes"
1479 else
1480         INSTALL_KAUTH="no"
1481 fi
1482 AC_SUBST(INSTALL_KAUTH)
1483
1484 AC_CHECK_FUNCS([ \
1485         arc4random \
1486         fcntl \
1487         fseeko64 \
1488         ftello64 \
1489         getcwd \
1490         getegid \
1491         geteuid \
1492         getgid \
1493         getuid \
1494         getrlimit \
1495         issetugid \
1496         mkstemp \
1497         poll \
1498         pread \
1499         preadv \
1500         preadv64 \
1501         pwrite \
1502         pwritev \
1503         pwritev64 \
1504         regcomp \
1505         regerror \
1506         regexec \
1507         setitimer \
1508         setvbuf \
1509         sigaction \
1510         strcasestr \
1511         strerror \
1512         sysconf \
1513         sysctl \
1514         tdestroy \
1515         timegm \
1516 ])
1517
1518 OPENAFS_ROKEN()
1519 OPENAFS_C_ATTRIBUTE()
1520
1521 dnl Functions that Heimdal's libroken provides, but that we
1522 dnl haven't found a need for yet, and so haven't imported
1523 AC_CHECK_FUNCS([ \
1524         chown \
1525         fchown \
1526         gethostname \
1527         lstat \
1528         inet_aton \
1529         inet_ntop \
1530         inet_pton \
1531         putenv \
1532         readv \
1533         setenv \
1534         strdup \
1535         strftime \
1536         strndup \
1537         strsep \
1538         unsetenv \
1539 ])
1540
1541 dnl Functions that are in objects that we always build from libroken
1542 AC_CHECK_FUNCS([ \
1543         asprintf \
1544         asnprintf \
1545         vasprintf \
1546         vasnprintf \
1547         vsnprintf \
1548         snprintf \
1549 ])
1550
1551 dnl Functions that we're going to try and get from libroken
1552 AC_REPLACE_FUNCS([ \
1553         daemon \
1554         ecalloc \
1555         emalloc \
1556         erealloc \
1557         err \
1558         errx \
1559         flock \
1560         getdtablesize \
1561         getopt \
1562         getprogname \
1563         gettimeofday \
1564         localtime_r \
1565         mkstemp \
1566         setenv \
1567         setprogname \
1568         strcasecmp \
1569         strlcat \
1570         strnlen \
1571         strlcpy \
1572         strsep \
1573         tdelete \
1574         tfind \
1575         tsearch \
1576         twalk \
1577         unsetenv \
1578         verr \
1579         verrx \
1580         vsyslog \
1581         vwarn \
1582         vwarnx \
1583         warn \
1584         warnx \
1585 ])
1586
1587 dnl Headers that we're going to try and get from libroken
1588 AC_CHECK_HEADERS([ \
1589         err.h \
1590         search.h \
1591 ])
1592
1593 AC_CHECK_DECLS([h_errno], [], [], [
1594 #include <sys/types.h>
1595 #ifdef HAVE_NETDB_H
1596 #include <netdb.h>
1597 #endif
1598 ])
1599
1600 AC_HEADER_TIME
1601
1602 ROKEN_HEADERS=
1603 AS_IF([test "$ac_cv_header_err_h" != "yes" ],
1604       [ROKEN_HEADERS="$ROKEN_HEADERS \$(TOP_INCDIR)/err.h"],
1605       [])
1606 AC_SUBST(ROKEN_HEADERS)
1607
1608 dnl Stuff that's harder ...
1609 AC_MSG_CHECKING([for bswap16])
1610 AC_LINK_IFELSE([AC_LANG_PROGRAM([
1611 #ifdef HAVE_SYS_TYPES_H
1612 #include <sys/types.h>
1613 #endif
1614 #ifdef HAVE_SYS_BSWAP_H
1615 #include <sys/bswap.h>
1616 #endif
1617 ],
1618 [short a, b; b = bswap16(a); ])],
1619 [AC_MSG_RESULT(yes)
1620  AC_DEFINE(HAVE_BSWAP16, 1, [Define to 1 if you have the bswap16 function])
1621 ],
1622 [AC_MSG_RESULT(no)])
1623
1624 AC_MSG_CHECKING([for bswap32])
1625 AC_LINK_IFELSE([AC_LANG_PROGRAM([#ifdef HAVE_SYS_TYPES_H
1626 #include <sys/types.h>
1627 #endif
1628 #ifdef HAVE_SYS_BSWAP_H
1629 #include <sys/bswap.h>
1630 #endif
1631 ],
1632 [int a, b; b = bswap32(a); ])],
1633 [AC_MSG_RESULT(yes)
1634  AC_DEFINE(HAVE_BSWAP32, 1, [Define to 1 if you have the bswap32 function])
1635 ],
1636 [AC_MSG_RESULT(no)])
1637
1638 case $AFS_SYSNAME in
1639 *hp_ux* | *hpux*)
1640    AC_MSG_WARN([Some versions of HP-UX have a buggy positional I/O implementation. Forcing no positional I/O.])
1641    ;;
1642 *)
1643    AC_MSG_CHECKING([for positional I/O])
1644    if test "$ac_cv_func_pread" = "yes" && \
1645            test "$ac_cv_func_pwrite" = "yes"; then
1646       AC_DEFINE(HAVE_PIO, 1, [define if you have pread() and pwrite()])
1647       AC_MSG_RESULT(yes)
1648    else
1649      AC_MSG_RESULT(no)
1650    fi
1651    AC_MSG_CHECKING([for vectored positional I/O])
1652    AS_IF([test "$ac_cv_func_preadv" = "yes" -a \
1653                "$ac_cv_func_pwritev" = "yes" -a \
1654                "$ac_cv_func_preadv64" = "yes" -a \
1655                "$ac_cv_func_pwritev64" = "yes"],
1656          [AC_DEFINE(HAVE_PIOV, 1, [define if you have preadv() and pwritev()])
1657           AC_MSG_RESULT(yes)],
1658          [AC_MSG_RESULT(no)])
1659    ;;
1660 esac
1661
1662 AC_MSG_CHECKING([for POSIX regex library])
1663 if test "$ac_cv_header_regex_h" = "yes" && \
1664         test "$ac_cv_func_regcomp" = "yes" && \
1665         test "$ac_cv_func_regexec" = "yes" && \
1666         test "$ac_cv_func_regerror" = "yes"; then
1667     AC_DEFINE(HAVE_POSIX_REGEX, 1, [define if you have POSIX regex library])
1668     AC_MSG_RESULT(yes)
1669 else
1670     AC_MSG_RESULT(no)
1671 fi
1672
1673 dnl Look for "non-portable" pthreads functions.
1674 save_LIBS="$LIBS"
1675 LIBS="$LIBS $PTHREAD_LIBS"
1676 AC_CHECK_FUNCS([ \
1677         pthread_set_name_np \
1678         pthread_setname_np \
1679 ])
1680
1681 dnl Sadly, there are three different versions of pthread_setname_np.
1682 dnl Try to cater for all of them.
1683 if test "$ac_cv_func_pthread_setname_np" = "yes" ; then
1684     AC_MSG_CHECKING([for signature of pthread_setname_np])
1685     AC_TRY_COMPILE([
1686 #include <pthread.h>
1687 #ifdef HAVE_PTHREAD_NP_H
1688 #include <pthread_np.h>
1689 #endif
1690 ], [pthread_setname_np(pthread_self(), "test", (void *)0)], [
1691         AC_MSG_RESULT([three arguments])
1692         pthread_setname_np_args=3], [
1693         AC_TRY_COMPILE([
1694 #include <pthread.h>
1695 #ifdef HAVE_PTHREAD_NP_H
1696 #include <pthread_np.h>
1697 #endif
1698 ], [pthread_setname_np(pthread_self(), "test")], [
1699             AC_MSG_RESULT([two arguments])
1700             pthread_setname_np_args=2], [
1701             AC_TRY_COMPILE([
1702 #include <pthread.h>
1703 #ifdef HAVE_PTHREAD_NP_H
1704 #include <pthread_np.h>
1705 #endif
1706 ], [pthread_setname_np("test")], [
1707                 AC_MSG_RESULT([one argument])
1708                 pthread_setname_np_args=1], [pthread_setname_np_args=0])
1709 ])
1710 ])
1711 AC_DEFINE_UNQUOTED([PTHREAD_SETNAME_NP_ARGS], $pthread_setname_np_args, [Number of arguments required by pthread_setname_np() function])
1712 fi
1713 LIBS="$save_LIBS"
1714
1715 openafs_cv_saved_CFLAGS="$CFLAGS"
1716 CFLAGS="$CFLAGS $XCFLAGS_NOCHECKING"
1717
1718 AC_TYPE_SIGNAL
1719 OPENAFS_RETSIGTYPE
1720 AC_CHECK_SIZEOF(void *)
1721 AC_CHECK_SIZEOF(unsigned long long)
1722 AC_CHECK_SIZEOF(unsigned long)
1723 AC_CHECK_SIZEOF(unsigned int)
1724 AC_TYPE_INTPTR_T
1725 AC_TYPE_UINTPTR_T
1726 AC_TYPE_SSIZE_T
1727 AC_CHECK_TYPE([sig_atomic_t],[],
1728     [AC_DEFINE([sig_atomic_t], [int],
1729         [Define to int if <signal.h> does not define.])],
1730 [#include <sys/types.h>
1731 #include <signal.h>])
1732 AC_CHECK_TYPE([socklen_t],[],
1733     [AC_DEFINE([socklen_t], [int],
1734         [Define to int if <sys/socket.h> does not define.])],
1735 [#include <sys/types.h>
1736 #include <sys/socket.h>])
1737 AC_CHECK_TYPES(off64_t)
1738 AC_CHECK_TYPES([ssize_t], [], [], [#include <unistd.h>])
1739 AC_CHECK_TYPES([struct winsize], [], [], [
1740 #ifdef HAVE_TERMIOS_H
1741 # include <termios.h>
1742 #else
1743 # include <sys/termios.h>
1744 #endif
1745 #include <sys/ioctl.h>])
1746 AC_CHECK_TYPES([sa_family_t, socklen_t, struct sockaddr,
1747                 struct sockaddr_storage],
1748                [], [], [
1749 #include <sys/types.h>
1750 #include <sys/socket.h>
1751 ])
1752 AC_CHECK_TYPES([sa_family_t], [], [], [
1753 #include <sys/types.h>
1754 #include <sys/socket.h>
1755 ])
1756 AC_CHECK_TYPES([struct addrinfo], [], [], [
1757 #include <sys/types.h>
1758 #ifdef HAVE_NETDB_H
1759 #include <netdb.h>
1760 #endif
1761 ])
1762 AC_CHECK_TYPES([long long], [], [], [])
1763
1764 AC_SIZEOF_TYPE(long)
1765
1766 CFLAGS="$openafs_cv_saved_CFLAGS"
1767
1768 RRA_HEADER_PAM_CONST
1769
1770
1771 dnl Directory PATH handling
1772 if test "x$enable_transarc_paths" = "xyes"  ; then 
1773     afsconfdir=${afsconfdir=/usr/afs/etc}
1774     viceetcdir=${viceetcdir=/usr/vice/etc}
1775     afskerneldir=${afskerneldir=${viceetcdir}}
1776     afssrvbindir=${afssrvbindir=/usr/afs/bin}
1777     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
1778     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
1779     afsdbdir=${afsdbdir=/usr/afs/db}
1780     afslogsdir=${afslogsdir=/usr/afs/logs}
1781     afslocaldir=${afslocaldir=/usr/afs/local}
1782     afsbackupdir=${afsbackupdir=/usr/afs/backup}
1783     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
1784     afsdatadir=${afsdatadir=/usr/vice/etc}
1785 else 
1786     afsconfdir=${afsconfdir='${sysconfdir}/openafs/server'}
1787     viceetcdir=${viceetcdir='${sysconfdir}/openafs'}
1788     afskerneldir=${afskerneldir='${libdir}/openafs'}
1789     afssrvbindir=${afssrvbindir='${bindir}'}
1790     afssrvsbindir=${afssrvsbindir='${sbindir}'}
1791     afssrvlibexecdir=${afssrvlibexecdir='${libexecdir}/openafs'}
1792     afsdbdir=${afsdbdir='${localstatedir}/openafs/db'}
1793     afslogsdir=${afslogsdir='${localstatedir}/openafs/logs'}
1794     afslocaldir=${afslocaldir='${localstatedir}/openafs'}
1795     afsbackupdir=${afsbackupdir='${localstatedir}/openafs/backup'}
1796     afsbosconfigdir=${afsbosconfigdir='${sysconfdir}/openafs'}
1797     afsdatadir=${afsdatadir='${datadir}/openafs'}
1798 fi
1799 AC_SUBST(afsconfdir)
1800 AC_SUBST(viceetcdir)
1801 AC_SUBST(afskerneldir)
1802 AC_SUBST(afssrvbindir)
1803 AC_SUBST(afssrvsbindir)
1804 AC_SUBST(afssrvlibexecdir)
1805 AC_SUBST(afsdbdir)
1806 AC_SUBST(afslogsdir)
1807 AC_SUBST(afslocaldir)
1808 AC_SUBST(afsbackupdir)
1809 AC_SUBST(afsbosconfigdir)
1810 AC_SUBST(afsdatadir)
1811
1812 if test "x$enable_kernel_module" = "xyes"; then
1813 ENABLE_KERNEL_MODULE=libafs
1814 fi
1815
1816 if test "x$enable_pthreaded_ubik" = "xyes"; then
1817 ENABLE_PTHREADED_UBIK=yes
1818 fi
1819
1820 AC_SUBST(VFSCK)
1821 AC_SUBST(AFS_SYSNAME)
1822 AC_SUBST(AFS_PARAM_COMMON)
1823 AC_SUBST(ENABLE_KERNEL_MODULE)
1824 AC_SUBST(ENABLE_PTHREADED_UBIK)
1825 AC_SUBST(LIB_AFSDB)
1826 AC_SUBST(LINUX_KERNEL_PATH)
1827 AC_SUBST(LINUX_KERNEL_BUILD)
1828 AC_SUBST(HOST_CPU)
1829 AC_SUBST(BSD_KERNEL_PATH)
1830 AC_SUBST(BSD_KERNEL_BUILD)
1831 AC_SUBST(LINUX_VERSION)
1832 AC_SUBST(MKAFS_OSTYPE)
1833 AC_SUBST(TOP_OBJDIR)
1834 AC_SUBST(TOP_SRCDIR)
1835 AC_SUBST(TOP_INCDIR)
1836 AC_SUBST(TOP_LIBDIR)
1837 AC_SUBST(DEST)
1838 AC_SUBST(DARWIN_INFOFILE)
1839 AC_SUBST(IRIX_BUILD_IP35)
1840 AC_SUBST(HTML_XSL)
1841 AC_SUBST(XSLTPROC)
1842 AC_SUBST(DOCBOOK2PDF)
1843 AC_SUBST(DOCBOOK_STYLESHEETS)
1844
1845 OPENAFS_FUSE
1846 OPENAFS_SWIG
1847
1848 TOP_SRCDIR="${srcdir}/src"
1849 dnl
1850 dnl If we're using ./configure, need a more reasonable TOP_SRCDIR, since relative links don't work everywhere
1851 dnl
1852 case $TOP_SRCDIR in
1853         /*)
1854                 ;;
1855         *)
1856                 TOP_SRCDIR=`cd $TOP_SRCDIR; pwd`
1857                 ;;
1858 esac
1859
1860 TOP_OBJDIR="${SRCDIR_PARENT}"
1861 TOP_INCDIR="${SRCDIR_PARENT}/include"
1862 TOP_LIBDIR="${SRCDIR_PARENT}/lib"
1863 if test "${DEST}x" = "x"; then
1864         DEST="${SRCDIR_PARENT}/${AFS_SYSNAME}/dest"
1865 fi
1866
1867 if test "x$with_crosstools_dir" != "x"; then
1868         if test -f "$with_crosstools_dir/rxgen" -a -f "$with_crosstools_dir/compile_et" -a -f "$with_crosstools_dir/config"; then
1869                 COMPILE_ET_PATH=$with_crosstools_dir/compile_et
1870                 CONFIGTOOL_PATH=$with_crosstools_dir/config
1871                 RXGEN_PATH=$with_crosstools_dir/rxgen
1872         else
1873                 AC_MSG_ERROR(Tools not found in $with_crosstools_dir)
1874                 exit 1
1875         fi
1876 else
1877         COMPILE_ET_PATH="${SRCDIR_PARENT}/src/comerr/compile_et"
1878         CONFIGTOOL_PATH="${SRCDIR_PARENT}/src/config/config"
1879         RXGEN_PATH="${SRCDIR_PARENT}/src/rxgen/rxgen"
1880 fi
1881 AC_SUBST(COMPILE_ET_PATH)
1882 AC_SUBST(CONFIGTOOL_PATH)
1883 AC_SUBST(RXGEN_PATH)
1884
1885 HELPER_SPLINT="${TOP_SRCDIR}/helper-splint.sh"
1886 HELPER_SPLINTCFG="${TOP_SRCDIR}/splint.cfg"
1887 AC_SUBST(HELPER_SPLINT)
1888 AC_SUBST(HELPER_SPLINTCFG)
1889
1890 mkdir -p ${TOP_OBJDIR}/src/JAVA/libjafs
1891
1892 dnl Check to see if crypt lives in a different library
1893 AC_CHECK_LIB(crypt, crypt, LIB_crypt="-lcrypt")
1894 AC_SUBST(LIB_crypt)
1895
1896 dnl Check to see if the compiler support labels in structs
1897 AC_MSG_CHECKING(for label support in structs)
1898 AC_TRY_COMPILE([], [
1899 extern void osi_UFSOpen(void);
1900 struct labeltest {
1901    void (*open) (void);
1902 };
1903 struct labeltest struct_labeltest = {
1904    .open       = osi_UFSOpen,
1905 }
1906 ],
1907 [AC_MSG_RESULT(yes)
1908  AC_DEFINE(HAVE_STRUCT_LABEL_SUPPORT, 1, [Define to 1 if your compiler supports labels in structs.])
1909 ],
1910 [AC_MSG_RESULT(no)
1911 ])
1912
1913 AC_MSG_CHECKING([checking for dirfd])
1914 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1915 #ifdef HAVE_DIRENT_H
1916 #include <dirent.h>
1917 #endif
1918 ]],
1919         [[DIR *d = 0; dirfd(d);]])],
1920         [ac_rk_have_dirfd=yes], [ac_rk_have_dirfd=no])
1921 if test "$ac_rk_have_dirfd" = "yes" ; then
1922         AC_DEFINE_UNQUOTED(HAVE_DIRFD, 1, [have a dirfd function/macro])
1923 fi
1924 AC_MSG_RESULT($ac_rk_have_dirfd)
1925
1926 OPENAFS_HAVE_STRUCT_FIELD(DIR, dd_fd, [#include <sys/types.h>
1927 #ifdef HAVE_DIRENT_H
1928 #include <dirent.h>
1929 #endif])
1930
1931 dnl Eventually, this will look for the system one, or for OpenSSL
1932 LIB_hcrypto="-lafshcrypto"
1933 LDFLAGS_hcrypto="-L\$(TOP_LIBDIR)"
1934 AC_SUBST(LIB_hcrypto)
1935 AC_SUBST(LDFLAGS_hcrypto)
1936
1937 dnl Check for UUID library
1938 AC_CHECK_HEADERS([uuid/uuid.h])
1939 AC_CHECK_LIB(uuid, uuid_generate, LIBS_uuid="-luuid")
1940 AC_CHECK_FUNCS([uuid_generate])
1941 ])
1942
1943
1944 AC_DEFUN([SUMMARY], [
1945     # Print a configuration summary
1946 echo 
1947 echo "**************************************"
1948 echo configure summary
1949 echo
1950 AS_IF([test $LIB_curses],[
1951 echo "LIB_curses :                $LIB_curses" ],[
1952 echo "XXX LIB_curses  not found! not building scout and afsmonitor!"
1953 ])
1954 echo 
1955 echo "**************************************"
1956 ])