a7bc13280ccef0f728fdf9f67ce2bd5eeea6b1db
[openafs.git] / configure.in
1 AC_INIT(src/config/stds.h)
2 AM_INIT_AUTOMAKE(openafs,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_WITH(dux-kernel-headers,
25 [  --with-dux-kernel-headers=path       use the kernel headers found at path(optional, defaults to first match in /usr/sys)]
26 )
27 AC_ARG_WITH(linux-kernel-headers,
28 [  --with-linux-kernel-headers=path     use the kernel headers found at path(optional, defaults to /usr/src/linux)]
29 )
30 AC_ARG_ENABLE(kernel-module,
31 [  --disable-kernel-module              disable compilation of the kernel module (defaults to enabled)],, enable_kernel_module="yes"
32 )
33 AC_ARG_ENABLE(redhat-buildsys,
34 [  --enable-redhat-buildsys             enable compilation of the redhat build system kernel (defaults to disabled)],, enable_redhat_buildsys="no"
35 )
36
37 AC_PROG_CC
38
39 dnl weird ass systems
40 AC_AIX
41 AC_ISC_POSIX
42 AC_MINIX
43
44 dnl Various compiler setup.
45 AC_C_INLINE
46 AC_C_CONST
47 AC_TYPE_PID_T
48 AC_TYPE_SIZE_T
49 AC_TYPE_SIGNAL
50
51 dnl Checks for programs.
52 AC_PROG_INSTALL
53 AC_PROG_LN_S
54 AC_PROG_RANLIB
55 AC_PROG_YACC
56 AM_PROG_LEX
57
58 OPENAFS_CHECK_BIGENDIAN
59
60 AC_MSG_CHECKING(your OS)
61 system=$host
62 case $system in
63         *-linux*)
64                 MKAFS_OSTYPE=LINUX
65                 if test "x$enable_kernel_module" = "xyes"; then
66                  if test "x$with_linux_kernel_headers" != "x"; then
67                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
68                  else
69                    LINUX_KERNEL_PATH="/usr/src/linux"
70                  fi
71                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
72                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
73                   if test "x$linux_kvers" = "x"; then
74                     if test -f "$LINUX_KERNEL_PATH/include/linux/version-up.h"; then
75                       linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
76                       if test "x$linux_kvers" = "x"; then
77
78                         AC_MSG_ERROR(Linux headers lack version definition [2])
79                         exit 1
80                       else
81                         LINUX_VERSION="$linux_kvers"
82                       fi
83                     else
84                       AC_MSG_ERROR(Linux headers lack version definition)
85                       exit 1
86                     fi
87                   else
88                     LINUX_VERSION="$linux_kvers"
89                   fi
90                  else
91                     enable_kernel_module="no"
92                  fi
93                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
94                      enable_kernel_module="no"
95                  fi
96                  if test "x$enable_kernel_module" = "xno"; then
97                   if test "x$with_linux_kernel_headers" != "x"; then
98                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
99                    exit 1
100                   else
101                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
102                   fi
103                  fi
104                 fi
105                 AC_MSG_RESULT(linux)
106                 if test "x$enable_kernel_module" = "xyes"; then
107                  LINUX_FS_STRUCT_INODE_HAS_I_BYTES
108                  LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
109                  LINUX_INODE_SETATTR_RETURN_TYPE
110                  LINUX_NEED_RHCONFIG
111                  LINUX_WHICH_MODULES
112                  if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then
113                   AC_DEFINE(INODE_SETATTR_NOT_VOID)
114                  fi
115                  if test "x$ac_cv_linux_fs_struct_inode_has_i_bytes" = "xyes"; then 
116                   AC_DEFINE(STRUCT_INODE_HAS_I_BYTES)
117                  fi
118                  if test "x$ac_cv_linux_fs_struct_address_space_has_page_lock" = "xyes"; then 
119                   AC_DEFINE(STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK)
120                  fi
121                 :
122                 fi
123                 ;;
124         *-solaris*)
125                 MKAFS_OSTYPE=SOLARIS
126                 AC_MSG_RESULT(sun4)
127                 ;;
128         *-hpux*)
129                 MKAFS_OSTYPE=HPUX
130                 AC_MSG_RESULT(hp_ux)
131                 ;;
132         *-irix*)
133                 MKAFS_OSTYPE=IRIX
134                 AC_MSG_RESULT(sgi)
135                 ;;
136         *-aix*)
137                 MKAFS_OSTYPE=AIX
138                 AC_MSG_RESULT(rs_aix)
139                 ;;
140         *-osf*)
141                 MKAFS_OSTYPE=DUX
142                 AC_MSG_RESULT(alpha_dux)
143                 if test "x$enable_kernel_module" = "xyes"; then
144                  if test "x$with_dux_kernel_headers" != "x"; then
145                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
146                  else
147                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
148                  fi
149                 fi
150                 if test "$HEADER_RT" = "*" ; then
151                         AC_MSG_ERROR([Need a configured kernel directory])
152                 fi
153                 AC_SUBST([HEADER_RT])
154                 ;;
155         *-darwin*)
156                 MKAFS_OSTYPE=DARWIN
157                 AC_MSG_RESULT(ppc_darwin)
158                 ;;
159         *-freebsd*)
160                 MKAFS_OSTYPE=FBSD
161                 AC_MSG_RESULT(i386_fbsd)
162                 ;;
163         *)
164                 AC_MSG_RESULT($system)
165                 ;;
166 esac
167
168 if test "x$with_afs_sysname" != "x"; then
169         AFS_SYSNAME="$with_afs_sysname"
170 else
171         AC_MSG_CHECKING(your AFS sysname)
172         case $host in
173                 i?86-*-freebsd4.2*)
174                         AFS_SYSNAME="i386_fbsd_42"
175                         ;;
176                 hppa-hp-hpux11*)
177                         AFS_SYSNAME="hp_ux110"
178                         ;;
179                 hppa-hp-hpux10*)
180                         AFS_SYSNAME="hp_ux102"
181                         ;;
182                 powerpc-apple-darwin1.2*)
183                         AFS_SYSNAME="ppc_darwin_12"
184                         ;;
185                 powerpc-apple-darwin1.3*)
186                         AFS_SYSNAME="ppc_darwin_13"
187                         ;;
188                 sparc-sun-solaris2.5*)
189                         AFS_SYSNAME="sun4x_55"
190                         ;;
191                 sparc-sun-solaris2.6)
192                         AFS_SYSNAME="sun4x_56"
193                         ;;
194                 sparc-sun-solaris2.7)
195                         AFS_SYSNAME="sun4x_57"
196                         ;;
197                 sparc-sun-solaris2.8)
198                         AFS_SYSNAME="sun4x_58"
199                         ;;
200                 alpha*-dec-osf4.0*)
201                         AFS_SYSNAME="alpha_dux40"
202                         ;;
203                 alpha*-dec-osf5.0*)
204                         AFS_SYSNAME="alpha_dux50"
205                         ;;
206                 mips-sgi-irix6.5)
207                         AFS_SYSNAME="sgi_65"
208                         ;;
209                 powerpc-*-linux*)
210                         AFS_SYSNAME="ppc_linuxXX"
211                         ;;
212                 alpha*-linux*)
213                         AFS_SYSNAME="alpha_linux_XX"
214                         ;;
215                 sparc-*-linux*)
216                         AFS_SYSNAME="sparc_linuxXX"
217                         ;;
218                 sparc64-*-linux*)
219                         AFS_SYSNAME="sparc64_linuxXX"
220                         ;;
221                 i?86-*-linux*)
222                         AFS_SYSNAME="i386_linuxXX"
223                         ;;
224                 power*-ibm-aix4.2*)
225                         AFS_SYSNAME="rs_aix42"
226                         ;;
227                 power*-ibm-aix4.3*)
228                         AFS_SYSNAME="rs_aix42"
229                         ;;
230                 default)
231                         AC_MSG_ERROR(An AFS sysname is required)
232                         exit 1
233                         ;;
234         esac
235         case $AFS_SYSNAME in
236                 *_linux*)
237                         AFS_SYSKVERS=`echo $LINUX_VERSION | awk -F\. '{print $1 $2}'`
238                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
239                         AFS_SYSNAME="$_AFS_SYSNAME"
240                         ;;
241         esac
242         AC_MSG_RESULT($AFS_SYSNAME)
243 fi
244
245
246 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
247         echo Skipping library tests because they confuse Irix.
248 else
249   AC_CHECK_FUNCS(socket)
250
251   if test "$ac_cv_func_socket" = no; then
252     for lib in socket inet; do
253         if test "$HAVE_SOCKET" != 1; then
254                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
255         fi
256     done
257   fi
258   
259   AC_CHECK_FUNCS(connect)       
260
261   if test "$ac_cv_func_connect" = no; then
262     for lib in nsl; do
263         if test "$HAVE_CONNECT" != 1; then
264                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
265         fi
266     done
267   fi
268
269   AC_CHECK_FUNCS(gethostbyname)
270   if test "$ac_cv_func_gethostbyname" = no; then
271         for lib in dns nsl resolv; do
272           if test "$HAVE_GETHOSTBYNAME" != 1; then
273             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
274           fi
275         done    
276   fi    
277
278   AC_CHECK_FUNCS(res_search)
279   if test "$ac_cv_func_res_search" = no; then
280         for lib in dns nsl resolv; do
281           if test "$HAVE_RES_SEARCH" != 1; then
282             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
283           fi
284         done    
285         if test "$HAVE_RES_SEARCH" = 1; then
286           LIB_res_search="-l$lib"       
287         fi
288   fi    
289 fi
290
291 PTHREAD_LIBS=error
292 AC_CHECK_LIB(pthread, pthread_attr_init,
293              PTHREAD_LIBS="-lpthread")
294 if test "x$PTHREAD_LIBS" = xerror; then
295         AC_CHECK_LIB(pthreads, pthread_attr_init,
296                 PTHREAD_LIBS="-lpthreads")
297 fi
298 if test "x$PTHREAD_LIBS" = xerror; then
299         AC_CHECK_LIB(c_r, pthread_attr_init,
300                 PTHREAD_LIBS="-lc_r")
301 fi
302 if test "x$PTHREAD_LIBS" = xerror; then
303         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
304 fi
305 if test "x$PTHREAD_LIBS" = xerror; then
306         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
307 fi
308 AC_SUBST(PTHREAD_LIBS)
309
310 WITH_OBSOLETE=NO
311 if test "$enable_obsolete" = "yes"; then
312         WITH_OBSOLETE=YES
313 fi
314
315 WITH_INSECURE=NO
316 if test "$enable_insecure" = "yes"; then
317         WITH_INSECURE=YES
318 fi
319
320 # Fast restart
321 if test "$enable_fast_restart" = "yes"; then
322         AC_DEFINE(FAST_RESTART)
323 fi
324
325 if test "$enable_bitmap_later" = "yes"; then
326         AC_DEFINE(BITMAP_LATER)
327 fi
328
329 if test "$enable_bos_restricted_mode" = "yes"; then
330         AC_DEFINE(BOS_RESTRICTED_MODE)
331 fi
332
333 if test "$enable_namei_fileserver" = "yes"; then
334         AC_DEFINE(AFS_NAMEI_ENV)
335 fi
336
337 if test "$enable_afsdb" = "yes"; then
338         LIB_AFSDB="$LIB_res_search"
339         AC_DEFINE(AFS_AFSDB_ENV)
340 fi
341
342 SRCDIR_PARENT=`pwd`
343 TOP_SRCDIR="${SRCDIR_PARENT}/src"
344
345 dnl checks for header files.
346 AC_HEADER_STDC
347 AC_HEADER_SYS_WAIT
348 AC_HEADER_DIRENT
349 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
350 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
351 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
352 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
353 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
354 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
355
356 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
357
358 if test "x$enable_kernel_module" = "xyes"; then
359 ENABLE_KERNEL_MODULE=libafs
360 fi
361
362 AC_SUBST(AFS_SYSNAME)
363 AC_SUBST(ENABLE_KERNEL_MODULE)
364 AC_SUBST(LIB_AFSDB)
365 AC_SUBST(LINUX_KERNEL_PATH)
366 AC_SUBST(LINUX_VERSION)
367 AC_SUBST(MKAFS_OSTYPE)
368 AC_SUBST(TOP_SRCDIR)
369 AC_SUBST(WITH_OBSOLETE)
370 AC_SUBST(WITH_INSECURE)
371
372 AC_OUTPUT(             \
373 Makefile               \
374 src/config/Makefile.${AFS_SYSNAME} \
375 src/libafs/MakefileProto.${MKAFS_OSTYPE} \
376 )