r18087: use m4_include() do notice missing files
[bbaumbach/samba-autobuild/.git] / source4 / heimdal_build / config.m4
1 m4_define([upcase],`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`)dnl
2
3 dnl love_FIND_FUNC(func, includes, arguments)
4 dnl kind of like AC_CHECK_FUNC, but with headerfiles
5 AC_DEFUN([love_FIND_FUNC], [
6
7 AC_MSG_CHECKING([for $1])
8 AC_CACHE_VAL(ac_cv_love_func_$1,
9 [
10 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[$1($3)]])],
11 [eval "ac_cv_love_func_$1=yes"],[eval "ac_cv_love_func_$1=no"])])
12
13 eval "ac_res=\$ac_cv_love_func_$1"
14
15 if false; then
16         AC_CHECK_FUNCS($1)
17 fi
18 # $1
19 eval "ac_tr_func=HAVE_[]upcase($1)"
20
21 case "$ac_res" in
22         yes)
23         AC_DEFINE_UNQUOTED($ac_tr_func)
24         AC_MSG_RESULT([yes])
25         ;;
26         no)
27         AC_MSG_RESULT([no])
28         ;;
29 esac
30
31
32 ])
33
34
35
36 AC_CHECK_HEADERS([                              \
37         crypt.h                                 \
38         curses.h                                \
39         err.h                                   \
40         errno.h                                 \
41         inttypes.h                              \
42         netdb.h                                 \
43         signal.h                                \
44         sys/bswap.h                             \
45         sys/file.h                              \
46         sys/stropts.h                           \
47         sys/timeb.h                             \
48         sys/times.h                             \
49         sys/uio.h                               \
50         sys/un.h                                \
51         sys/utsname.h                           \
52         term.h                                  \
53         termcap.h                               \
54         time.h                                  \
55         timezone.h                              \
56         ttyname.h                               \
57         netinet/in.h                            \
58         netinet/in6.h                           \
59         netinet6/in6.h
60 ])
61
62 AC_CHECK_FUNCS([                                \
63         atexit                                  \
64         cgetent                                 \
65         getprogname                             \
66         inet_ntop                               \
67         inet_aton                               \
68         inet_pton                               \
69         gethostname                             \
70         getnameinfo                             \
71         iruserok                                \
72         putenv                                  \
73         rcmd                                    \
74         readv                                   \
75         sendmsg                                 \
76         setitimer                               \
77         socket                                  \
78         strlwr                                  \
79         strncasecmp                             \
80         strptime                                \
81         strsep                                  \
82         strsep_copy                             \
83         strtok_r                                \
84         strupr                                  \
85         swab                                    \
86         umask                                   \
87         uname                                   \
88         unsetenv                                \
89         closefrom                               \
90         hstrerror                               \
91         err                                     \
92         errx                                    \
93         warnx                                   \
94         flock                                   \
95         getaddrinfo                             \
96         freeaddrinfo                            \
97         getipnodebyname                         \
98         getipnodebyaddr                         \
99         freehostent                             \
100         writev
101 ])
102
103 love_FIND_FUNC(bswap16, [#ifdef HAVE_SYS_BSWAP_H
104 #include <sys/bswap.h>
105 #endif], 0)
106
107 love_FIND_FUNC(bswap32, [#ifdef HAVE_SYS_BSWAP_H
108 #include <sys/bswap.h>
109 #endif], 0)
110
111
112 dnl AC_HAVE_TYPE(TYPE,INCLUDES)
113 AC_DEFUN([AC_HAVE_TYPE], [
114 AC_REQUIRE([AC_HEADER_STDC])
115 cv=`echo "$1" | sed 'y%./+- %__p__%'`
116 AC_MSG_CHECKING(for $1)
117 AC_CACHE_VAL([ac_cv_type_$cv],
118 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
119 #include <sys/types.h>
120 #if STDC_HEADERS
121 #include <stdlib.h>
122 #include <stddef.h>
123 #endif
124 $2]],
125 [[$1 foo;]])],
126 [eval "ac_cv_type_$cv=yes"],
127 [eval "ac_cv_type_$cv=no"]))dnl
128 ac_foo=`eval echo \\$ac_cv_type_$cv`
129 AC_MSG_RESULT($ac_foo)
130 if test "$ac_foo" = yes; then
131   ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
132 if false; then
133         AC_CHECK_TYPES($1)
134 fi
135   AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
136 fi
137 ])
138
139 AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
140 AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
141 AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
142 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
143 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
144 AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
145
146
147 AC_DEFUN([AC_KRB_STRUCT_WINSIZE], [
148 AC_MSG_CHECKING(for struct winsize)
149 AC_CACHE_VAL(ac_cv_struct_winsize, [
150 ac_cv_struct_winsize=no
151 for i in sys/termios.h sys/ioctl.h; do
152 AC_EGREP_HEADER(
153 struct[[        ]]*winsize,dnl
154 $i, ac_cv_struct_winsize=yes; break)dnl
155 done
156 ])
157 if test "$ac_cv_struct_winsize" = "yes"; then
158   AC_DEFINE(HAVE_STRUCT_WINSIZE, 1, [define if struct winsize is declared in sys/termios.h])
159 fi
160 AC_MSG_RESULT($ac_cv_struct_winsize)
161 AC_EGREP_HEADER(ws_xpixel, termios.h, 
162         AC_DEFINE(HAVE_WS_XPIXEL, 1, [define if struct winsize has ws_xpixel]))
163 AC_EGREP_HEADER(ws_ypixel, termios.h, 
164         AC_DEFINE(HAVE_WS_YPIXEL, 1, [define if struct winsize has ws_ypixel]))
165 ])
166
167 AC_KRB_STRUCT_WINSIZE
168
169 AC_TYPE_SIGNAL
170 if test "$ac_cv_type_signal" = "void" ; then
171         AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
172 fi
173 AC_SUBST(VOID_RETSIGTYPE)
174
175
176 m4_include(heimdal/cf/check-var.m4)
177
178 rk_CHECK_VAR(h_errno, 
179 [#ifdef HAVE_SYS_TYPES_H
180 #include <sys/types.h>
181 #endif
182 #ifdef HAVE_NETDB_H
183 #include <netdb.h>
184 #endif])
185
186 m4_include(heimdal/cf/find-func.m4)
187 m4_include(heimdal/cf/find-func-no-libs.m4)
188 m4_include(heimdal/cf/find-func-no-libs2.m4)
189 m4_include(heimdal/cf/resolv.m4)
190
191 smb_save_LIBS=$LIBS
192 RESOLV_LIBS=""
193 LIBS=""
194
195 dnl  This fills in the global LIBS...
196 rk_RESOLV
197
198 dnl AC_CHECK_LIB_EXT(resolv, RESOLV_LIBS, res_search)
199         SMB_ENABLE(RESOLV,YES)
200
201 if test x"$LIBS" != "x"; then
202         RESOLV_LIBS=$LIBS
203 fi
204
205 LIBS=$smb_save_LIBS
206
207 SMB_EXT_LIB(RESOLV,[${RESOLV_LIBS}],[${RESOLV_CFLAGS}],[${RESOLV_CPPFLAGS}],[${RESOLV_LDFLAGS}])
208
209
210 # these are disabled unless heimdal is found below
211 SMB_ENABLE(KERBEROS_LIB, NO)
212 SMB_ENABLE(asn1_compile, NO)
213 SMB_ENABLE(compile_et, NO)
214
215 AC_PROG_LEX
216 AC_PROG_YACC
217
218 # Portions of heimdal kerberos are unpacked into source/heimdal
219 # of the samba source tree.  
220
221 # if we ever get to using a host kerberos, we might add conditionals here
222 AC_DEFINE(HAVE_KRB5,1,[Whether kerberos is available])
223 HAVE_KRB5=YES
224 SMB_ENABLE(KERBEROS_LIB, YES)
225 SMB_ENABLE(asn1_compile, YES)
226 SMB_ENABLE(compile_et, YES)
227
228 # only add getaddrinfo and related functions if needed
229 SMB_ENABLE(HEIMDAL_ROKEN_ADDRINFO, NO)
230 if test t$ac_cv_func_getaddrinfo != tyes; then
231         SMB_ENABLE(HEIMDAL_ROKEN_ADDRINFO, YES)
232 fi
233
234 # only add inet_aton if needed
235 SMB_ENABLE(HEIMDAL_ROKEN_INET_ATON, NO)
236 if test t$ac_cv_func_inet_aton != tyes; then
237         SMB_ENABLE(HEIMDAL_ROKEN_INET_ATON, YES)
238 fi
239
240 if test x"$ac_cv_func_inet_pton" = x"no"; then
241     AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, inet_pton)
242     AC_CHECK_LIB_EXT(nsl, NSL_LIBS, inet_pton)
243     SMB_ENABLE(NSL,YES)
244     if test x"$ac_cv_lib_ext_nsl_s_inet_pton" != x"yes" &&
245        test x"$ac_cv_lib_ext_nsl_inet_pton" != x"yes"; then
246         AC_MSG_ERROR([no inet_pton() function available!])
247     fi
248 fi
249
250 SMB_EXT_LIB(NSL,[${NSL_LIBS}],[],[],[])
251
252 # only add getprogname if needed
253 SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, NO)
254 SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, NO)
255 if test t$ac_cv_func_getprogname != tyes; then
256         SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, YES)
257         SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, YES)
258 fi
259
260 # only add gai_strerror if needed
261 SMB_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, NO)
262 AC_CHECK_FUNC(gai_strerror)
263
264 if test t$ac_cv_func_gai_strerror != tyes; then
265     AC_CHECK_LIB_EXT(nsl, GAI_LIBS, gai_strerror)
266     AC_CHECK_LIB_EXT(socket, GAI_LIBS, gai_strerror)
267     AC_CHECK_LIB_EXT(xnet, GAI_LIBS, gai_strerror)
268
269     dnl We can't just call AC_CHECK_FUNCS(gai_strerror) here, because the value
270     dnl has been cached.
271     if test x"$ac_cv_lib_ext_nsl_gai_strerror" = x"yes" ||
272        test x"$ac_cv_lib_ext_socket_gai_strerror" = x"yes" ||
273        test x"$ac_cv_lib_ext_xnet_gai_strerror" = x"yes"; then
274         AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror()])
275         SMB_ENABLE(GAI, YES)
276     else
277         SMB_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, YES)
278     fi
279
280 else
281     AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether gai_strerror() is available])
282 fi
283
284 SMB_EXT_LIB(GAI,[${GAI_LIBS}],[${GAI_CFLAGS}],[${GAI_CPPFLAGS}],[${GAI_LDFLAGS}])