r9136: made the 'AJAJ' code portable to IE and Opera
[samba.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         iruserok                                \
68         putenv                                  \
69         rcmd                                    \
70         readv                                   \
71         sendmsg                                 \
72         setitimer                               \
73         socket                                  \
74         strlwr                                  \
75         strncasecmp                             \
76         strptime                                \
77         strsep                                  \
78         strsep_copy                             \
79         strtok_r                                \
80         strupr                                  \
81         swab                                    \
82         umask                                   \
83         uname                                   \
84         unsetenv                                \
85         closefrom                               \
86         hstrerror                               \
87         err                                     \
88         errx                                    \
89         warnx                                   \
90         flock                                   \
91         getaddrinfo                             \
92         freeaddrinfo                            \
93         writev
94 ])
95
96 love_FIND_FUNC(bswap16, [#ifdef HAVE_SYS_BSWAP_H
97 #include <sys/bswap.h>
98 #endif], 0)
99
100 love_FIND_FUNC(bswap32, [#ifdef HAVE_SYS_BSWAP_H
101 #include <sys/bswap.h>
102 #endif], 0)
103
104
105 dnl AC_HAVE_TYPE(TYPE,INCLUDES)
106 AC_DEFUN([AC_HAVE_TYPE], [
107 AC_REQUIRE([AC_HEADER_STDC])
108 cv=`echo "$1" | sed 'y%./+- %__p__%'`
109 AC_MSG_CHECKING(for $1)
110 AC_CACHE_VAL([ac_cv_type_$cv],
111 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
112 #include <sys/types.h>
113 #if STDC_HEADERS
114 #include <stdlib.h>
115 #include <stddef.h>
116 #endif
117 $2]],
118 [[$1 foo;]])],
119 [eval "ac_cv_type_$cv=yes"],
120 [eval "ac_cv_type_$cv=no"]))dnl
121 ac_foo=`eval echo \\$ac_cv_type_$cv`
122 AC_MSG_RESULT($ac_foo)
123 if test "$ac_foo" = yes; then
124   ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
125 if false; then
126         AC_CHECK_TYPES($1)
127 fi
128   AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
129 fi
130 ])
131
132 AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
133 AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
134 AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
135 AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
136 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
137 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
138
139
140 AC_DEFUN([AC_KRB_STRUCT_WINSIZE], [
141 AC_MSG_CHECKING(for struct winsize)
142 AC_CACHE_VAL(ac_cv_struct_winsize, [
143 ac_cv_struct_winsize=no
144 for i in sys/termios.h sys/ioctl.h; do
145 AC_EGREP_HEADER(
146 struct[[        ]]*winsize,dnl
147 $i, ac_cv_struct_winsize=yes; break)dnl
148 done
149 ])
150 if test "$ac_cv_struct_winsize" = "yes"; then
151   AC_DEFINE(HAVE_STRUCT_WINSIZE, 1, [define if struct winsize is declared in sys/termios.h])
152 fi
153 AC_MSG_RESULT($ac_cv_struct_winsize)
154 AC_EGREP_HEADER(ws_xpixel, termios.h, 
155         AC_DEFINE(HAVE_WS_XPIXEL, 1, [define if struct winsize has ws_xpixel]))
156 AC_EGREP_HEADER(ws_ypixel, termios.h, 
157         AC_DEFINE(HAVE_WS_YPIXEL, 1, [define if struct winsize has ws_ypixel]))
158 ])
159
160 AC_KRB_STRUCT_WINSIZE
161
162 AC_TYPE_SIGNAL
163 if test "$ac_cv_type_signal" = "void" ; then
164         AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
165 fi
166 AC_SUBST(VOID_RETSIGTYPE)
167
168 AC_CHECK_DECL(h_errno, 
169               [AC_DEFINE(HAVE_DECL_H_ERRNO,1,whether h_errno is declared)], [], [
170 #ifdef HAVE_SYS_TYPES_H
171 #include <sys/types.h>
172 #endif
173 #ifdef HAVE_NETDB_H
174 #include <netdb.h>
175 #endif])
176
177 # these are disabled unless heimdal is found below
178 SMB_SUBSYSTEM_ENABLE(KERBEROS_LIB, NO)
179 SMB_BINARY_ENABLE(asn1_compile, NO)
180 SMB_BINARY_ENABLE(compile_et, NO)
181
182 AC_PROG_LEX
183 AC_PROG_YACC
184
185 AC_CHECK_TYPES(u_int32_t)
186 AC_CHECK_TYPES(u_int16_t)
187 AC_CHECK_TYPES(u_int8_t)
188
189 # to enable kerberos, unpack a heimdal source tree in the heimdal directory
190 # of the samba source tree
191 if test -d heimdal; then
192         AC_DEFINE(HAVE_KRB5,1,[Whether kerberos is available])
193         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"
194         HAVE_KRB5=YES
195         SMB_SUBSYSTEM_ENABLE(KERBEROS_LIB, YES)
196         SMB_BINARY_ENABLE(asn1_compile, YES)
197         SMB_BINARY_ENABLE(compile_et, YES)
198 fi
199
200 # only add getaddrinfo and related functions if needed
201 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_ADDRINFO, NO)
202 if test t$ac_cv_func_getaddrinfo != tyes; then
203         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_ADDRINFO, YES)
204 fi
205
206 # only add inet_aton if needed
207 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_INET_ATON, NO)
208 if test t$ac_cv_func_inet_aton != tyes; then
209         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_INET_ATON, YES)
210 fi
211
212 # only add gai_strerror if needed
213 SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, NO)
214 AC_CHECK_FUNC(gai_strerror)
215 if test t$ac_cv_func_gai_strerror != tyes; then
216     AC_SEARCH_LIBS_EXT(gai_strerror, [xnet], XNET_LIBS)
217     AC_CHECK_FUNC_EXT(gai_strerror, $XNET_LIBS)
218     if test t$ac_cv_func_ext_gai_strerror != tyes; then
219         SMB_SUBSYSTEM_ENABLE(HEIMDAL_ROKEN_GAI_STRERROR, YES)
220     else
221         AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether gai_strerror() is available])
222     fi
223 else
224     AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether gai_strerror() is available])
225 fi
226 SMB_EXT_LIB(XNET,[${XNET_LIBS}],[${XNET_CFLAGS}],[${XNET_CPPFLAGS}],[${XNET_LDFLAGS}])