summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 0442eb754b517835b1553f9224783f4d7852b23b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
dnl Process this file with autoconf to produce a configure script.
AC_INIT([zephyr],[__DEV__])
AC_CONFIG_MACRO_DIR([m4])

test -d h || mkdir h
test -d h/zephyr || mkdir h/zephyr

test -z "$lbindir" && lbindir='${bindir}'
test -z "$lsbindir" && lsbindir='${sbindir}'
AC_SUBST(lbindir)
AC_SUBST(lsbindir)

AC_CANONICAL_SYSTEM
AC_CANONICAL_TARGET
AC_DEFINE_UNQUOTED(MACHINE_TYPE, "$host", [Define to the type of the host system.])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_YACC
AC_PROG_LEX
AC_PROG_INSTALL
AC_PROG_LIBTOOL

AC_MSG_CHECKING(location of temporary directory)
if test -d /var/tmp; then
	found_tmp=/var/tmp/
elif test -d /usr/tmp; then
	found_tmp=/usr/tmp/
else
	found_tmp=/tmp/
fi
AC_DEFINE_UNQUOTED(FOUND_TMP, "${found_tmp}", [Define to a temporary directory on your system.])
AC_MSG_RESULT(${found_tmp})

dnl Checks for header files.
AC_PATH_XTRA
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h paths.h sgtty.h unistd.h malloc.h term.h)
AC_CHECK_HEADERS(sys/filio.h sys/ioctl.h sys/time.h sys/file.h sys/utsname.h)
AC_CHECK_HEADERS(sys/select.h sys/msgbuf.h sys/cdefs.h krb5_err.h termcap.h)
AC_CHECK_HEADERS(arpa/nameser_compat.h stdbool.h termio.h curses.h)

if test "$no_x" != "yes"; then
	ZWGC_LIBX11=-lX11
fi
AC_SUBST(XCLIENTS)
AC_SUBST(ZWGC_LIBX11)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIGNAL
AC_TYPE_UID_T
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_MSG_CHECKING(for 32-bit integer type)
if test "$ac_cv_sizeof_long" = 4; then
	int32=long
elif test "$ac_cv_sizeof_int" = 4; then
	int32=int
elif test "$ac_cv_sizeof_short" = 4; then
	int32=short
else
	AC_WARN([Can't find 32-bit type, using long])
	int32=long
fi
AC_DEFINE_UNQUOTED(ZEPHYR_INT32, ${int32}, [Define to a signed 32-bit integral type.])
AC_MSG_RESULT(${int32})

AC_CHECK_LIB(w, wslen)
# XXX? AC_CHECK_LIB(dl, dlopen)

AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
		[AC_DEFINE(HAVE_SOCKADDR_IN_SIN_LEN, 1,
		 [sockaddr_in has sin_len member])],
		[], [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])

AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
		[AC_DEFINE(HAVE_SOCKADDR_IN6_SIN6_LEN, 1,
		 [sockaddr_in6 has sin6_len member])],
		[], [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])

AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(socket, socket)

AC_CHECK_LIB(44bsd, strerror)

AC_CHECK_LIB(iconv, iconv_open, [LIBICONV=-liconv; AC_SUBST(LIBICONV)])

AC_CHECK_LIB(curses, tgetstr, [TLIB=-lcurses], [TLIB=-ltermcap])
AC_SUBST(TLIB)

AC_ARG_WITH(krb4,
	[  --with-krb4=PREFIX      Use Kerberos 4],
	[krb4="$withval"], [krb4=no])
if test "$krb4" != no; then
	AC_CHECK_FUNC(gethostbyname, :, AC_CHECK_LIB(nsl, gethostbyname))
	AC_CHECK_FUNC(socket, :, AC_CHECK_LIB(socket, socket))
	AC_CHECK_LIB(gen, compile)
	if test "$krb4" != yes; then
	   CPPFLAGS="$CPPFLAGS -I$krb4/include"
	   if test -d "$krb4/include/kerberosIV"; then
	      CPPFLAGS="$CPPFLAGS -I$krb4/include/kerberosIV"
	   fi
	   LDFLAGS="$LDFLAGS -L$krb4/lib"
	fi
	AC_CHECK_LIB(krb4, krb_rd_req,
	     [KRB4_LIBS="-lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"],
	     [AC_CHECK_LIB(krb, krb_rd_req,
			   [KRB4_LIBS="-lkrb -ldes"],
			   [AC_MSG_ERROR(Kerberos 4 libraries not found)],
			   -ldes)],
	     -ldes425 -lkrb5 -lk5crypto -lcom_err)
	AC_DEFINE(HAVE_KRB4, 1, [Define to compile with Kerberos support.])
	LIBZEPHYR_LIBS="$LIBZEPHYR_LIBS $KRB4_LIBS"
fi
AC_SUBST(KRB4_LIBS)

AC_ARG_WITH(krb5,
	    [  --with-krb5=PREFIX      Use Kerberos 5],
	    [krb5="$withval"], [krb5=no])
if test "$krb5" != no; then
   AC_SEARCH_LIBS(gethostbyname, nsl)
   AC_SEARCH_LIBS(socket, socket)
   AC_CHECK_LIB(gen, compile)
   if test "$krb5" != yes; then
      PATH="$PATH:$krb5/bin"
   fi
   AC_CHECK_PROG(krb5config, krb5-config,yes)
   if test "$krb5config" = yes; then
      CPPFLAGS="$CPPFLAGS $(krb5-config --cflags krb5)"
      KRB5_LIBS="$(krb5-config --libs krb5)"
   else
      if test "$krb5" != yes; then
      	 CPPFLAGS="$CPPFLAGS -I$krb5/include"
      	 LDFLAGS="$LDFLAGS -L$krb5/lib"
      fi
      KRB5_LIBS="-lkrb5 -lk5crypto -lcom_err"
   fi
   AC_CHECK_HEADER(krb5.h, :, [AC_MSG_ERROR(Kerberos 5 headers not found)])
   local_save_LIBS=$LIBS
   LIBS="$libs $KRB5_LIBS"
   AC_CHECK_FUNC(krb5_init_context, :,
	           [AC_MSG_ERROR(Kerberos 5 libraries not found)])
   LIBS="$local_save_LIBS"
   AC_DEFINE(HAVE_KRB5, 1, [Define to compile with Kerberos 5 support.])
   LIBZEPHYR_LIBS="$LIBZEPHYR_LIBS $KRB5_LIBS"
   # the zephyr library needs -lresolv if it's built with krb5
   AC_CHECK_LIB(resolv, res_send, LIBZEPHYR_LIBS="-lresolv $LIBZEPHYR_LIBS",
   		AC_CHECK_LIB(resolv, __res_send, LIBZEPHYR_LIBS="-lresolv $LIBZEPHYR_LIBS",
			     AC_MSG_ERROR(Zephyr requires libresolv along with Kerberos V.)))
   case "$target_os" in 
      darwin*) KRB5_LIBS="$KRB5_LIBS -framework Kerberos" ;;
   esac 
fi
AC_SUBST(KRB5_LIBS)

AC_SUBST(LIBZEPHYR_LIBS)

AC_ARG_WITH(hesiod,
	[  --with-hesiod=PREFIX    Use Hesiod],
	[hesiod="$withval"], [hesiod=no])
if test "$hesiod" != no; then
	AC_CHECK_FUNC(res_send, :, AC_CHECK_LIB(resolv, res_send))
        if test "$hesiod" != yes; then
        	CPPFLAGS="$CPPFLAGS -I$hesiod/include"
        	LDFLAGS="$LDFLAGS -L$hesiod/lib"
        fi
        AC_CHECK_LIB(hesiod, hes_resolve, :,
	     [AC_MSG_ERROR(Hesiod library not found)],$LIBS)
	HESIOD_LIBS="-lhesiod"
	AC_DEFINE(HAVE_HESIOD, 1, [Define to compile with Hesiod support.])
fi

AC_SUBST(HESIOD_LIBS)

AC_ARG_WITH(regex,
	[  --with-regex=PREFIX     Use installed regex library],
	[regex="$withval"], [regex=no])
if test "$regex" != no; then
	if test "$regex" != yes; then
		CPPFLAGS="$CPPFLAGS -I$regex/include"
		LDFLAGS="$LDFLAGS -L$regex/lib"
	fi
	AC_CHECK_LIB(regex, regcomp, REGEX_LIBS=-lregex,
		     [AC_MSG_ERROR(regex library not found)])
else
	AC_CHECK_FUNC(regcomp, :,
		      [AC_MSG_ERROR(can't find POSIX regexp support)])
fi
AC_SUBST(REGEX_LIBS)

AC_ARG_WITH(com_err,
	[  --with-com_err=PREFIX   Specify location of com_err],
	[com_err="$withval"], [com_err=yes])
if test "$com_err" != no; then
	if test "$com_err" != yes; then
		CPPFLAGS="$CPPFLAGS -I$com_err/include"
		LDFLAGS="$LDFLAGS -L$com_err/lib"
	fi
	AC_CHECK_LIB(com_err, com_err, :,
		     [AC_MSG_ERROR(com_err library not found)])
else
	AC_MSG_ERROR(This package requires com_err.)
fi

AC_ARG_WITH(ss,
	[  --with-ss=PREFIX        Specify location of ss (requires com_err)],
	[ss="$withval"], [ss=yes])
if test "$ss" != no; then
	if test "$ss" != yes; then
		CPPFLAGS="$CPPFLAGS -I$ss/include"
		LDFLAGS="$LDFLAGS -L$ss/lib"
	fi
	AC_CHECK_LIB(ss, ss_perror, SS_LIBS="-lss -lreadline -lcurses",
		     [AC_MSG_ERROR(ss library not found)], -lcom_err -lreadline -lcurses)
	AC_SUBST(SS_LIBS)
else
	AC_MSG_ERROR(This package requires ss.)
fi

LIBS="$KRB5_LIBS $KRB4_LIBS $LIBS"

dnl Checks for library functions.
#XXX more looking for res_send
#AC_CHECK_FUNC(res_send, :, AC_CHECK_LIB(resolv, res_send))

AC_ARG_WITH([cares], AS_HELP_STRING([--with-cares], [Use libcares]))
if test "x$with_ares" != "xno"; then
   AC_CHECK_LIB(cares, ares_getnameinfo,
		       [ARES_LIBS="-lcares"
		       AC_DEFINE(HAVE_ARES, 1, [Define to compile with c-ares support.])],
		       AS_IF([test "x$with_ares" = "xyes"],
			     AC_MSG_ERROR(libcares not found)))
fi
AC_SUBST(ARES_LIBS)
		    
AC_PROG_GCC_TRADITIONAL
AC_FUNC_VPRINTF
AC_FUNC_GETPGRP
AC_FUNC_SETPGRP
AC_CHECK_FUNCS(putenv strchr memcpy memmove waitpid getlogin strerror random)
AC_CHECK_FUNCS(lrand48 gethostid getsid getpgid etext)
AC_CHECK_FUNCS(krb_get_err_text krb_log)
AC_CHECK_FUNCS(krb5_free_data krb5_c_make_checksum krb5_cc_set_default_name)
AC_CHECK_FUNCS(krb5_crypto_init krb5_c_decrypt)

AC_MSG_CHECKING(krb5_auth_con_getauthenticator out argument type)
AC_CACHE_VAL(ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer, [
local_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
AC_TRY_COMPILE(
[#include <krb5.h>
krb5_error_code
krb5_auth_con_getauthenticator(krb5_context context,
                           krb5_auth_context auth_context,
                           krb5_authenticator *authenticator);],
[krb5_error_code foo = krb5_auth_con_getauthenticator(0, 0, 0);],
ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=no,
[AC_TRY_COMPILE(
[#include <krb5.h>
krb5_error_code
krb5_auth_con_getauthenticator(krb5_context context,
                           krb5_auth_context auth_context,
                           krb5_authenticator **authenticator);],
[krb5_error_code foo = krb5_auth_con_getauthenticator(0, 0, 0);],
ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=yes,
[AC_MSG_ERROR([Cannot identify krb5_auth_con_getauthenticator function signature])]
)])
CPPFLAGS="${local_save_CPPFLAGS}"
])
krb5_authent_type='krb5_authenticator *'
if test "$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" = yes; then
        AC_DEFINE(KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER, 1,
                  [Define if `krb5_auth_con_getauthenticator' takes a double pointer third arg.])dnl
        krb5_authent_type='krb5_authenticator **'
fi
AC_MSG_RESULT($krb5_authent_type)

AC_MSG_CHECKING(for enc_part2 in struct krb5_ticket)
AC_CACHE_VAL(ac_cv_have_krb5_ticket_enc_part2, [
local_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
AC_TRY_COMPILE(
[#include <krb5.h>], [krb5_ticket _tkt; _tkt.enc_part2;],
ac_cv_have_krb5_ticket_enc_part2=yes,
ac_cv_have_krb5_ticket_enc_part2=no)
])
CPPFLAGS="${local_save_CPPFLAGS}"
if test "$ac_cv_have_krb5_ticket_enc_part2" = yes; then
	AC_DEFINE(HAVE_KRB5_TICKET_ENC_PART2, 1,
                  [Define to 1 if `enc_part2' is member of `krb5_ticket'.])dnl
fi
AC_MSG_RESULT($ac_cv_have_krb5_ticket_enc_part2)

AC_MSG_CHECKING(for enctype in struct krb5_keyblock)
AC_CACHE_VAL(ac_cv_have_krb5_creds_keyblock_enctype, [
local_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
AC_TRY_COMPILE(
[#include <krb5.h>], [krb5_creds _creds; _creds.keyblock.enctype;],
ac_cv_have_krb5_creds_keyblock_enctype=yes,
ac_cv_have_krb5_creds_keyblock_enctype=no)
])
CPPFLAGS="${local_save_CPPFLAGS}"
if test "$ac_cv_have_krb5_creds_keyblock_enctype" = yes; then
	AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE, 1,
                  [Define if `keyblock.enctype' is member of `krb5_creds'.])dnl
fi
AC_MSG_RESULT($ac_cv_have_krb5_creds_keyblock_enctype)

AC_ARG_ENABLE(cmu-zwgcplus,
[  --enable-cmu-zwgcplus   enable CMU zwgcplus extensions],[
if test "$enableval" = "yes"; then
        AC_DEFINE(CMU_ZWGCPLUS, 1, [Define to enable zwgcplus support])
fi
])

AC_ARG_ENABLE(cmu-zctl-punt,
[  --enable-cmu-zctl-punt  enable CMU zctl punt extensions],[
if test "$enableval" = "yes"; then
        AC_DEFINE(CMU_ZCTL_PUNT, 1,
                  [Define to pull in CMU zctl punt backward compat foo])
fi
])

AC_ARG_ENABLE(cmu-hm-flush-restrict,
[  --enable-cmu-hm-flush-restrict   enable CMU zctl hm flush restriction],[
if test "$enableval" = "yes"; then
        AC_DEFINE(HM_FLUSH_RESTRICT, 1,
                  [Define to get hm_flush restrictions in zctl])
fi
])

AC_ARG_ENABLE(cmu-opstaff-locate-self,
[  --enable-cmu-opstaff-locate-self enable CMU opstaff locate-self ability],[
if test "$enableval" = "yes"; then
        AC_DEFINE(OPSTAFF_LOCATE_SELF, 1,
                  [Define to allow users to locate themselves if they are opstaff])
fi
])

AC_CONFIG_HEADER(h/config.h)
AC_OUTPUT(Makefile clients/Makefile clients/zaway/Makefile
          clients/zctl/Makefile clients/zleave/Makefile
          clients/zlocate/Makefile clients/znol/Makefile
          clients/zshutdown_notify/Makefile clients/zstat/Makefile
          clients/zwrite/Makefile lib/Makefile
          server/Makefile zhm/Makefile zwgc/Makefile)