configure-fail-if-cant-guess-linux-version-for-sysname-20010719
[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                         if test "x${AFS_SYSKVERS}" = "x"; then
243                          AC_MSG_ERROR(Couldn't guess your Linux version. Please use the --with-afs-sysname option to configure an AFS sysname.)
244                         fi
245                         _AFS_SYSNAME=`echo $AFS_SYSNAME|sed s/XX\$/$AFS_SYSKVERS/`
246                         AFS_SYSNAME="$_AFS_SYSNAME"
247                         ;;
248         esac
249         AC_MSG_RESULT($AFS_SYSNAME)
250 fi
251
252
253 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
254         echo Skipping library tests because they confuse Irix.
255 else
256   AC_CHECK_FUNCS(socket)
257
258   if test "$ac_cv_func_socket" = no; then
259     for lib in socket inet; do
260         if test "$HAVE_SOCKET" != 1; then
261                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
262         fi
263     done
264   fi
265   
266   AC_CHECK_FUNCS(connect)       
267
268   if test "$ac_cv_func_connect" = no; then
269     for lib in nsl; do
270         if test "$HAVE_CONNECT" != 1; then
271                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
272         fi
273     done
274   fi
275
276   AC_CHECK_FUNCS(gethostbyname)
277   if test "$ac_cv_func_gethostbyname" = no; then
278         for lib in dns nsl resolv; do
279           if test "$HAVE_GETHOSTBYNAME" != 1; then
280             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
281           fi
282         done    
283   fi    
284
285   AC_CHECK_FUNCS(res_search)
286   if test "$ac_cv_func_res_search" = no; then
287         for lib in dns nsl resolv; do
288           if test "$HAVE_RES_SEARCH" != 1; then
289             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
290           fi
291         done    
292         if test "$HAVE_RES_SEARCH" = 1; then
293           LIB_res_search="-l$lib"       
294         fi
295   fi    
296 fi
297
298 PTHREAD_LIBS=error
299 AC_CHECK_LIB(pthread, pthread_attr_init,
300              PTHREAD_LIBS="-lpthread")
301 if test "x$PTHREAD_LIBS" = xerror; then
302         AC_CHECK_LIB(pthreads, pthread_attr_init,
303                 PTHREAD_LIBS="-lpthreads")
304 fi
305 if test "x$PTHREAD_LIBS" = xerror; then
306         AC_CHECK_LIB(c_r, pthread_attr_init,
307                 PTHREAD_LIBS="-lc_r")
308 fi
309 if test "x$PTHREAD_LIBS" = xerror; then
310         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
311 fi
312 if test "x$PTHREAD_LIBS" = xerror; then
313         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
314 fi
315 AC_SUBST(PTHREAD_LIBS)
316
317 WITH_OBSOLETE=NO
318 if test "$enable_obsolete" = "yes"; then
319         WITH_OBSOLETE=YES
320 fi
321
322 WITH_INSECURE=NO
323 if test "$enable_insecure" = "yes"; then
324         WITH_INSECURE=YES
325 fi
326
327 # Fast restart
328 if test "$enable_fast_restart" = "yes"; then
329         AC_DEFINE(FAST_RESTART)
330 fi
331
332 if test "$enable_bitmap_later" = "yes"; then
333         AC_DEFINE(BITMAP_LATER)
334 fi
335
336 if test "$enable_bos_restricted_mode" = "yes"; then
337         AC_DEFINE(BOS_RESTRICTED_MODE)
338 fi
339
340 if test "$enable_namei_fileserver" = "yes"; then
341         AC_DEFINE(AFS_NAMEI_ENV)
342 fi
343
344 if test "$enable_afsdb" = "yes"; then
345         LIB_AFSDB="$LIB_res_search"
346         AC_DEFINE(AFS_AFSDB_ENV)
347 fi
348
349 SRCDIR_PARENT=`pwd`
350 TOP_SRCDIR="${SRCDIR_PARENT}/src"
351
352 dnl checks for header files.
353 AC_HEADER_STDC
354 AC_HEADER_SYS_WAIT
355 AC_HEADER_DIRENT
356 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
357 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
358 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
359 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
360 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
361 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
362
363 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
364
365 if test "x$enable_kernel_module" = "xyes"; then
366 ENABLE_KERNEL_MODULE=libafs
367 fi
368
369 AC_SUBST(AFS_SYSNAME)
370 AC_SUBST(ENABLE_KERNEL_MODULE)
371 AC_SUBST(LIB_AFSDB)
372 AC_SUBST(LINUX_KERNEL_PATH)
373 AC_SUBST(LINUX_VERSION)
374 AC_SUBST(MKAFS_OSTYPE)
375 AC_SUBST(TOP_SRCDIR)
376 AC_SUBST(WITH_OBSOLETE)
377 AC_SUBST(WITH_INSECURE)
378
379 AC_OUTPUT(             \
380 Makefile               \
381 src/config/Makefile.version-NOCML \
382 src/config/Makefile.${AFS_SYSNAME} \
383 src/libafs/MakefileProto.${MKAFS_OSTYPE} \
384 src/pam/Makefile \
385 src/afsd/afs.ppc_darwin.plist \
386 )