e824c0a7b0727a5eee7d83517960de3ef72a3368
[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
34 AC_PROG_CC
35
36 dnl weird ass systems
37 AC_AIX
38 AC_ISC_POSIX
39 AC_MINIX
40
41 dnl Various compiler setup.
42 AC_C_INLINE
43 AC_C_CONST
44 AC_TYPE_PID_T
45 AC_TYPE_SIZE_T
46 AC_TYPE_SIGNAL
47
48 dnl Checks for programs.
49 AC_PROG_INSTALL
50 AC_PROG_LN_S
51 AC_PROG_RANLIB
52 AC_PROG_YACC
53 AM_PROG_LEX
54
55 OPENAFS_CHECK_BIGENDIAN
56
57 AC_MSG_CHECKING(your OS)
58 system=$host
59 case $system in
60         *-linux*)
61                 MKAFS_OSTYPE=LINUX
62                 if test "x$enable_kernel_module" = "xyes"; then
63                  if test "x$with_linux_kernel_headers" != "x"; then
64                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
65                  else
66                    LINUX_KERNEL_PATH="/usr/src/linux"
67                  fi
68                  if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then
69                   linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $2 }'|tail -1`
70                   if test "x$linux_kvers" = "x"; then
71                     AC_MSG_ERROR(Linux headers lack version definition)
72                     exit 1
73                   else
74                     LINUX_VERSION="$linux_kvers"
75                   fi
76                  else
77                     enable_kernel_module="no"
78                  fi
79                  if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
80                      enable_kernel_module="no"
81                  fi
82                  if test "x$enable_kernel_module" = "xno"; then
83                   if test "x$with_linux_kernel_headers" != "x"; then
84                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
85                    exit 1
86                   else
87                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
88                   fi
89                  fi
90                 fi
91                 AC_MSG_RESULT(linux)
92                 if test "x$enable_kernel_module" = "xyes"; then
93                  LINUX_FS_STRUCT_INODE_HAS_I_BYTES
94                  LINUX_INODE_SETATTR_RETURN_TYPE
95                  LINUX_NEED_RHCONFIG
96                  LINUX_WHICH_MODULES
97                 :
98                 fi
99                 ;;
100         *-solaris*)
101                 MKAFS_OSTYPE=SOLARIS
102                 AC_MSG_RESULT(sun4)
103                 ;;
104         *-hpux*)
105                 MKAFS_OSTYPE=HPUX
106                 AC_MSG_RESULT(hp_ux)
107                 ;;
108         *-irix*)
109                 MKAFS_OSTYPE=IRIX
110                 AC_MSG_RESULT(sgi)
111                 ;;
112         *-aix*)
113                 MKAFS_OSTYPE=AIX
114                 AC_MSG_RESULT(rs_aix)
115                 ;;
116         *-osf*)
117                 MKAFS_OSTYPE=DUX
118                 AC_MSG_RESULT(alpha_dux)
119                 if test "x$enable_kernel_module" = "xyes"; then
120                  if test "x$with_dux_kernel_headers" != "x"; then
121                    HEADER_RT=`ls ${with_dux_kernel_headers}/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
122                  else
123                    HEADER_RT=`ls /usr/sys/*/rt_preempt.h | head -1 | sed 's,/rt_preempt.h,,;s,/usr/sys/,,'`
124                  fi
125                 fi
126                 if test "$HEADER_RT" = "*" ; then
127                         AC_MSG_ERROR([Need a configured kernel directory])
128                 fi
129                 AC_SUBST([HEADER_RT])
130                 ;;
131         *-darwin*)
132                 MKAFS_OSTYPE=DARWIN
133                 AC_MSG_RESULT(ppc_darwin)
134                 ;;
135         *-freebsd*)
136                 MKAFS_OSTYPE=FBSD
137                 AC_MSG_RESULT(i386_fbsd)
138                 ;;
139         *)
140                 AC_MSG_RESULT($system)
141                 ;;
142 esac
143
144 if test "x${MKAFS_OSTYPE}" = "xIRIX"; then
145         echo Skipping library tests because they confuse Irix.
146 else
147   AC_CHECK_FUNCS(socket)
148
149   if test "$ac_cv_func_socket" = no; then
150     for lib in socket inet; do
151         if test "$HAVE_SOCKET" != 1; then
152                 AC_CHECK_LIB(${lib}, socket,LIBS="$LIBS -l$lib";HAVE_SOCKET=1;AC_DEFINE(HAVE_SOCKET))
153         fi
154     done
155   fi
156   
157   AC_CHECK_FUNCS(connect)       
158
159   if test "$ac_cv_func_connect" = no; then
160     for lib in nsl; do
161         if test "$HAVE_CONNECT" != 1; then
162                 AC_CHECK_LIB(${lib}, connect,LIBS="$LIBS -l$lib";HAVE_CONNECT=1;AC_DEFINE(HAVE_CONNECT))
163         fi
164     done
165   fi
166
167   AC_CHECK_FUNCS(gethostbyname)
168   if test "$ac_cv_func_gethostbyname" = no; then
169         for lib in dns nsl resolv; do
170           if test "$HAVE_GETHOSTBYNAME" != 1; then
171             AC_CHECK_LIB(${lib}, gethostbyname, LIBS="$LIBS -l$lib";HAVE_GETHOSTBYNAME=1;AC_DEFINE(HAVE_GETHOSTBYNAME))
172           fi
173         done    
174   fi    
175
176   AC_CHECK_FUNCS(res_search)
177   if test "$ac_cv_func_res_search" = no; then
178         for lib in dns nsl resolv; do
179           if test "$HAVE_RES_SEARCH" != 1; then
180             AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH))
181           fi
182         done    
183         if test "$HAVE_RES_SEARCH" = 1; then
184           LIB_res_search="-l$lib"       
185         fi
186   fi    
187 fi
188
189 PTHREAD_LIBS=error
190 AC_CHECK_LIB(pthread, pthread_attr_init,
191              PTHREAD_LIBS="-lpthread")
192 if test "x$PTHREAD_LIBS" = xerror; then
193         AC_CHECK_LIB(pthreads, pthread_attr_init,
194                 PTHREAD_LIBS="-lpthreads")
195 fi
196 if test "x$PTHREAD_LIBS" = xerror; then
197         AC_CHECK_LIB(c_r, pthread_attr_init,
198                 PTHREAD_LIBS="-lc_r")
199 fi
200 if test "x$PTHREAD_LIBS" = xerror; then
201         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
202 fi
203 if test "x$PTHREAD_LIBS" = xerror; then
204         AC_MSG_WARN(*** Unable to locate working posix thread library ***)
205 fi
206 AC_SUBST(PTHREAD_LIBS)
207
208 WITH_OBSOLETE=NO
209 if test "$enable_obsolete" = "yes"; then
210         WITH_OBSOLETE=YES
211 fi
212
213 WITH_INSECURE=NO
214 if test "$enable_insecure" = "yes"; then
215         WITH_INSECURE=YES
216 fi
217
218 # Fast restart
219 if test "$enable_fast_restart" = "yes"; then
220         AC_DEFINE(FAST_RESTART)
221 fi
222
223 if test "$enable_bitmap_later" = "yes"; then
224         AC_DEFINE(BITMAP_LATER)
225 fi
226
227 # Should autocompute a default
228 if test "x$with_afs_sysname" != "x"; then
229         AFS_SYSNAME="$with_afs_sysname"
230 else
231         AC_MSG_ERROR(An AFS sysname is required)
232         exit 1
233 fi
234
235 if test "$enable_bos_restricted_mode" = "yes"; then
236         AC_DEFINE(BOS_RESTRICTED_MODE)
237 fi
238
239 if test "$enable_namei_fileserver" = "yes"; then
240         AC_DEFINE(AFS_NAMEI_ENV)
241 fi
242
243 if test "$enable_afsdb" = "yes"; then
244         LIB_AFSDB="$LIB_res_search"
245         AC_DEFINE(AFS_AFSDB_ENV)
246 fi
247
248 SRCDIR_PARENT=`pwd`
249 TOP_SRCDIR="${SRCDIR_PARENT}/src"
250
251 dnl checks for header files.
252 AC_HEADER_STDC
253 AC_HEADER_SYS_WAIT
254 AC_HEADER_DIRENT
255 AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h)
256 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
257 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h)
258 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h)
259 AC_CHECK_HEADERS(windows.h malloc.h winsock2.h direct.h io.h)
260 AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h)
261
262 AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec)
263
264 if test "x$enable_kernel_module" = "xyes"; then
265 ENABLE_KERNEL_MODULE=libafs
266 fi
267
268 AC_SUBST(AFS_SYSNAME)
269 AC_SUBST(ENABLE_KERNEL_MODULE)
270 AC_SUBST(LIB_AFSDB)
271 AC_SUBST(LINUX_KERNEL_PATH)
272 AC_SUBST(LINUX_VERSION)
273 AC_SUBST(MKAFS_OSTYPE)
274 AC_SUBST(TOP_SRCDIR)
275 AC_SUBST(WITH_OBSOLETE)
276 AC_SUBST(WITH_INSECURE)
277
278 AC_OUTPUT(             \
279 Makefile               \
280 src/config/Makefile.${AFS_SYSNAME} \
281 src/libafs/MakefileProto.${MKAFS_OSTYPE} \
282 )