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