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