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