Merge commit 'release-4-0-0alpha1' into v4-0-test
[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 dnl Not all systems have err.h, so we provide a replacement. Heimdal
35 dnl unconditionally #includes <err.h>, so we need to create an err.h,
36 dnl but we can't just have a static one because we don't want to use
37 dnl it on systems that have a real err.h. If the system has a real
38 dnl err.h, we should use that (eg. on Darwin, the declarations get
39 dnl linker attributes added, so we can't guarantee that our local
40 dnl declarations will be correct). Phew!
41 AC_CHECK_HEADERS([err.h], [],
42         [ cp heimdal/lib/roken/err.hin heimdal_build/err.h ])
43
44 AC_CHECK_HEADERS([                              \
45         crypt.h                                 \
46         curses.h                                \
47         errno.h                                 \
48         inttypes.h                              \
49         netdb.h                                 \
50         signal.h                                \
51         sys/bswap.h                             \
52         sys/file.h                              \
53         sys/stropts.h                           \
54         sys/timeb.h                             \
55         sys/times.h                             \
56         sys/uio.h                               \
57         sys/un.h                                \
58         sys/utsname.h                           \
59         term.h                                  \
60         termcap.h                               \
61         time.h                                  \
62         timezone.h                              \
63         ttyname.h                               \
64         netinet/in.h                            \
65         netinet/in6.h                           \
66         netinet6/in6.h
67 ])
68
69 AC_CHECK_FUNCS([                                \
70         atexit                                  \
71         cgetent                                 \
72         getprogname                             \
73         inet_aton                               \
74         gethostname                             \
75         getnameinfo                             \
76         iruserok                                \
77         putenv                                  \
78         rcmd                                    \
79         readv                                   \
80         sendmsg                                 \
81         setitimer                               \
82         socket                                  \
83         strlwr                                  \
84         strncasecmp                             \
85         strptime                                \
86         strsep                                  \
87         strsep_copy                             \
88         strtok_r                                \
89         strupr                                  \
90         swab                                    \
91         umask                                   \
92         uname                                   \
93         unsetenv                                \
94         closefrom                               \
95         hstrerror                               \
96         err                                     \
97         warn                                    \
98         errx                                    \
99         warnx                                   \
100         flock                                   \
101         getipnodebyname                         \
102         getipnodebyaddr                         \
103         freehostent                             \
104         writev
105 ])
106
107 love_FIND_FUNC(bswap16, [#ifdef HAVE_SYS_BSWAP_H
108 #include <sys/bswap.h>
109 #endif], 0)
110
111 love_FIND_FUNC(bswap32, [#ifdef HAVE_SYS_BSWAP_H
112 #include <sys/bswap.h>
113 #endif], 0)
114
115
116 dnl AC_HAVE_TYPE(TYPE,INCLUDES)
117 AC_DEFUN([AC_HAVE_TYPE], [
118 AC_REQUIRE([AC_HEADER_STDC])
119 cv=`echo "$1" | sed 'y%./+- %__p__%'`
120 AC_MSG_CHECKING(for $1)
121 AC_CACHE_VAL([ac_cv_type_$cv],
122 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
123 AC_INCLUDES_DEFAULT
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 closefrom if needed
229 SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, NO)
230 if test t$ac_cv_func_closefrom != tyes; then
231         SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, YES)
232 fi
233
234 # only add getprogname if needed
235 SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, NO)
236 SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, NO)
237 if test t$ac_cv_func_getprogname != tyes; then
238         SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, YES)
239         SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, YES)
240 fi