1dnl Id
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
24AC_DEFINE(rk_PATH_DELIM, '/', [Path name delimiter])
25
26dnl C characteristics
27
28AC_REQUIRE([AC_C___ATTRIBUTE__])
29AC_REQUIRE([AC_C_INLINE])
30AC_REQUIRE([AC_C_CONST])
31rk_WFLAGS(-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs)
32
33AC_REQUIRE([rk_DB])
34
35dnl C types
36
37AC_REQUIRE([AC_TYPE_SIZE_T])
38AC_HAVE_TYPE([ssize_t],[#include <unistd.h>])
39AC_REQUIRE([AC_TYPE_PID_T])
40AC_REQUIRE([AC_TYPE_UID_T])
41AC_HAVE_TYPE([long long])
42
43AC_REQUIRE([rk_RETSIGTYPE])
44
45dnl Checks for header files.
46AC_REQUIRE([AC_HEADER_STDC])
47AC_REQUIRE([AC_HEADER_TIME])
48
49AC_CHECK_HEADERS([\
50	arpa/inet.h				\
51	config.h				\
52	crypt.h					\
53	dirent.h				\
54	errno.h					\
55	err.h					\
56	fcntl.h					\
57	fnmatch.h				\
58	grp.h					\
59	ifaddrs.h				\
60	netinet/in.h				\
61	netinet/in6.h				\
62	netinet/in_systm.h			\
63	netinet6/in6.h				\
64	paths.h					\
65	poll.h					\
66	pwd.h					\
67	rpcsvc/ypclnt.h				\
68	search.h				\
69	shadow.h				\
70	stdint.h				\
71	sys/bswap.h				\
72	sys/ioctl.h				\
73	sys/mman.h				\
74	sys/param.h				\
75	sys/resource.h				\
76	sys/sockio.h				\
77	sys/stat.h				\
78	sys/time.h				\
79	sys/tty.h				\
80	sys/types.h				\
81	sys/uio.h				\
82	sys/utsname.h				\
83	sys/wait.h				\
84	syslog.h				\
85	termios.h				\
86	winsock2.h				\
87	ws2tcpip.h				\
88	unistd.h				\
89	userconf.h				\
90	usersec.h				\
91	util.h					\
92])
93
94AC_HAVE_TYPE([uintptr_t],[#ifdef HAVE_STDINT_H
95#include <stdint.h>
96#endif])
97
98dnl Sunpro 5.2 has a vis.h which is something different.
99AC_CHECK_HEADERS(vis.h, , , [
100#include <vis.h>
101#ifndef VIS_SP
102#error invis
103#endif])
104
105AC_CHECK_HEADERS(netdb.h, , , [AC_INCLUDES_DEFAULT
106#ifdef HAVE_SYS_TYPES_H
107#include <sys/types.h>
108#endif
109])
110
111AC_CHECK_HEADERS(sys/socket.h, , , [AC_INCLUDES_DEFAULT
112#ifdef HAVE_SYS_TYPES_H
113#include <sys/types.h>
114#endif
115])
116
117AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
118#ifdef HAVE_SYS_TYPES_H
119#include <sys/types.h>
120#endif
121#if HAVE_SYS_SOCKET_H
122#include <sys/socket.h>
123#endif])
124
125AC_CHECK_HEADERS(netinet6/in6_var.h, , , [AC_INCLUDES_DEFAULT
126#ifdef HAVE_SYS_TYPES_H
127#include <sys/types.h>
128#endif
129#if HAVE_SYS_SOCKET_H
130#include <sys/socket.h>
131#endif
132#ifdef HAVE_NETINET6_IN6_H
133#include <netinet6/in6.h>
134#endif
135])
136
137AC_CHECK_HEADERS(sys/sysctl.h, , , [AC_INCLUDES_DEFAULT
138#ifdef HAVE_SYS_PARAM_H
139#include <sys/param.h>
140#endif
141])
142
143AC_CHECK_HEADERS(sys/proc.h, , , [AC_INCLUDES_DEFAULT
144#ifdef HAVE_SYS_PARAM_H
145#include <sys/param.h>
146#endif
147])
148
149AC_REQUIRE([CHECK_NETINET_IP_AND_TCP])
150
151AM_CONDITIONAL(have_err_h, test "$ac_cv_header_err_h" = yes)
152AM_CONDITIONAL(have_ifaddrs_h, test "$ac_cv_header_ifaddrs_h" = yes)
153AM_CONDITIONAL(have_search_h, test "$ac_cv_header_search_h" = yes)
154AM_CONDITIONAL(have_vis_h, test "$ac_cv_header_vis_h" = yes)
155
156dnl Check for functions and libraries
157
158AC_FIND_FUNC(socket, socket)
159AC_FIND_FUNC(gethostbyname, nsl)
160AC_FIND_FUNC(syslog, syslog)
161
162AC_KRB_IPV6
163
164AC_FIND_FUNC(gethostbyname2, inet6 ip6)
165
166rk_RESOLV
167
168AC_BROKEN_SNPRINTF
169AC_BROKEN_VSNPRINTF
170
171AC_BROKEN_GLOB
172if test "$ac_cv_func_glob_working" != yes; then
173	AC_LIBOBJ(glob)
174fi
175AM_CONDITIONAL(have_glob_h, test "$ac_cv_func_glob_working" = yes)
176
177
178AC_CHECK_FUNCS([				\
179	asnprintf				\
180	asprintf				\
181	atexit					\
182	cgetent					\
183	getconfattr				\
184	getprogname				\
185	getrlimit				\
186	getspnam				\
187	initstate				\
188	issetugid				\
189	on_exit					\
190	poll					\
191	random					\
192	setprogname				\
193	setstate				\
194	strsvis					\
195	strsvisx				\
196	strunvis				\
197	strvis					\
198	strvisx					\
199	svis					\
200	sysconf					\
201	sysctl					\
202	tdelete					\
203	tfind					\
204	tsearch					\
205	twalk					\
206	uname					\
207	unvis					\
208	vasnprintf				\
209	vasprintf				\
210	vis					\
211])
212
213if test "$ac_cv_func_cgetent" = no; then
214	AC_LIBOBJ(getcap)
215fi
216AM_CONDITIONAL(have_cgetent, test "$ac_cv_func_cgetent" = yes)
217
218AC_REQUIRE([AC_FUNC_GETLOGIN])
219
220AC_REQUIRE([AC_FUNC_MMAP])
221
222AC_FIND_FUNC_NO_LIBS(getsockopt,,
223[#ifdef HAVE_SYS_TYPES_H
224#include <sys/types.h>
225#endif
226#ifdef HAVE_SYS_SOCKET_H
227#include <sys/socket.h>
228#endif],
229[0,0,0,0,0])
230AC_FIND_FUNC_NO_LIBS(setsockopt,,
231[#ifdef HAVE_SYS_TYPES_H
232#include <sys/types.h>
233#endif
234#ifdef HAVE_SYS_SOCKET_H
235#include <sys/socket.h>
236#endif],
237[0,0,0,0,0])
238
239AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
240[#ifdef HAVE_NETDB_H
241#include <netdb.h>
242#endif],
24317)
244AC_NEED_PROTO([
245#ifdef HAVE_NETDB_H
246#include <netdb.h>
247#endif],
248hstrerror)
249
250AC_FOREACH([rk_func], [asprintf vasprintf asnprintf vasnprintf],
251	[AC_NEED_PROTO([
252	#include <stdio.h>
253	#include <string.h>],
254	rk_func)])
255
256AC_FIND_FUNC_NO_LIBS(bswap16,,
257[#ifdef HAVE_SYS_TYPES_H
258#include <sys/types.h>
259#endif
260#ifdef HAVE_SYS_BSWAP_H
261#include <sys/bswap.h>
262#endif],0)
263
264AC_FIND_FUNC_NO_LIBS(bswap32,,
265[#ifdef HAVE_SYS_TYPES_H
266#include <sys/types.h>
267#endif
268#ifdef HAVE_SYS_BSWAP_H
269#include <sys/bswap.h>
270#endif],0)
271
272AC_FIND_FUNC_NO_LIBS(pidfile,util,
273[#ifdef HAVE_UTIL_H
274#include <util.h>
275#endif],0)
276
277AC_FIND_IF_NOT_BROKEN(getaddrinfo,,
278[#ifdef HAVE_NETDB_H
279#include <netdb.h>
280#endif
281#ifdef HAVE_WS2TCPIP_H
282#include <ws2tcpip.h>
283#endif],[0,0,0,0])
284
285AC_FIND_IF_NOT_BROKEN(getnameinfo,,
286[#ifdef HAVE_NETDB_H
287#include <netdb.h>
288#endif
289#ifdef HAVE_WS2TCPIP_H
290#include <ws2tcpip.h>
291#endif],[0,0,0,0,0,0,0])
292
293AC_FIND_IF_NOT_BROKEN(freeaddrinfo,,
294[#ifdef HAVE_NETDB_H
295#include <netdb.h>
296#endif
297#ifdef HAVE_WS2TCPIP_H
298#include <ws2tcpip.h>
299#endif],[0])
300
301AC_FIND_IF_NOT_BROKEN(gai_strerror,,
302[#ifdef HAVE_NETDB_H
303#include <netdb.h>
304#endif
305#ifdef HAVE_WS2TCPIP_H
306#include <ws2tcpip.h>
307#endif],[0])
308
309dnl Darwin is weird, and in some senses not unix, launchd doesn't want
310dnl servers to use daemon(), so its deprecated.
311case "$host_os" in
312	darwin*)
313		;;
314	*)
315		AC_DEFINE([SUPPORT_DETACH], 1,
316		    [Define if os support want to detach is daemonens.])
317		AC_BROKEN([daemon]) ;;
318esac
319
320AC_BROKEN([					\
321	chown					\
322	copyhostent				\
323	closefrom				\
324	ecalloc					\
325	emalloc					\
326	erealloc				\
327	estrdup					\
328	err					\
329	errx					\
330	fchown					\
331	flock					\
332	fnmatch					\
333	freehostent				\
334	getcwd					\
335	getdtablesize				\
336	getegid					\
337	geteuid					\
338	getgid					\
339	gethostname				\
340	getifaddrs				\
341	getipnodebyaddr				\
342	getipnodebyname				\
343	getopt					\
344	gettimeofday				\
345	getuid					\
346	getusershell				\
347	initgroups				\
348	innetgr					\
349	iruserok				\
350	localtime_r				\
351	lstat					\
352	memmove					\
353	mkstemp					\
354	putenv					\
355	rcmd					\
356	readv					\
357	recvmsg					\
358	sendmsg					\
359	setegid					\
360	setenv					\
361	seteuid					\
362	strcasecmp				\
363	strdup					\
364	strerror				\
365	strftime				\
366	strlcat					\
367	strlcpy					\
368	strlwr					\
369	strncasecmp				\
370	strndup					\
371	strnlen					\
372	strptime				\
373	strsep					\
374	strsep_copy				\
375	strtok_r				\
376	strupr					\
377	swab					\
378	timegm					\
379	unsetenv				\
380	verr					\
381	verrx					\
382	vsyslog					\
383	vwarn					\
384	vwarnx					\
385	warn					\
386	warnx					\
387	writev					\
388])
389
390AM_CONDITIONAL(have_fnmatch_h,
391	test "$ac_cv_header_fnmatch_h" = yes -a "$ac_cv_func_fnmatch" = yes)
392
393AC_FOREACH([rk_func], [strndup strsep strtok_r],
394	[AC_NEED_PROTO([#include <string.h>], rk_func)])
395
396AC_FOREACH([rk_func], [strsvis strsvisx strunvis strvis strvisx svis unvis vis],
397[AC_NEED_PROTO([#ifdef HAVE_VIS_H
398#include <vis.h>
399#endif], rk_func)])
400
401AC_MSG_CHECKING([checking for dirfd])
402AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
403#ifdef HAVE_DIRENT_H
404#include <dirent.h>
405#endif
406]],
407	[[DIR *d = 0; dirfd(d);]])],
408	[ac_rk_have_dirfd=yes], [ac_rk_have_dirfd=no])
409if test "$ac_rk_have_dirfd" = "yes" ; then
410	AC_DEFINE_UNQUOTED(HAVE_DIRFD, 1, [have a dirfd function/macro])
411fi
412AC_MSG_RESULT($ac_rk_have_dirfd)
413
414AC_HAVE_STRUCT_FIELD(DIR, dd_fd, [#include <sys/types.h>
415#ifdef HAVE_DIRENT_H
416#include <dirent.h>
417#endif])
418
419
420AC_BROKEN2(inet_aton,
421[#ifdef HAVE_SYS_TYPES_H
422#include <sys/types.h>
423#endif
424#ifdef HAVE_SYS_SOCKET_H
425#include <sys/socket.h>
426#endif
427#ifdef HAVE_NETINET_IN_H
428#include <netinet/in.h>
429#endif
430#ifdef HAVE_ARPA_INET_H
431#include <arpa/inet.h>
432#endif],
433[0,0])
434
435AC_BROKEN2(inet_ntop,
436[#ifdef HAVE_SYS_TYPES_H
437#include <sys/types.h>
438#endif
439#ifdef HAVE_SYS_SOCKET_H
440#include <sys/socket.h>
441#endif
442#ifdef HAVE_NETINET_IN_H
443#include <netinet/in.h>
444#endif
445#ifdef HAVE_ARPA_INET_H
446#include <arpa/inet.h>
447#endif],
448[0, 0, 0, 0])
449
450AC_BROKEN2(inet_pton,
451[#ifdef HAVE_SYS_TYPES_H
452#include <sys/types.h>
453#endif
454#ifdef HAVE_SYS_SOCKET_H
455#include <sys/socket.h>
456#endif
457#ifdef HAVE_NETINET_IN_H
458#include <netinet/in.h>
459#endif
460#ifdef HAVE_ARPA_INET_H
461#include <arpa/inet.h>
462#endif],
463[0,0,0])
464
465dnl
466dnl Check for sa_len in struct sockaddr,
467dnl needs to come before the getnameinfo test
468dnl
469AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
470#include <sys/socket.h>])
471
472if test "$ac_cv_func_getaddrinfo" = "yes"; then
473  rk_BROKEN_GETADDRINFO
474  if test "$ac_cv_func_getaddrinfo_numserv" = no; then
475	AC_LIBOBJ(getaddrinfo)
476	AC_LIBOBJ(freeaddrinfo)
477  fi
478fi
479
480AC_NEED_PROTO([#include <stdlib.h>], setenv)
481AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
482AC_NEED_PROTO([#include <unistd.h>], gethostname)
483AC_NEED_PROTO([#include <unistd.h>], mkstemp)
484AC_NEED_PROTO([#include <unistd.h>], getusershell)
485AC_NEED_PROTO([#include <unistd.h>], daemon)
486AC_NEED_PROTO([
487#ifdef HAVE_SYS_TYPES_H
488#include <sys/types.h>
489#endif
490#ifdef HAVE_SYS_SOCKET_H
491#include <sys/socket.h>
492#endif
493#ifdef HAVE_NETINET_IN_H
494#include <netinet/in.h>
495#endif
496#ifdef HAVE_ARPA_INET_H
497#include <arpa/inet.h>
498#endif
499#ifdef HAVE_NETDB_H
500#include <netdb.h>
501#endif
502#ifdef HAVE_UNISTD_H
503#include <unistd.h>
504#endif],
505iruserok)
506
507AC_NEED_PROTO([
508#ifdef HAVE_SYS_TYPES_H
509#include <sys/types.h>
510#endif
511#ifdef HAVE_SYS_SOCKET_H
512#include <sys/socket.h>
513#endif
514#ifdef HAVE_NETINET_IN_H
515#include <netinet/in.h>
516#endif
517#ifdef HAVE_ARPA_INET_H
518#include <arpa/inet.h>
519#endif],
520inet_aton)
521
522AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl
523
524AC_REQUIRE([rk_BROKEN_REALLOC])dnl
525
526dnl AC_KRB_FUNC_GETCWD_BROKEN
527
528dnl strerror_r is great fun, on linux it exists before sus catched up,
529dnl so the return type is diffrent, lets check for both
530
531AC_PROTO_COMPAT([
532#include <stdio.h>
533#include <string.h>
534],
535strerror_r, int strerror_r(int, char *, size_t))
536
537AC_CHECK_FUNC([strerror_r],
538    [AC_DEFINE_UNQUOTED(HAVE_STRERROR_R, 1,
539        [Define if you have the function strerror_r.])])
540
541dnl
542dnl Checks for prototypes and declarations
543dnl
544
545AC_PROTO_COMPAT([
546#ifdef HAVE_SYS_TYPES_H
547#include <sys/types.h>
548#endif
549#ifdef HAVE_SYS_SOCKET_H
550#include <sys/socket.h>
551#endif
552#ifdef HAVE_NETINET_IN_H
553#include <netinet/in.h>
554#endif
555#ifdef HAVE_ARPA_INET_H
556#include <arpa/inet.h>
557#endif
558#ifdef HAVE_NETDB_H
559#include <netdb.h>
560#endif
561],
562gethostbyname, struct hostent *gethostbyname(const char *))
563
564AC_PROTO_COMPAT([
565#ifdef HAVE_SYS_TYPES_H
566#include <sys/types.h>
567#endif
568#ifdef HAVE_SYS_SOCKET_H
569#include <sys/socket.h>
570#endif
571#ifdef HAVE_NETINET_IN_H
572#include <netinet/in.h>
573#endif
574#ifdef HAVE_ARPA_INET_H
575#include <arpa/inet.h>
576#endif
577#ifdef HAVE_NETDB_H
578#include <netdb.h>
579#endif
580],
581gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))
582
583AC_PROTO_COMPAT([
584#ifdef HAVE_SYS_TYPES_H
585#include <sys/types.h>
586#endif
587#ifdef HAVE_SYS_SOCKET_H
588#include <sys/socket.h>
589#endif
590#ifdef HAVE_NETINET_IN_H
591#include <netinet/in.h>
592#endif
593#ifdef HAVE_ARPA_INET_H
594#include <arpa/inet.h>
595#endif
596#ifdef HAVE_NETDB_H
597#include <netdb.h>
598#endif
599],
600getservbyname, struct servent *getservbyname(const char *, const char *))
601
602AC_PROTO_COMPAT([
603#ifdef HAVE_SYS_TYPES_H
604#include <sys/types.h>
605#endif
606#ifdef HAVE_SYS_SOCKET_H
607#include <sys/socket.h>
608#endif
609],
610getsockname, int getsockname(int, struct sockaddr*, socklen_t*))
611
612AC_PROTO_COMPAT([
613#ifdef HAVE_SYSLOG_H
614#include <syslog.h>
615#endif
616],
617openlog, void openlog(const char *, int, int))
618
619AC_NEED_PROTO([
620#ifdef HAVE_CRYPT_H
621#include <crypt.h>
622#endif
623#ifdef HAVE_UNISTD_H
624#include <unistd.h>
625#endif
626],
627crypt)
628
629dnl variables
630
631rk_CHECK_VAR(h_errno,
632[#ifdef HAVE_SYS_TYPES_H
633#include <sys/types.h>
634#endif
635#ifdef HAVE_NETDB_H
636#include <netdb.h>
637#endif
638#ifdef HAVE_WS2TCPIP_H
639#include <ws2tcpip.h>
640#endif
641])
642
643rk_CHECK_VAR(h_errlist,
644[#ifdef HAVE_NETDB_H
645#include <netdb.h>
646#endif
647#ifdef HAVE_WS2TCPIP_H
648#include <ws2tcpip.h>
649#endif])
650
651rk_CHECK_VAR(h_nerr,
652[#ifdef HAVE_NETDB_H
653#include <netdb.h>
654#endif
655#ifdef HAVE_WS2TCPIP_H
656#include <ws2tcpip.h>
657#endif])
658
659rk_CHECK_VAR([__progname],
660[#ifdef HAVE_ERR_H
661#include <err.h>
662#endif])
663
664AC_CHECK_DECLS([optarg, optind, opterr, optopt, environ],[],[],[
665#include <stdlib.h>
666#ifdef HAVE_UNISTD_H
667#include <unistd.h>
668#endif])
669
670dnl
671dnl Check for fields in struct tm
672dnl
673
674AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
675AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])
676
677dnl
678dnl or do we have a variable `timezone' ?
679dnl
680
681rk_CHECK_VAR(timezone,[#include <time.h>])
682rk_CHECK_VAR(altzone,[#include <time.h>])
683
684AC_HAVE_TYPE([sa_family_t],[
685#include <sys/types.h>
686#ifdef HAVE_SYS_SOCKET_H
687#include <sys/socket.h>
688#endif
689#ifdef HAVE_WS2TCPIP_H
690#include <ws2tcpip.h>
691#endif])
692AC_HAVE_TYPE([socklen_t],[
693#include <sys/types.h>
694#ifdef HAVE_SYS_SOCKET_H
695#include <sys/socket.h>
696#endif
697#ifdef HAVE_WS2TCPIP_H
698#include <ws2tcpip.h>
699#endif])
700AC_HAVE_TYPE([struct sockaddr], [
701#include <sys/types.h>
702#ifdef HAVE_SYS_SOCKET_H
703#include <sys/socket.h>
704#endif
705#ifdef HAVE_WS2TCPIP_H
706#include <ws2tcpip.h>
707#endif])
708AC_HAVE_TYPE([struct sockaddr_storage], [
709#include <sys/types.h>
710#ifdef HAVE_SYS_SOCKET_H
711#include <sys/socket.h>
712#endif
713#ifdef HAVE_WS2TCPIP_H
714#include <ws2tcpip.h>
715#endif])
716AC_HAVE_TYPE([struct addrinfo], [
717#include <sys/types.h>
718#ifdef HAVE_NETDB_H
719#include <netdb.h>
720#endif
721#ifdef HAVE_WS2TCPIP_H
722#include <ws2tcpip.h>
723#endif])
724AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
725AC_HAVE_TYPE([struct iovec],[
726#include <sys/types.h>
727#include <sys/uio.h>
728])
729AC_HAVE_TYPE([struct msghdr],[
730#include <sys/types.h>
731#ifdef HAVE_SYS_SOCKET_H
732#include <sys/socket.h>
733#endif
734#ifdef HAVE_WS2TCPIP_H
735#include <ws2tcpip.h>
736#endif])
737
738dnl
739dnl Check for struct winsize
740dnl
741
742AC_KRB_STRUCT_WINSIZE
743
744dnl
745dnl Check for struct spwd
746dnl
747
748AC_KRB_STRUCT_SPWD
749
750#
751# Check if we want samba's socket wrapper
752#
753
754samba_SOCKET_WRAPPER
755
756dnl won't work with automake
757dnl moved to AC_OUTPUT in configure.in
758dnl AC_CONFIG_FILES($1/Makefile)
759
760LIB_roken="${LIB_roken} \$(LIB_crypt) \$(LIB_dbopen)"
761
762AC_SUBST(DIR_roken)dnl
763AC_SUBST(LIB_roken)dnl
764AC_SUBST(INCLUDES_roken)dnl
765])
766