4e521e4cfdaa7b694420d01e2a66ec17b16726d3
[jra/samba/.git] / source4 / 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         writev
89 ])
90
91 love_FIND_FUNC(bswap16, [#ifdef HAVE_SYS_BSWAP_H
92 #include <sys/bswap.h>
93 #endif], 0)
94
95 love_FIND_FUNC(bswap32, [#ifdef HAVE_SYS_BSWAP_H
96 #include <sys/bswap.h>
97 #endif], 0)
98
99
100 dnl AC_HAVE_TYPE(TYPE,INCLUDES)
101 AC_DEFUN([AC_HAVE_TYPE], [
102 AC_REQUIRE([AC_HEADER_STDC])
103 cv=`echo "$1" | sed 'y%./+- %__p__%'`
104 AC_MSG_CHECKING(for $1)
105 AC_CACHE_VAL([ac_cv_type_$cv],
106 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
107 #include <sys/types.h>
108 #if STDC_HEADERS
109 #include <stdlib.h>
110 #include <stddef.h>
111 #endif
112 $2]],
113 [[$1 foo;]])],
114 [eval "ac_cv_type_$cv=yes"],
115 [eval "ac_cv_type_$cv=no"]))dnl
116 ac_foo=`eval echo \\$ac_cv_type_$cv`
117 AC_MSG_RESULT($ac_foo)
118 if test "$ac_foo" = yes; then
119   ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
120 if false; then
121         AC_CHECK_TYPES($1)
122 fi
123   AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
124 fi
125 ])
126
127 AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
128 AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
129 AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
130 AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
131 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
132 AC_HAVE_TYPE([struct ifaddrs], [#include <ifaddrs.h>])
133
134
135 AC_DEFUN([AC_KRB_STRUCT_WINSIZE], [
136 AC_MSG_CHECKING(for struct winsize)
137 AC_CACHE_VAL(ac_cv_struct_winsize, [
138 ac_cv_struct_winsize=no
139 for i in sys/termios.h sys/ioctl.h; do
140 AC_EGREP_HEADER(
141 struct[[        ]]*winsize,dnl
142 $i, ac_cv_struct_winsize=yes; break)dnl
143 done
144 ])
145 if test "$ac_cv_struct_winsize" = "yes"; then
146   AC_DEFINE(HAVE_STRUCT_WINSIZE, 1, [define if struct winsize is declared in sys/termios.h])
147 fi
148 AC_MSG_RESULT($ac_cv_struct_winsize)
149 AC_EGREP_HEADER(ws_xpixel, termios.h, 
150         AC_DEFINE(HAVE_WS_XPIXEL, 1, [define if struct winsize has ws_xpixel]))
151 AC_EGREP_HEADER(ws_ypixel, termios.h, 
152         AC_DEFINE(HAVE_WS_YPIXEL, 1, [define if struct winsize has ws_ypixel]))
153 ])
154
155 AC_KRB_STRUCT_WINSIZE
156
157
158 AC_CHECK_DECL(h_errno, 
159               [AC_DEFINE(HAVE_DECL_H_ERRNO,1,whether h_errno is declared)], [], [
160 #ifdef HAVE_SYS_TYPES_H
161 #include <sys/types.h>
162 #endif
163 #ifdef HAVE_NETDB_H
164 #include <netdb.h>
165 #endif])
166
167 # these are disabled unless heimdal is found below
168 SMB_MODULE_DEFAULT(KERBEROS_LIB, NOT)
169 SMB_BINARY_ENABLE(asn1_compile, NO)
170 SMB_BINARY_ENABLE(compile_et, NO)
171
172 # to enable kerberos, unpack a heimdal source tree in the heimdal directory
173 # of the samba source tree
174 if test -d heimdal; then
175         AC_DEFINE(HAVE_KRB5,1,[Whether kerberos is available])
176         CFLAGS="${CFLAGS} -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/gssapi -Iheimdal/lib/asn1 -Iheimdal/lib/com_err -Iheimdal/lib/hdb -Iheimdal/kdc"
177         HAVE_KRB5=YES
178         SMB_MODULE_DEFAULT(KERBEROS_LIB, STATIC)
179         SMB_BINARY_ENABLE(asn1_compile, YES)
180         SMB_BINARY_ENABLE(compile_et, YES)
181 fi