r8832: Automatically rebuilding C files if headers change (in developer mode)
[sfrench/samba-autobuild/.git] / source / heimdal_build / config.m4
1
2 m4_define([upcase],`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`)dnl
3
4 dnl love_FIND_FUNC(func, includes, arguments)
5 dnl kind of like AC_CHECK_FUNC, but with headerfiles
6 AC_DEFUN([love_FIND_FUNC], [
7
8 AC_MSG_CHECKING([for $1])
9 AC_CACHE_VAL(ac_cv_love_func_$1,
10 [
11 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[$1($3)]])],
12 [eval "ac_cv_love_func_$1=yes"],[eval "ac_cv_love_func_$1=no"])])
13
14 eval "ac_res=\$ac_cv_love_func_$1"
15
16 if false; then
17         AC_CHECK_FUNCS($1)
18 fi
19 # $1
20 eval "ac_tr_func=HAVE_[]upcase($1)"
21
22 case "$ac_res" in
23         yes)
24         AC_DEFINE_UNQUOTED($ac_tr_func)
25         AC_MSG_RESULT([yes])
26         ;;
27         no)
28         AC_MSG_RESULT([no])
29         ;;
30 esac
31
32
33 ])
34
35
36
37 AC_CHECK_HEADERS([                              \
38         crypt.h                                 \
39         curses.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 ])
59
60 AC_CHECK_FUNCS([                                \
61         atexit                                  \
62         cgetent                                 \
63         inet_ntop                               \
64         inet_aton                               \
65         gethostname                             \
66         getnameinfo                             \
67         gai_strerror                            \
68         iruserok                                \
69         putenv                                  \
70         rcmd                                    \
71         readv                                   \
72         sendmsg                                 \
73         setitimer                               \
74         socket                                  \
75         strlwr                                  \
76         strncasecmp                             \
77         strptime                                \
78         strsep                                  \
79         strsep_copy                             \
80         strtok_r                                \
81         strupr                                  \
82         swab                                    \
83         umask                                   \
84         uname                                   \
85         unsetenv                                \
86         closefrom                               \
87         hstrerror                               \
88         err                                     \
89         errx                                    \
90         warnx                                   \
91         flock                                   \
92         getaddrinfo                             \
93         freeaddrinfo                            \
94         gai_strerror                            \
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 AC_CHECK_DECL(h_errno, 
171               [AC_DEFINE(HAVE_DECL_H_ERRNO,1,whether h_errno is declared)], [], [
172 #ifdef HAVE_SYS_TYPES_H
173 #include <sys/types.h>
174 #endif
175 #ifdef HAVE_NETDB_H
176 #include <netdb.h>
177 #endif])
178
179 # these are disabled unless heimdal is found below
180 SMB_SUBSYSTEM_ENABLE(KERBEROS_LIB, NO)
181 SMB_BINARY_ENABLE(asn1_compile, NO)
182 SMB_BINARY_ENABLE(compile_et, NO)
183
184 AC_PROG_LEX
185 AC_PROG_YACC
186
187 AC_CHECK_TYPES(u_int32_t)
188 AC_CHECK_TYPES(u_int16_t)
189 AC_CHECK_TYPES(u_int8_t)
190
191 # to enable kerberos, unpack a heimdal source tree in the heimdal directory
192 # of the samba source tree
193 if test -d heimdal; then
194         AC_DEFINE(HAVE_KRB5,1,[Whether kerberos is available])
195         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"
196         HAVE_KRB5=YES
197         SMB_SUBSYSTEM_ENABLE(KERBEROS_LIB, YES)
198         SMB_BINARY_ENABLE(asn1_compile, YES)
199         SMB_BINARY_ENABLE(compile_et, YES)
200 fi
201
202 # only add getaddrinfo and related functions if needed
203 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_ADDRINFO, NO)
204 if test t$ac_cv_func_getaddrinfo != tyes; then
205         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_ADDRINFO, YES)
206 fi