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