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