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