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