roken-frag.m4 revision 72445
1dnl $Id: roken-frag.m4,v 1.19 2000/12/15 14:29:54 assar Exp $
2dnl
3dnl some code to get roken working
4dnl
5dnl rk_ROKEN(subdir)
6dnl
7AC_DEFUN(rk_ROKEN, [
8
9AC_REQUIRE([rk_CONFIG_HEADER])
10
11DIR_roken=roken
12LIB_roken='$(top_builddir)/$1/libroken.la'
13INCLUDES_roken='-I$(top_builddir)/$1 -I$(top_srcdir)/$1'
14
15dnl Checks for programs
16AC_REQUIRE([AC_PROG_CC])
17AC_REQUIRE([AC_PROG_AWK])
18AC_REQUIRE([AC_OBJEXT])
19AC_REQUIRE([AC_EXEEXT])
20AC_REQUIRE([AC_PROG_LIBTOOL])
21
22AC_REQUIRE([AC_MIPS_ABI])
23
24dnl C characteristics
25
26AC_REQUIRE([AC_C___ATTRIBUTE__])
27AC_REQUIRE([AC_C_INLINE])
28AC_REQUIRE([AC_C_CONST])
29AC_WFLAGS(-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs)
30
31AC_REQUIRE([rk_DB])
32
33dnl C types
34
35AC_REQUIRE([AC_TYPE_SIZE_T])
36AC_CHECK_TYPE_EXTRA(ssize_t, int, [#include <unistd.h>])
37AC_REQUIRE([AC_TYPE_PID_T])
38AC_REQUIRE([AC_TYPE_UID_T])
39AC_HAVE_TYPE([long long])
40
41AC_REQUIRE([rk_RETSIGTYPE])
42
43dnl Checks for header files.
44AC_REQUIRE([AC_HEADER_STDC])
45AC_REQUIRE([AC_HEADER_TIME])
46
47AC_CHECK_HEADERS([\
48	arpa/inet.h				\
49	arpa/nameser.h				\
50	config.h				\
51	crypt.h					\
52	dbm.h					\
53	db.h					\
54	dirent.h				\
55	errno.h					\
56	err.h					\
57	fcntl.h					\
58	gdbm/ndbm.h				\
59	grp.h					\
60	ifaddrs.h				\
61	ndbm.h					\
62	net/if.h				\
63	netdb.h					\
64	netinet/in.h				\
65	netinet/in6.h				\
66	netinet/in_systm.h			\
67	netinet6/in6.h				\
68	netinet6/in6_var.h			\
69	paths.h					\
70	pwd.h					\
71	resolv.h				\
72	rpcsvc/dbm.h				\
73	rpcsvc/ypclnt.h				\
74	shadow.h				\
75	sys/ioctl.h				\
76	sys/param.h				\
77	sys/proc.h				\
78	sys/resource.h				\
79	sys/socket.h				\
80	sys/sockio.h				\
81	sys/stat.h				\
82	sys/sysctl.h				\
83	sys/time.h				\
84	sys/tty.h				\
85	sys/types.h				\
86	sys/uio.h				\
87	sys/utsname.h				\
88	sys/wait.h				\
89	syslog.h				\
90	termios.h				\
91	unistd.h				\
92	userconf.h				\
93	usersec.h				\
94	util.h					\
95	vis.h					\
96	winsock.h				\
97])
98	
99AC_REQUIRE([CHECK_NETINET_IP_AND_TCP])
100
101AM_CONDITIONAL(have_err_h, test "$ac_cv_header_err_h" = yes)
102AM_CONDITIONAL(have_fnmatch_h, test "$ac_cv_header_fnmatch_h" = yes)
103AM_CONDITIONAL(have_ifaddrs_h, test "$ac_cv_header_ifaddrs_h" = yes)
104AM_CONDITIONAL(have_vis_h, test "$ac_cv_header_vis_h" = yes)
105
106dnl Check for functions and libraries
107
108AC_KRB_IPV6
109
110AC_FIND_FUNC(socket, socket)
111AC_FIND_FUNC(gethostbyname, nsl)
112AC_FIND_FUNC(syslog, syslog)
113AC_FIND_FUNC(gethostbyname2, inet6 ip6)
114
115AC_FIND_FUNC(res_search, resolv,
116[
117#include <stdio.h>
118#ifdef HAVE_SYS_TYPES_H
119#include <sys/types.h>
120#endif
121#ifdef HAVE_NETINET_IN_H
122#include <netinet/in.h>
123#endif
124#ifdef HAVE_ARPA_NAMESER_H
125#include <arpa/nameser.h>
126#endif
127#ifdef HAVE_RESOLV_H
128#include <resolv.h>
129#endif
130],
131[0,0,0,0,0])
132
133AC_FIND_FUNC(dn_expand, resolv,
134[
135#include <stdio.h>
136#ifdef HAVE_SYS_TYPES_H
137#include <sys/types.h>
138#endif
139#ifdef HAVE_NETINET_IN_H
140#include <netinet/in.h>
141#endif
142#ifdef HAVE_ARPA_NAMESER_H
143#include <arpa/nameser.h>
144#endif
145#ifdef HAVE_RESOLV_H
146#include <resolv.h>
147#endif
148],
149[0,0,0,0,0])
150
151AC_BROKEN_SNPRINTF
152AC_BROKEN_VSNPRINTF
153
154AC_BROKEN_GLOB
155if test "$ac_cv_func_glob_working" != yes; then
156	LIBOBJS="$LIBOBJS glob.o"
157fi
158AM_CONDITIONAL(have_glob_h, test "$ac_cv_func_glob_working" = yes)
159
160
161AC_CHECK_FUNCS([				\
162	asnprintf				\
163	asprintf				\
164	cgetent					\
165	getconfattr				\
166	getrlimit				\
167	getspnam				\
168	strsvis					\
169	strunvis				\
170	strvis					\
171	strvisx					\
172	svis					\
173	sysconf					\
174	sysctl					\
175	uname					\
176	unvis					\
177	vasnprintf				\
178	vasprintf				\
179	vis					\
180])
181
182if test "$ac_cv_func_cgetent" = no; then
183	LIBOBJS="$LIBOBJS getcap.o"
184fi
185
186AC_REQUIRE([AC_FUNC_GETLOGIN])
187
188AC_FIND_FUNC_NO_LIBS(getsockopt,,
189[#ifdef HAVE_SYS_TYPES_H
190#include <sys/types.h>
191#endif
192#ifdef HAVE_SYS_SOCKET_H
193#include <sys/socket.h>
194#endif],
195[0,0,0,0,0])
196AC_FIND_FUNC_NO_LIBS(setsockopt,,
197[#ifdef HAVE_SYS_TYPES_H
198#include <sys/types.h>
199#endif
200#ifdef HAVE_SYS_SOCKET_H
201#include <sys/socket.h>
202#endif],
203[0,0,0,0,0])
204
205AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
206[#ifdef HAVE_NETDB_H
207#include <netdb.h>
208#endif],
20917)
210if test "$ac_cv_func_hstrerror" = yes; then
211AC_NEED_PROTO([
212#ifdef HAVE_NETDB_H
213#include <netdb.h>
214#endif],
215hstrerror)
216fi
217
218dnl sigh, wish this could be done in a loop
219if test "$ac_cv_func_asprintf" = yes; then
220AC_NEED_PROTO([
221#include <stdio.h>
222#include <string.h>],
223asprintf)dnl
224fi
225if test "$ac_cv_func_vasprintf" = yes; then
226AC_NEED_PROTO([
227#include <stdio.h>
228#include <string.h>],
229vasprintf)dnl
230fi
231if test "$ac_cv_func_asnprintf" = yes; then
232AC_NEED_PROTO([
233#include <stdio.h>
234#include <string.h>],
235asnprintf)dnl
236fi
237if test "$ac_cv_func_vasnprintf" = yes; then
238AC_NEED_PROTO([
239#include <stdio.h>
240#include <string.h>],
241vasnprintf)dnl
242fi
243
244AC_FIND_FUNC_NO_LIBS(pidfile,util,
245[#ifdef HAVE_UTIL_H
246#include <util.h>
247#endif],0)
248
249AC_BROKEN([					\
250	chown					\
251	copyhostent				\
252	daemon					\
253	err					\
254	errx					\
255	fchown					\
256	flock					\
257	fnmatch					\
258	freeaddrinfo				\
259	freehostent				\
260	gai_strerror				\
261	getaddrinfo				\
262	getcwd					\
263	getdtablesize				\
264	getegid					\
265	geteuid					\
266	getgid					\
267	gethostname				\
268	getifaddrs				\
269	getipnodebyaddr				\
270	getipnodebyname				\
271	getnameinfo				\
272	getopt					\
273	gettimeofday				\
274	getuid					\
275	getusershell				\
276	initgroups				\
277	innetgr					\
278	iruserok				\
279	lstat					\
280	memmove					\
281	mkstemp					\
282	putenv					\
283	rcmd					\
284	readv					\
285	recvmsg					\
286	sendmsg					\
287	setegid					\
288	setenv					\
289	seteuid					\
290	strcasecmp				\
291	strdup					\
292	strerror				\
293	strftime				\
294	strlcat					\
295	strlcpy					\
296	strlwr					\
297	strncasecmp				\
298	strndup					\
299	strnlen					\
300	strptime				\
301	strsep					\
302	strsep_copy				\
303	strtok_r				\
304	strupr					\
305	swab					\
306	unsetenv				\
307	verr					\
308	verrx					\
309	vsyslog					\
310	vwarn					\
311	vwarnx					\
312	warn					\
313	warnx					\
314	writev					\
315])
316
317AC_BROKEN2(inet_aton,
318[#ifdef HAVE_SYS_TYPES_H
319#include <sys/types.h>
320#endif
321#ifdef HAVE_SYS_SOCKET_H
322#include <sys/socket.h>
323#endif
324#ifdef HAVE_NETINET_IN_H
325#include <netinet/in.h>
326#endif
327#ifdef HAVE_ARPA_INET_H
328#include <arpa/inet.h>
329#endif],
330[0,0])
331
332AC_BROKEN2(inet_ntop,
333[#ifdef HAVE_SYS_TYPES_H
334#include <sys/types.h>
335#endif
336#ifdef HAVE_SYS_SOCKET_H
337#include <sys/socket.h>
338#endif
339#ifdef HAVE_NETINET_IN_H
340#include <netinet/in.h>
341#endif
342#ifdef HAVE_ARPA_INET_H
343#include <arpa/inet.h>
344#endif],
345[0, 0, 0, 0])
346
347AC_BROKEN2(inet_pton,
348[#ifdef HAVE_SYS_TYPES_H
349#include <sys/types.h>
350#endif
351#ifdef HAVE_SYS_SOCKET_H
352#include <sys/socket.h>
353#endif
354#ifdef HAVE_NETINET_IN_H
355#include <netinet/in.h>
356#endif
357#ifdef HAVE_ARPA_INET_H
358#include <arpa/inet.h>
359#endif],
360[0,0,0])
361
362dnl
363dnl Check for sa_len in struct sockaddr, 
364dnl needs to come before the getnameinfo test
365dnl
366AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
367#include <sys/socket.h>])
368
369if test "$ac_cv_func_getnameinfo" = "yes"; then
370  rk_BROKEN_GETNAMEINFO
371  if test "$ac_cv_func_getnameinfo_broken" = yes; then
372    LIBOBJS="$LIBOBJS getnameinfo.o"
373  fi
374fi
375
376AC_NEED_PROTO([#include <stdlib.h>], setenv)
377AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
378AC_NEED_PROTO([#include <unistd.h>], gethostname)
379AC_NEED_PROTO([#include <unistd.h>], mkstemp)
380AC_NEED_PROTO([#include <unistd.h>], getusershell)
381
382AC_NEED_PROTO([
383#ifdef HAVE_SYS_TYPES_H
384#include <sys/types.h>
385#endif
386#ifdef HAVE_SYS_SOCKET_H
387#include <sys/socket.h>
388#endif
389#ifdef HAVE_NETINET_IN_H
390#include <netinet/in.h>
391#endif
392#ifdef HAVE_ARPA_INET_H
393#include <arpa/inet.h>
394#endif],
395inet_aton)
396
397AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
398
399AC_REQUIRE([rk_BROKEN_REALLOC])dnl
400
401dnl AC_KRB_FUNC_GETCWD_BROKEN
402
403dnl
404dnl Checks for prototypes and declarations
405dnl
406
407AC_PROTO_COMPAT([
408#ifdef HAVE_SYS_TYPES_H
409#include <sys/types.h>
410#endif
411#ifdef HAVE_SYS_SOCKET_H
412#include <sys/socket.h>
413#endif
414#ifdef HAVE_NETINET_IN_H
415#include <netinet/in.h>
416#endif
417#ifdef HAVE_ARPA_INET_H
418#include <arpa/inet.h>
419#endif
420#ifdef HAVE_NETDB_H
421#include <netdb.h>
422#endif
423],
424gethostbyname, struct hostent *gethostbyname(const char *))
425
426AC_PROTO_COMPAT([
427#ifdef HAVE_SYS_TYPES_H
428#include <sys/types.h>
429#endif
430#ifdef HAVE_SYS_SOCKET_H
431#include <sys/socket.h>
432#endif
433#ifdef HAVE_NETINET_IN_H
434#include <netinet/in.h>
435#endif
436#ifdef HAVE_ARPA_INET_H
437#include <arpa/inet.h>
438#endif
439#ifdef HAVE_NETDB_H
440#include <netdb.h>
441#endif
442],
443gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
444
445AC_PROTO_COMPAT([
446#ifdef HAVE_SYS_TYPES_H
447#include <sys/types.h>
448#endif
449#ifdef HAVE_SYS_SOCKET_H
450#include <sys/socket.h>
451#endif
452#ifdef HAVE_NETINET_IN_H
453#include <netinet/in.h>
454#endif
455#ifdef HAVE_ARPA_INET_H
456#include <arpa/inet.h>
457#endif
458#ifdef HAVE_NETDB_H
459#include <netdb.h>
460#endif
461],
462getservbyname, struct servent *getservbyname(const char *, const char *))
463
464AC_PROTO_COMPAT([
465#ifdef HAVE_SYS_TYPES_H
466#include <sys/types.h>
467#endif
468#ifdef HAVE_SYS_SOCKET_H
469#include <sys/socket.h>
470#endif
471],
472getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
473
474AC_PROTO_COMPAT([
475#ifdef HAVE_SYSLOG_H
476#include <syslog.h>
477#endif
478],
479openlog, void openlog(const char *, int, int))
480
481AC_NEED_PROTO([
482#ifdef HAVE_CRYPT_H
483#include <crypt.h>
484#endif
485#ifdef HAVE_UNISTD_H
486#include <unistd.h>
487#endif
488],
489crypt)
490
491AC_NEED_PROTO([
492#include <string.h>
493],
494strtok_r)
495
496AC_NEED_PROTO([
497#include <string.h>
498],
499strsep)
500
501dnl variables
502
503rk_CHECK_VAR(h_errno, 
504[#ifdef HAVE_SYS_TYPES_H
505#include <sys/types.h>
506#endif
507#ifdef HAVE_NETDB_H
508#include <netdb.h>
509#endif])
510
511rk_CHECK_VAR(h_errlist, 
512[#ifdef HAVE_NETDB_H
513#include <netdb.h>
514#endif])
515
516rk_CHECK_VAR(h_nerr, 
517[#ifdef HAVE_NETDB_H
518#include <netdb.h>
519#endif])
520
521rk_CHECK_VAR([__progname], 
522[#ifdef HAVE_ERR_H
523#include <err.h>
524#endif])
525
526AC_CHECK_DECLARATION([#include <stdlib.h>
527#ifdef HAVE_UNISTD_H
528#include <unistd.h>
529#endif], optarg)
530AC_CHECK_DECLARATION([#include <stdlib.h>
531#ifdef HAVE_UNISTD_H
532#include <unistd.h>
533#endif], optind)
534AC_CHECK_DECLARATION([#include <stdlib.h>
535#ifdef HAVE_UNISTD_H
536#include <unistd.h>
537#endif], opterr)
538AC_CHECK_DECLARATION([#include <stdlib.h>
539#ifdef HAVE_UNISTD_H
540#include <unistd.h>
541#endif], optopt)
542
543AC_CHECK_DECLARATION([#include <stdlib.h>], environ)
544
545dnl
546dnl Check for fields in struct tm
547dnl
548
549AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
550AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
551
552dnl
553dnl or do we have a variable `timezone' ?
554dnl
555
556rk_CHECK_VAR(timezone,[#include <time.h>])
557
558AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
559AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
560AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
561AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
562AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
563AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
564
565dnl
566dnl Check for struct winsize
567dnl
568
569AC_KRB_STRUCT_WINSIZE
570
571dnl
572dnl Check for struct spwd
573dnl
574
575AC_KRB_STRUCT_SPWD
576
577dnl won't work with automake
578dnl moved to AC_OUTPUT in configure.in
579dnl AC_CONFIG_FILES($1/Makefile)
580
581LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
582
583AC_SUBST(DIR_roken)dnl
584AC_SUBST(LIB_roken)dnl
585AC_SUBST(INCLUDES_roken)dnl
586])