Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
[kai/samba.git] / source4 / heimdal_build / internal.m4
1 m4_define([upcase],`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`)dnl
2
3 m4_ifndef([AC_WARNING_ENABLE],[AC_DEFUN([AC_WARNING_ENABLE],[])])
4
5 dnl love_FIND_FUNC(func, includes, arguments)
6 dnl kind of like AC_CHECK_FUNC, but with headerfiles
7 AC_DEFUN([love_FIND_FUNC], [
8
9 AC_MSG_CHECKING([for $1])
10 AC_CACHE_VAL(ac_cv_love_func_$1,
11 [
12 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]],[[$1($3)]])],
13 [eval "ac_cv_love_func_$1=yes"],[eval "ac_cv_love_func_$1=no"])])
14
15 eval "ac_res=\$ac_cv_love_func_$1"
16
17 if false; then
18         AC_CHECK_FUNCS($1)
19 fi
20 # $1
21 eval "ac_tr_func=HAVE_[]upcase($1)"
22
23 case "$ac_res" in
24         yes)
25         AC_DEFINE_UNQUOTED($ac_tr_func)
26         AC_MSG_RESULT([yes])
27         ;;
28         no)
29         AC_MSG_RESULT([no])
30         ;;
31 esac
32
33
34 ])
35
36 dnl Not all systems have err.h, so we provide a replacement. Heimdal
37 dnl unconditionally #includes <err.h>, so we need to create an err.h,
38 dnl but we can't just have a static one because we don't want to use
39 dnl it on systems that have a real err.h. If the system has a real
40 dnl err.h, we should use that (eg. on Darwin, the declarations get
41 dnl linker attributes added, so we can't guarantee that our local
42 dnl declarations will be correct). Phew!
43 AC_CHECK_HEADERS([err.h], [],
44         [ cp heimdal/lib/roken/err.hin heimdal_build/err.h ])
45
46 AC_CHECK_HEADERS([                              \
47         crypt.h                                 \
48         curses.h                                \
49         errno.h                                 \
50         inttypes.h                              \
51         netdb.h                                 \
52         signal.h                                \
53         sys/bswap.h                             \
54         sys/file.h                              \
55         sys/stropts.h                           \
56         sys/timeb.h                             \
57         sys/times.h                             \
58         sys/uio.h                               \
59         sys/un.h                                \
60         sys/utsname.h                           \
61         term.h                                  \
62         termcap.h                               \
63         time.h                                  \
64         timezone.h                              \
65         ttyname.h                               \
66         netinet/in.h                            \
67         netinet/in6.h                           \
68         netinet6/in6.h
69 ])
70
71 AC_CHECK_FUNCS([                                \
72         atexit                                  \
73         cgetent                                 \
74         getprogname                             \
75         inet_aton                               \
76         gethostname                             \
77         getnameinfo                             \
78         iruserok                                \
79         putenv                                  \
80         rcmd                                    \
81         readv                                   \
82         sendmsg                                 \
83         setitimer                               \
84         socket                                  \
85         strlwr                                  \
86         strncasecmp                             \
87         strptime                                \
88         strsep                                  \
89         strsep_copy                             \
90         strtok_r                                \
91         strupr                                  \
92         swab                                    \
93         umask                                   \
94         uname                                   \
95         unsetenv                                \
96         closefrom                               \
97         hstrerror                               \
98         err                                     \
99         warn                                    \
100         errx                                    \
101         warnx                                   \
102         flock                                   \
103         getipnodebyname                         \
104         getipnodebyaddr                         \
105         freehostent                             \
106         writev
107 ])
108
109 love_FIND_FUNC(bswap16, [#ifdef HAVE_SYS_BSWAP_H
110 #include <sys/bswap.h>
111 #endif], 0)
112
113 love_FIND_FUNC(bswap32, [#ifdef HAVE_SYS_BSWAP_H
114 #include <sys/bswap.h>
115 #endif], 0)
116
117 AC_DEFUN([AC_KRB_STRUCT_WINSIZE], [
118 AC_MSG_CHECKING(for struct winsize)
119 AC_CACHE_VAL(ac_cv_struct_winsize, [
120 ac_cv_struct_winsize=no
121 for i in sys/termios.h sys/ioctl.h; do
122 AC_EGREP_HEADER(
123 struct[[        ]]*winsize,dnl
124 $i, ac_cv_struct_winsize=yes; break)dnl
125 done
126 ])
127 if test "$ac_cv_struct_winsize" = "yes"; then
128   AC_DEFINE(HAVE_STRUCT_WINSIZE, 1, [define if struct winsize is declared in sys/termios.h])
129 fi
130 AC_MSG_RESULT($ac_cv_struct_winsize)
131 AC_EGREP_HEADER(ws_xpixel, termios.h, 
132         AC_DEFINE(HAVE_WS_XPIXEL, 1, [define if struct winsize has ws_xpixel]))
133 AC_EGREP_HEADER(ws_ypixel, termios.h, 
134         AC_DEFINE(HAVE_WS_YPIXEL, 1, [define if struct winsize has ws_ypixel]))
135 ])
136
137 AC_KRB_STRUCT_WINSIZE
138
139 AC_TYPE_SIGNAL
140 if test "$ac_cv_type_signal" = "void" ; then
141         AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
142 fi
143 AC_SUBST(VOID_RETSIGTYPE)
144
145
146 m4_include(heimdal/cf/check-var.m4)
147
148 rk_CHECK_VAR(h_errno, 
149 [#ifdef HAVE_SYS_TYPES_H
150 #include <sys/types.h>
151 #endif
152 #ifdef HAVE_NETDB_H
153 #include <netdb.h>
154 #endif])
155
156 m4_include(heimdal/cf/find-func.m4)
157 m4_include(heimdal/cf/find-func-no-libs.m4)
158 m4_include(heimdal/cf/find-func-no-libs2.m4)
159 m4_include(heimdal/cf/resolv.m4)
160
161 smb_save_LIBS=$LIBS
162 RESOLV_LIBS=""
163 LIBS=""
164
165 dnl  This fills in the global LIBS...
166 rk_RESOLV
167
168 dnl AC_CHECK_LIB_EXT(resolv, RESOLV_LIBS, res_search)
169         SMB_ENABLE(RESOLV,YES)
170
171 if test x"$LIBS" != "x"; then
172         RESOLV_LIBS=$LIBS
173 fi
174
175 LIBS=$smb_save_LIBS
176
177 SMB_EXT_LIB(RESOLV,[${RESOLV_LIBS}],[${RESOLV_CFLAGS}],[${RESOLV_CPPFLAGS}],[${RESOLV_LDFLAGS}])
178
179
180 # these are disabled unless heimdal is found below
181 SMB_ENABLE(KERBEROS_LIB, NO)
182 SMB_ENABLE(asn1_compile, NO)
183 SMB_ENABLE(compile_et, NO)
184
185 #
186 # We need bison -y and flex in new versions
187 # Otherwise we get random runtime failures
188 #
189 LEX_YACC_COMBINATIONS=""
190 LEX_YACC_COMBINATIONS="$LEX_YACC_COMBINATIONS flex-2.5.33:bison-2.3"
191 LEX_YACC_COMBINATIONS="$LEX_YACC_COMBINATIONS flex-2.5.34:bison-2.3"
192
193 AC_PROG_LEX
194 LEX_BASENAME=`basename "$LEX"`
195 if test x"$LEX_BASENAME" = x"flex"; then
196         # "flex 2.5.33"
197         FLEX_VERSION=`$LEX --version | cut -d ' ' -f2`
198         AC_MSG_CHECKING(flex version)
199         AC_MSG_RESULT($FLEX_VERSION)
200         FLEX_MAJOR=`echo $FLEX_VERSION | cut -d '.' -f1`
201         FLEX_MINOR=`echo $FLEX_VERSION | cut -d '.' -f2`
202         FLEX_RELEASE=`echo $FLEX_VERSION | cut -d '.' -f3`
203
204         LEX_VERSION="flex-$FLEX_MAJOR.$FLEX_MINOR.$FLEX_RELEASE"
205 fi
206
207 AC_PROG_YACC
208 YACC_BASENAME=`basename "$YACC"`
209 if test x"$YACC_BASENAME" = x"bison -y"; then
210         # bison (GNU Bison) 2.3
211         BISON_VERSION=`$YACC --version | head -1 | cut -d ' ' -f4`
212         AC_MSG_CHECKING(bison version)
213         AC_MSG_RESULT($BISON_VERSION)
214         BISON_MAJOR=`echo $BISON_VERSION | cut -d '.' -f1`
215         BISON_MINOR=`echo $BISON_VERSION | cut -d '.' -f2`
216
217         YACC_VERSION="bison-$BISON_MAJOR.$BISON_MINOR"
218 fi
219
220 AC_MSG_CHECKING(working LEX YACC combination)
221 LEX_YACC="no"
222 if test x"$LEX_VERSION" != x"" -a x"$YACC_VERSION" != x""; then
223         V="$LEX_VERSION:$YACC_VERSION"
224         for C in $LEX_YACC_COMBINATIONS; do
225                 if test x"$V" = x"$C"; then
226                         LEX_YACC=$V
227                         break;
228                 fi
229         done
230 fi
231 if test x"$LEX_YACC" = x"no"; then
232         LEX=false
233         YACC=false
234 fi
235 AC_MSG_RESULT($LEX_YACC)
236
237 # Portions of heimdal kerberos are unpacked into source/heimdal
238 # of the samba source tree.  
239
240 # if we ever get to using a host kerberos, we might add conditionals here
241 AC_DEFINE(HAVE_COM_ERR,1,[Whether com_err is available])
242 HAVE_COM_ERR=YES
243 AC_DEFINE(HAVE_KRB5,1,[Whether kerberos is available])
244 HAVE_KRB5=YES
245 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
246 HAVE_GSSAPI=YES
247 SMB_ENABLE(KERBEROS_LIB, YES)
248 SMB_ENABLE(asn1_compile, YES)
249 SMB_ENABLE(compile_et, YES)
250
251 # only add closefrom if needed
252 SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, NO)
253 if test t$ac_cv_func_closefrom != tyes; then
254         SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, YES)
255 fi
256
257 # only add getprogname if needed
258 SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, NO)
259 SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, NO)
260 if test t$ac_cv_func_getprogname != tyes; then
261         SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, YES)
262         SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, YES)
263 fi
264
265 VPATH="$VPATH:\$(HEIMDAL_VPATH)"
266
267 AC_DEFINE(SAMBA4_INTERNAL_HEIMDAL,1,[Whether we use in internal heimdal build])
268
269 SMB_INCLUDE_MK(heimdal_build/internal.mk)