Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / cf / roken.m4
1
2 AC_DEFUN([_OPENAFS_ROKEN_INTERNAL], [
3 DIR_roken=roken
4 CPPFLAGS_roken=
5 LDFLAGS_roken="-L\$(TOP_LIBDIR)"
6 LIB_roken=-lrokenafs
7 buildtool_roken="\$(TOP_OBJDIR)/src/roken/librokenafs.a"
8 ])
9
10 dnl _OPENAFS_ROKEN_PATHS()
11 dnl Set CPPFLAGS_roken, LDFLAGS_roken, and LIB_roken based on the values
12 dnl of roken_root, roken_libdir, and roken_includedir.
13 AC_DEFUN([_OPENAFS_ROKEN_PATHS], [
14 AS_IF([test x"$roken_libdir" != x],
15 [LDFLAGS_roken="-L$roken_libdir"],
16 [AS_IF([test x"$roken_root" != x],
17 [LDFLAGS_roken="-L$roken_root/lib"])])
18 AS_IF([test x"$roken_includedir" != x],
19 [CPPFLAGS_roken="-I$roken_includedir"],
20 [AS_IF([test x"$roken_root" != x],
21 [CPPFLAGS_roken="-I$roken_root/include"])])
22 LIB_roken="-lroken"
23 buildtool_roken="\$(LDFLAGS_roken) \$(LIB_roken)"])
24
25 dnl _OPENAFS_ROKEN_CHECK($action-if-found,
26 dnl $action-if-not-found)
27 dnl Find a roken library using $roken_root, $roken_libdir, and $roken_includedir
28 dnl
29 dnl If none of the three paths are specified,
30 dnl try to find one in the standard locations on the system.
31 dnl
32 dnl If we fail, and at least one path was given, then error out. Otherwise,
33 dnl fall back to the internal roken implementation.
34 AC_DEFUN([_OPENAFS_ROKEN_CHECK], [
35
36 _OPENAFS_ROKEN_PATHS
37 save_CPPFLAGS=$CPPFLAGS
38 save_LDFLAGS=$LDFLAGS
39 save_LIBS=$LIBS
40 AS_IF([test x"$CPPFLAGS_roken" != x],
41 [CPPFLAGS="$CPPFLAGS_roken $CPPFLAGS"])
42 AS_IF([test x"$LDFLAGS_roken" != x],
43 [LDFLAGS="$LDFLAGS_roken $LDFLAGS"])
44 AS_IF([test x"$roken_libdir" != x || test x"$roken_includedir" != x],
45 [checkstr=" with specified include and lib paths"],
46 [AS_IF([test x"$roken_root" != x],
47 [checkstr=" in $roken_root"])])
48
49 AC_MSG_CHECKING([for usable system libroken$checkstr])
50
51 LIBS="$LIBS $LIB_roken"
52 dnl Need to be careful what we check for here, as libroken contains
53 dnl different symbols on different platforms. We cannot simply check
54 dnl if e.g. rk_rename is a symbol or not, since on most platforms it
55 dnl will be a preprocessor define, but on others it will be a symbol.
56 dnl
57 dnl Also note that we need to check for the specific functionality in
58 dnl roken that we use, not just the existence of the library itself,
59 dnl since older versions of roken do not contain all of the functions
60 dnl we need. It may not be practical to check everything we use, so
61 dnl just add functions to check here as we find installations where
62 dnl this breaks.
63 AC_LINK_IFELSE(
64 [AC_LANG_PROGRAM(
65 [[#include <roken.h>]],
66 [[ct_memcmp(NULL, NULL, 0); rk_rename(NULL, NULL);]])],
67 [roken_found=true
68 AC_MSG_RESULT([yes])],
69 [AC_MSG_RESULT([no])])
70
71 CPPFLAGS=$save_CPPFLAGS
72 LDFLAGS=$save_LDFLAGS
73 LIBS=$save_LIBS
74
75 AS_IF([test x"$roken_found" = xtrue],
76 [$1], [$2])
77 ])
78
79 AC_DEFUN([OPENAFS_ROKEN], [
80 roken_root=
81 AC_SUBST(LIB_roken)
82 AC_SUBST(CPPFLAGS_roken)
83 AC_SUBST(LDFLAGS_roken)
84 AC_SUBST(DIR_roken)
85 AC_SUBST(buildtool_roken)
86
87 AC_ARG_WITH([roken],
88 [AS_HELP_STRING([--with-roken=DIR],
89 [Location of the roken library, or 'internal'])],
90 [AS_IF([test x"$withval" = xno],
91 [AC_MSG_ERROR("OpenAFS requires roken to build")],
92 [AS_IF([test x"$withval" != xyes],
93 [roken_root="$withval"])
94 ])
95 ])
96 AC_ARG_WITH([roken-include],
97 [AS_HELP_STRING([--with-roken-include=DIR],
98 [Location of roken headers])],
99 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
100 [roken_includedir="$withval"])])
101 AC_ARG_WITH([roken-lib],
102 [AS_HELP_STRING([--with-roken-lib=DIR],
103 [Location of roken libraries])],
104 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
105 [roken_libdir="$withval"])])
106
107 AS_IF([test x"$roken_root" = xinternal],
108 [_OPENAFS_ROKEN_INTERNAL()],
109 [AS_IF([test x"$roken_root" = x && test x"$roken_libdir" = x &&
110 test x"$roken_includedir" = x],
111 [_OPENAFS_ROKEN_CHECK([], [_OPENAFS_ROKEN_INTERNAL()])],
112 [_OPENAFS_ROKEN_CHECK([],
113 [AC_MSG_ERROR([Cannot find roken at that location])])
114 ])
115 ])
116 ])
117
118 AC_DEFUN([OPENAFS_MORE_ROKEN_CHECKS],[
119 dnl Functions that Heimdal's libroken provides, but that we
120 dnl haven't found a need for yet, and so haven't imported
121 AC_CHECK_FUNCS([ \
122 chown \
123 fchown \
124 gethostname \
125 lstat \
126 inet_aton \
127 putenv \
128 readv \
129 setenv \
130 strdup \
131 strftime \
132 strndup \
133 strsep \
134 unsetenv \
135 ])
136
137 dnl Functions that are in objects that we always build from libroken
138 AC_CHECK_FUNCS([ \
139 asprintf \
140 asnprintf \
141 vasprintf \
142 vasnprintf \
143 vsnprintf \
144 snprintf \
145 ])
146
147 dnl Functions that we're going to try and get from libroken
148 AC_REPLACE_FUNCS([ \
149 daemon \
150 ecalloc \
151 emalloc \
152 erealloc \
153 err \
154 errx \
155 flock \
156 freeaddrinfo \
157 gai_strerror \
158 getaddrinfo \
159 getdtablesize \
160 getnameinfo \
161 getopt \
162 getprogname \
163 gettimeofday \
164 inet_ntop \
165 inet_pton \
166 localtime_r \
167 mkstemp \
168 setenv \
169 setprogname \
170 strcasecmp \
171 strlcat \
172 strnlen \
173 strlcpy \
174 strsep \
175 tdelete \
176 tfind \
177 tsearch \
178 twalk \
179 unsetenv \
180 verr \
181 verrx \
182 vsyslog \
183 vwarn \
184 vwarnx \
185 warn \
186 warnx \
187 ])
188
189 dnl Headers that we're going to try and get from libroken
190 AC_CHECK_HEADERS([ \
191 err.h \
192 search.h \
193 ])
194 ])
195
196 AC_DEFUN([OPENAFS_ROKEN_HEADERS],[
197 ROKEN_HEADERS=
198 AS_IF([test "$ac_cv_header_err_h" != "yes" ],
199 [ROKEN_HEADERS="$ROKEN_HEADERS \$(TOP_INCDIR)/err.h"],
200 [])
201 AC_SUBST(ROKEN_HEADERS)
202 ])