r10097: Remove extraneous include patch heimdal/include. Add configure
[sfrench/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         errno.h                                 \
40         inttypes.h                              \
41         netdb.h                                 \
42         signal.h                                \
43         sys/bitypes.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 ])
58
59 AC_CHECK_FUNCS([                                \
60         atexit                                  \
61         cgetent                                 \
62         inet_ntop                               \
63         inet_aton                               \
64         gethostname                             \
65         getnameinfo                             \
66         iruserok                                \
67         putenv                                  \
68         rcmd                                    \
69         readv                                   \
70         sendmsg                                 \
71         setitimer                               \
72         socket                                  \
73         strlwr                                  \
74         strncasecmp                             \
75         strptime                                \
76         strsep                                  \
77         strsep_copy                             \
78         strtok_r                                \
79         strupr                                  \
80         swab                                    \
81         umask                                   \
82         uname                                   \
83         unsetenv                                \
84         closefrom                               \
85         hstrerror                               \
86         err                                     \
87         errx                                    \
88         warnx                                   \
89         flock                                   \
90         getaddrinfo                             \
91         freeaddrinfo                            \
92         getipnodebyname                         \
93         getipnodebyaddr                         \
94         freehostent                             \
95         writev
96 ])
97
98 love_FIND_FUNC(bswap16, [#ifdef HAVE_SYS_BSWAP_H
99 #include <sys/bswap.h>
100 #endif], 0)
101
102 love_FIND_FUNC(bswap32, [#ifdef HAVE_SYS_BSWAP_H
103 #include <sys/bswap.h>
104 #endif], 0)
105
106
107 dnl AC_HAVE_TYPE(TYPE,INCLUDES)
108 AC_DEFUN([AC_HAVE_TYPE], [
109 AC_REQUIRE([AC_HEADER_STDC])
110 cv=`echo "$1" | sed 'y%./+- %__p__%'`
111 AC_MSG_CHECKING(for $1)
112 AC_CACHE_VAL([ac_cv_type_$cv],
113 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
114 #include <sys/types.h>
115 #if STDC_HEADERS
116 #include <stdlib.h>
117 #include <stddef.h>
118 #endif
119 $2]],
120 [[$1 foo;]])],
121 [eval "ac_cv_type_$cv=yes"],
122 [eval "ac_cv_type_$cv=no"]))dnl
123 ac_foo=`eval echo \\$ac_cv_type_$cv`
124 AC_MSG_RESULT($ac_foo)
125 if test "$ac_foo" = yes; then
126   ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
127 if false; then
128         AC_CHECK_TYPES($1)
129 fi
130   AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
131 fi
132 ])
133
134 AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
135 AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
136 AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
137 AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
138 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
139 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
140
141
142 AC_DEFUN([AC_KRB_STRUCT_WINSIZE], [
143 AC_MSG_CHECKING(for struct winsize)
144 AC_CACHE_VAL(ac_cv_struct_winsize, [
145 ac_cv_struct_winsize=no
146 for i in sys/termios.h sys/ioctl.h; do
147 AC_EGREP_HEADER(
148 struct[[        ]]*winsize,dnl
149 $i, ac_cv_struct_winsize=yes; break)dnl
150 done
151 ])
152 if test "$ac_cv_struct_winsize" = "yes"; then
153   AC_DEFINE(HAVE_STRUCT_WINSIZE, 1, [define if struct winsize is declared in sys/termios.h])
154 fi
155 AC_MSG_RESULT($ac_cv_struct_winsize)
156 AC_EGREP_HEADER(ws_xpixel, termios.h, 
157         AC_DEFINE(HAVE_WS_XPIXEL, 1, [define if struct winsize has ws_xpixel]))
158 AC_EGREP_HEADER(ws_ypixel, termios.h, 
159         AC_DEFINE(HAVE_WS_YPIXEL, 1, [define if struct winsize has ws_ypixel]))
160 ])
161
162 AC_KRB_STRUCT_WINSIZE
163
164 AC_TYPE_SIGNAL
165 if test "$ac_cv_type_signal" = "void" ; then
166         AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
167 fi
168 AC_SUBST(VOID_RETSIGTYPE)
169
170
171 sinclude(heimdal/cf/check-var.m4)
172
173 rk_CHECK_VAR(h_errno, 
174 [#ifdef HAVE_SYS_TYPES_H
175 #include <sys/types.h>
176 #endif
177 #ifdef HAVE_NETDB_H
178 #include <netdb.h>
179 #endif])
180
181 sinclude(heimdal/cf/find-func.m4)
182 sinclude(heimdal/cf/find-func-no-libs.m4)
183 sinclude(heimdal/cf/find-func-no-libs2.m4)
184 sinclude(heimdal/cf/resolv.m4)
185
186 smb_save_LIBS=$LIBS
187 RESOLV_LIBS=""
188 LIBS=""
189
190 dnl  This fills in the global LIBS...
191 rk_RESOLV
192
193 dnl AC_CHECK_LIB_EXT(resolv, RESOLV_LIBS, res_search)
194         SMB_EXT_LIB_ENABLE(RESOLV,YES)
195
196 if test x"$LIBS" != "x"; then
197         RESOLV_LIBS=$LIBS
198 fi
199
200 LIBS=$smb_save_LIBS
201
202 SMB_EXT_LIB(RESOLV,[${RESOLV_LIBS}],[${RESOLV_CFLAGS}],[${RESOLV_CPPFLAGS}],[${RESOLV_LDFLAGS}])
203
204
205 # these are disabled unless heimdal is found below
206 SMB_SUBSYSTEM_ENABLE(KERBEROS_LIB, NO)
207 SMB_BINARY_ENABLE(asn1_compile, NO)
208 SMB_BINARY_ENABLE(compile_et, NO)
209
210 AC_PROG_LEX
211 AC_PROG_YACC
212
213 AC_CHECK_TYPES(u_int32_t)
214 AC_CHECK_TYPES(u_int16_t)
215 AC_CHECK_TYPES(u_int8_t)
216
217 # to enable kerberos, unpack a heimdal source tree in the heimdal directory
218 # of the samba source tree
219 if test -d heimdal; then
220         AC_DEFINE(HAVE_KRB5,1,[Whether kerberos is available])
221         CFLAGS="${CFLAGS} -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/gssapi -Iheimdal/lib/asn1 -Iheimdal/lib/com_err -Iheimdal/lib/hdb -Iheimdal/kdc -Iheimdal/lib/roken -Iheimdal/lib/des"
222         HAVE_KRB5=YES
223         SMB_SUBSYSTEM_ENABLE(KERBEROS_LIB, YES)
224         SMB_BINARY_ENABLE(asn1_compile, YES)
225         SMB_BINARY_ENABLE(compile_et, YES)
226 fi
227
228 # only add getaddrinfo and related functions if needed
229 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_ADDRINFO, NO)
230 if test t$ac_cv_func_getaddrinfo != tyes; then
231         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_ADDRINFO, YES)
232 fi
233
234 # only add inet_aton if needed
235 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_INET_ATON, NO)
236 if test t$ac_cv_func_inet_aton != tyes; then
237         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_INET_ATON, YES)
238 fi
239
240 # only add gai_strerror if needed
241 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, NO)
242 AC_CHECK_FUNC(gai_strerror)
243 if test t$ac_cv_func_gai_strerror != tyes; then
244     AC_SEARCH_LIBS_EXT(gai_strerror, [xnet], XNET_LIBS)
245     AC_CHECK_FUNC_EXT(gai_strerror, $XNET_LIBS)
246     if test t$ac_cv_func_ext_gai_strerror != tyes; then
247         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, YES)
248     else
249         AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether gai_strerror() is available])
250     fi
251 else
252     AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether gai_strerror() is available])
253 fi
254 SMB_EXT_LIB(XNET,[${XNET_LIBS}],[${XNET_CFLAGS}],[${XNET_CPPFLAGS}],[${XNET_LDFLAGS}])