configure-libafs-fix-paths-20010910
[openafs.git] / configure-libafs.in
1 AC_INIT(Makefile.common)
2 AM_INIT_AUTOMAKE(openafs-libafs,devel)
3 AC_CANONICAL_HOST
4 AC_CONFIG_HEADER(src/config/afsconfig.h)
5
6 #BOZO_SAVE_CORES BOS_RESTRICTED_MODE BOS_NEW_CONFIG pam sia
7 AC_ARG_WITH(afs-sysname,
8 [  --with-afs-sysname=sys    use sys for the afs sysname]
9 )
10 AC_ARG_ENABLE( obsolete,
11 [  --enable-obsolete                    enable obsolete portions of AFS (mpp, ntp and package)],, enable_obsolete="no")
12 AC_ARG_ENABLE( insecure,
13 [  --enable-insecure                    enable insecure portions of AFS (ftpd, inetd, rcp, rlogind and rsh)],, enable_insecure="no")
14 AC_ARG_ENABLE( afsdb,
15 [  --disable-afsdb                      disable AFSDB RR support],, enable_afsdb="yes")
16 AC_ARG_ENABLE( bos-restricted-mode,
17 [  --enable-bos-restricted-mode         enable bosserver restricted mode which disables certain bosserver functionality],, enable_bos_restricted_mode="no")
18 AC_ARG_ENABLE( namei-fileserver,
19 [  --enable-namei-fileserver            force compilation of namei fileserver in preference to inode fileserver],, enable_namei_fileserver="no")
20 AC_ARG_ENABLE( fast-restart,
21 [  --enable-fast-restart                enable fast startup of file server without salvaging],, enable_fast_restart="no")
22 AC_ARG_ENABLE( bitmap-later,
23 [  --enable-bitmap-later                enable fast startup of file server by not reading bitmap till needed],, enable_bitmap_later="no")
24 AC_ARG_ENABLE( full-vos-listvol-switch,
25 [  --enable-full-vos-listvol-switch     enable vos full listvol switch for formatted output],, enable_full_vos_listvol_switch="no")
26 AC_ARG_WITH(dux-kernel-headers,
27 [  --with-dux-kernel-headers=path       use the kernel headers found at path(optional, defaults to first match in /usr/sys)]
28 )
29 AC_ARG_WITH(linux-kernel-headers,
30 [  --with-linux-kernel-headers=path     use the kernel headers found at path(optional, defaults to /usr/src/linux)]
31 )
32 AC_ARG_ENABLE(kernel-module,
33 [  --disable-kernel-module              disable compilation of the kernel module (defaults to enabled)],, enable_kernel_module="yes"
34 )
35 AC_ARG_ENABLE(redhat-buildsys,
36 [  --enable-redhat-buildsys             enable compilation of the redhat build system kernel (defaults to disabled)],, enable_redhat_buildsys="no"
37 )
38 AC_ARG_ENABLE(transarc-paths,
39 [  --enable-transarc-paths                      Use Transarc style paths like /usr/afs and /usr/vice],, enable_transarc_paths="no"
40 )
41
42 AC_PROG_CC
43
44 dnl weird ass systems
45 AC_AIX
46 AC_ISC_POSIX
47 AC_MINIX
48
49 dnl Various compiler setup.
50 AC_C_INLINE
51 AC_C_CONST
52 AC_TYPE_PID_T
53 AC_TYPE_SIZE_T
54 AC_TYPE_SIGNAL
55
56 dnl Checks for programs.
57 AC_PROG_INSTALL
58 AC_PROG_LN_S
59 AC_PROG_RANLIB
60 AC_PROG_YACC
61 AM_PROG_LEX
62
63 OPENAFS_CHECK_BIGENDIAN
64
65 AC_MSG_CHECKING(your OS)
66 system=$host
67 case $system in
68         *-linux*)
69                 MKAFS_OSTYPE=LINUX
70                 if test "x$enable_redhat_buildsys" = "xyes"; then
71                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS)
72                 fi
73                 if test "x$enable_kernel_module" = "xyes"; then
74                  if test "x$with_linux_kernel_headers" != "x"; then
75                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
76                  else
77                    LINUX_KERNEL_PATH="/usr/src/linux"
78                  fi
79                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
80                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
81                   if test "x$linux_kvers" = "x"; then
82                     if test -f "$LINUX_KERNEL_PATH/include/linux/version-up.h"; then
83                       linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
84                       if test "x$linux_kvers" = "x"; then
85
86                         AC_MSG_ERROR(Linux headers lack version definition [2])
87                         exit 1
88                       else
89                         LINUX_VERSION="$linux_kvers"
90                       fi
91                     else
92                       AC_MSG_ERROR(Linux headers lack version definition)
93                       exit 1
94                     fi
95                   else
96                     LINUX_VERSION="$linux_kvers"
97                   fi
98                  else
99                     enable_kernel_module="no"
100                  fi
101                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
102                      enable_kernel_module="no"
103                  fi
104                  if test "x$enable_kernel_module" = "xno"; then
105                   if test "x$with_linux_kernel_headers" != "x"; then
106                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
107                    exit 1
108                   else
109                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
110                   fi
111                  fi
112                 fi
113                 AC_MSG_RESULT(linux)
114                 if test "x$enable_kernel_module" = "xyes"; then
115                  LINUX_FS_STRUCT_INODE_HAS_I_BYTES
116                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
117                  LINUX_FS_STRUCT_INODE_HAS_I_CDEV
118                  LINUX_FS_STRUCT_INODE_HAS_I_TRUNCATE_SEM
119                  LINUX_FS_STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
120                  LINUX_FS_STRUCT_INODE_HAS_I_MAPPING_OVERLOAD
121                  LINUX_FS_STRUCT_INODE_HAS_I_MMAP_SHARED
122                  LINUX_INODE_SETATTR_RETURN_TYPE
123                  LINUX_NEED_RHCONFIG
124                  LINUX_WHICH_MODULES
125                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
126                   AC_DEFINE(INODE_SETATTR_NOT_VOID)
127                  fi
128                  if test "x$ac_cv_linux_fs_struct_inode_has_i_dirty_data_buffers" = "xyes"; then 
129                   AC_DEFINE(STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS)
130                  fi
131                  if test "x$ac_cv_linux_fs_struct_inode_has_i_mmap_shared" = "xyes"; then 
132                   AC_DEFINE(STRUCT_INODE_HAS_I_MMAP_SHARED)
133                  fi
134                  if test "x$ac_cv_linux_fs_struct_inode_has_i_mapping_overload" = "xyes"; then 
135                   AC_DEFINE(STRUCT_INODE_HAS_I_MAPPING_OVERLOAD)
136                  fi
137                  if test "x$ac_cv_linux_fs_struct_inode_has_i_cdev" = "xyes"; then 
138                   AC_DEFINE(STRUCT_INODE_HAS_I_CDEV)
139                  fi
140                  if test "x$ac_cv_linux_fs_struct_inode_has_i_truncate_sem" = "xyes"; then 
141                   AC_DEFINE(STRUCT_INODE_HAS_I_TRUNCATE_SEM)
142                  fi
143                  if test "x$ac_cv_linux_fs_struct_inode_has_i_bytes" = "xyes"; then 
144                   AC_DEFINE(STRUCT_INODE_HAS_I_BYTES)
145                  fi
146                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
147                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK)
148                  fi
149                 :
150                 fi
151                 ;;
152         *-solaris*)
153                 MKAFS_OSTYPE=SOLARIS
154                 AC_MSG_RESULT(sun4)
155                 SOLARIS_UFSVFS_HAS_DQRWLOCK
156                 ;;
157         *-hpux*)
158                 MKAFS_OSTYPE=HPUX
159                 AC_MSG_RESULT(hp_ux)
160                 ;;
161         *-irix*)
162                 MKAFS_OSTYPE=IRIX
163                 AC_MSG_RESULT(sgi)
164                 ;;
165         *-aix*)
166                 MKAFS_OSTYPE=AIX
167                 AC_MSG_RESULT(rs_aix)
168                 ;;
169         *-osf*)
170                 MKAFS_OSTYPE=DUX
171                 AC_MSG_RESULT(alpha_dux)
172                 if test "x$enable_kernel_module" = "xyes"; then
173                  if test "x$with_dux_kernel_headers" != "x"; then
174                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
175                  else
176                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
177                  fi
178                 fi
179                 if test "$HEADER_RT" = "*" ; then
180                         AC_MSG_ERROR([Need a configured kernel directory])
181                 fi
182                 AC_SUBST([HEADER_RT])
183                 ;;
184         *-darwin*)
185                 MKAFS_OSTYPE=DARWIN
186                 AC_MSG_RESULT(ppc_darwin)
187                 ;;
188         *-freebsd*)
189                 MKAFS_OSTYPE=FBSD
190                 AC_MSG_RESULT(i386_fbsd)
191                 ;;
192         *)
193                 AC_MSG_RESULT($system)
194                 ;;
195 esac
196
197 if test "x$with_afs_sysname" != "x"; then
198         AFS_SYSNAME="$with_afs_sysname"
199 else
200         AC_MSG_CHECKING(your AFS sysname)
201         case $host in
202                 i?86-*-freebsd4.2*)
203                         AFS_SYSNAME="i386_fbsd_42"
204                         ;;
205                 hppa*-hp-hpux11*)
206                         AFS_SYSNAME="hp_ux110"
207                         ;;
208                 hppa*-hp-hpux10*)
209                         AFS_SYSNAME="hp_ux102"
210                         ;;
211                 powerpc-apple-darwin1.2*)
212                         AFS_SYSNAME="ppc_darwin_12"
213                         DARWIN_PLIST=src/afsd/afs.${AFS_SYSNAME}.plist
214                         ;;
215                 powerpc-apple-darwin1.3*)
216                         AFS_SYSNAME="ppc_darwin_13"
217                         DARWIN_PLIST=src/afsd/afs.${AFS_SYSNAME}.plist
218                         ;;
219                 powerpc-apple-darwin1.4*)
220                         AFS_SYSNAME="ppc_darwin_14"
221                         DARWIN_PLIST=src/afsd/afs.${AFS_SYSNAME}.plist
222                         ;;
223                 sparc-sun-solaris2.5*)
224                         AFS_SYSNAME="sun4x_55"
225                         ;;
226                 sparc-sun-solaris2.6)
227                         AFS_SYSNAME="sun4x_56"
228                         ;;
229                 sparc-sun-solaris2.7)
230                         AFS_SYSNAME="sun4x_57"
231                         ;;
232                 sparc-sun-solaris2.8)
233                         AFS_SYSNAME="sun4x_58"
234                         ;;
235                 alpha*-dec-osf4.0*)
236                         AFS_SYSNAME="alpha_dux40"
237                         ;;
238                 alpha*-dec-osf5.0*)
239                         AFS_SYSNAME="alpha_dux50"
240                         ;;
241                 mips-sgi-irix6.5)
242                         AFS_SYSNAME="sgi_65"
243                         ;;
244                 ia64-*-linux*)
245                         AFS_SYSNAME="ia64_linuxXX"
246                         ;;
247                 powerpc-*-linux*)
248                         AFS_SYSNAME="ppc_linuxXX"
249                         ;;
250                 alpha*-linux*)
251                         AFS_SYSNAME="alpha_linux_XX"
252                         ;;
253                 s390-*-linux*)
254                         AFS_SYSNAME="s390_linuxXX"
255                         ;;
256                 sparc-*-linux*)
257                         AFS_SYSNAME="sparc_linuxXX"
258                         ;;
259                 sparc64-*-linux*)
260                         AFS_SYSNAME="sparc64_linuxXX"
261                         ;;
262                 i?86-*-linux*)
263                         AFS_SYSNAME="i386_linuxXX"
264                         ;;
265                 power*-ibm-aix4.2*)
266                         AFS_SYSNAME="rs_aix42"
267                         ;;
268                 power*-ibm-aix4.3*)
269                         AFS_SYSNAME="rs_aix42"
270                         ;;
271                 *)
272                         AC_MSG_ERROR(An AFS sysname is required)
273                         exit 1
274                         ;;
275         esac
276         case $AFS_SYSNAME in
277                 *_linux*)
278                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $1 $2}'`
279                         if test "x${AFS_SYSKVERS}" = "x"; then
280                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
281                         fi
282                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
283                         AFS_SYSNAME="$_AFS_SYSNAME"
284                         ;;
285         esac
286         AC_MSG_RESULT($AFS_SYSNAME)
287 fi
288
289
290 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
291         echo Skipping library tests because they confuse Irix.
292 else
293   AC_CHECK_FUNCS(socket)
294
295   if test "$ac_cv_func_socket" = no; then
296     for lib in socket inet; do
297         if test "$HAVE_SOCKET" != 1; then
298                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
299         fi
300     done
301   fi
302   
303   AC_CHECK_FUNCS(connect)       
304
305   if test "$ac_cv_func_connect" = no; then
306     for lib in nsl; do
307         if test "$HAVE_CONNECT" != 1; then
308                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
309         fi
310     done
311   fi
312
313   AC_CHECK_FUNCS(gethostbyname)
314   if test "$ac_cv_func_gethostbyname" = no; then
315         for lib in dns nsl resolv; do
316           if test "$HAVE_GETHOSTBYNAME" != 1; then
317             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
318           fi
319         done    
320   fi    
321
322   AC_CHECK_FUNCS(res_search)
323   if test "$ac_cv_func_res_search" = no; then
324         for lib in dns nsl resolv; do
325           if test "$HAVE_RES_SEARCH" != 1; then
326             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
327           fi
328         done    
329         if test "$HAVE_RES_SEARCH" = 1; then
330           LIB_res_search="-l$lib"       
331         fi
332   fi    
333 fi
334
335 PTHREAD_LIBS=error
336 AC_CHECK_LIB(pthread, pthread_attr_init,
337              PTHREAD_LIBS="-lpthread")
338 if test "x$PTHREAD_LIBS" = xerror; then
339         AC_CHECK_LIB(pthreads, pthread_attr_init,
340                 PTHREAD_LIBS="-lpthreads")
341 fi
342 if test "x$PTHREAD_LIBS" = xerror; then
343         AC_CHECK_LIB(c_r, pthread_attr_init,
344                 PTHREAD_LIBS="-lc_r")
345 fi
346 if test "x$PTHREAD_LIBS" = xerror; then
347         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
348 fi
349 if test "x$PTHREAD_LIBS" = xerror; then
350         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
351 fi
352 AC_SUBST(PTHREAD_LIBS)
353
354 WITH_OBSOLETE=NO
355 if test "$enable_obsolete" = "yes"; then
356         WITH_OBSOLETE=YES
357 fi
358
359 WITH_INSECURE=NO
360 if test "$enable_insecure" = "yes"; then
361         WITH_INSECURE=YES
362 fi
363
364 # Fast restart
365 if test "$enable_fast_restart" = "yes"; then
366         AC_DEFINE(FAST_RESTART)
367 fi
368
369 if test "$enable_bitmap_later" = "yes"; then
370         AC_DEFINE(BITMAP_LATER)
371 fi
372
373 if test "$enable_full_vos_listvol_switch" = "yes"; then
374         AC_DEFINE(FULL_LISTVOL_SWITCH)
375 fi
376
377 if test "$enable_bos_restricted_mode" = "yes"; then
378         AC_DEFINE(BOS_RESTRICTED_MODE)
379 fi
380
381 if test "$enable_namei_fileserver" = "yes"; then
382         AC_DEFINE(AFS_NAMEI_ENV)
383 fi
384
385 if test "$enable_afsdb" = "yes"; then
386         LIB_AFSDB="$LIB_res_search"
387         AC_DEFINE(AFS_AFSDB_ENV)
388 fi
389
390 SRCDIR_PARENT=`pwd`
391 TOP_SRCDIR="${SRCDIR_PARENT}"
392 DESTDIR="${SRCDIR_PARENT}/${AFS_SYSNAME}/dest/"
393 TOP_INCDIR="${SRCDIR_PARENT}/include"
394 TOP_LIBDIR="${SRCDIR_PARENT}/lib"
395
396 dnl checks for header files.
397 AC_HEADER_STDC
398 AC_HEADER_SYS_WAIT
399 AC_HEADER_DIRENT
400 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
401 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
402 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
403 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
404 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
405 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
406
407 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
408
409 dnl Directory PATH handling
410 if test "x$enable_transarc_paths" = "xyes"  ; then 
411     afsconfdir=${afsconfdir=/usr/afs/etc}
412     viceetcdir=${viceetcdir=/usr/vice/etc}
413     afskerneldir=${afskerneldir=${viceetcdir}}
414     afssrvbindir=${afssrvbindir=/usr/afs/bin}
415     afssrvsbindir=${afssrvsbindir=/usr/afs/bin}
416     afssrvlibexecdir=${afssrvlibexecdir=/usr/afs/bin}
417     afsdbdir=${afsdbdir=/usr/afs/db}
418     afslogsdir=${afslogsdir=/usr/afs/logs}
419     afslocaldir=${afslocaldir=/usr/afs/local}
420     afsbackupdir=${afsbackupdir=/usr/afs/backup}
421     afsbosconfigdir=${afsbosconfigdir=/usr/afs/local}
422     else 
423     afsconfdir=${afsconfdir=$sysconfdir/openafs/server}
424     viceetcdir=${viceetcdir=$sysconfdir/openafs}
425     afskerneldir=${afskerneldir=$libdir/openafs}
426     afssrvbindir=${afssrvbindir=$bindir}
427     afssrvsbindir=${afssrvsbindir=$sbindir}
428     afssrvlibexecdir=${afssrvlibexecdir=$libexecdir/openafs}
429     afsdbdir=${afsdbdir=$localstatedir/openafs/db}
430     afslogsdir=${afslogsdir=$localstatedir/openafs/logs}
431     afslocaldir=${afslocaldir=$localstatedir/openafs}
432     afsbackupdir=${afsbackupdir=$localstatedir/openafs/backup}
433     afsbosconfigdir=${afsbosconfigdir=$sysconfdir/openafs}
434
435 fi
436 AC_SUBST(afsconfdir)
437 AC_SUBST(viceetcdir)
438 AC_SUBST(afskerneldir)
439 AC_SUBST(afssrvbindir)
440 AC_SUBST(afssrvsbindir)
441 AC_SUBST(afssrvlibexecdir)
442 AC_SUBST(afsdbdir)
443 AC_SUBST(afslogsdir)
444 AC_SUBST(afslocaldir)
445 AC_SUBST(afsbackupdir)
446 AC_SUBST(afsbosconfigdir)
447
448 if test "x$enable_kernel_module" = "xyes"; then
449 ENABLE_KERNEL_MODULE=libafs
450 fi
451
452 AC_SUBST(AFS_SYSNAME)
453 AC_SUBST(ENABLE_KERNEL_MODULE)
454 AC_SUBST(LIB_AFSDB)
455 AC_SUBST(LINUX_KERNEL_PATH)
456 AC_SUBST(LINUX_VERSION)
457 AC_SUBST(MKAFS_OSTYPE)
458 AC_SUBST(TOP_SRCDIR)
459 AC_SUBST(TOP_INCDIR)
460 AC_SUBST(TOP_LIBDIR)
461 AC_SUBST(DEST)
462 AC_SUBST(WITH_OBSOLETE)
463 AC_SUBST(WITH_INSECURE)
464
465 AC_OUTPUT(             \
466 Makefile               \
467 config/Makefile.${AFS_SYSNAME} \
468 )