root/configure.in

Revision 53d7d94e52f3e2ce0bfcc10448b4fffb5961aca8, 6.6 kB (checked in by Theo Schlossnagle <theo.schlossnagle@circonus.com>, 7 months ago)

make the checks -Werror safe

  • Property mode set to 100755
Line 
1 dnl vim:ts=2:sw=2:et:
2 AC_INIT(jlog.c)
3 AC_CONFIG_HEADER(jlog_config.h)
4
5 AC_SUBST(CPPFLAGS, "$CPPFLAGS -I/usr/java/include -I/usr/java/include/solaris")
6
7 AC_PROG_CC
8 AC_C_INLINE
9 AC_CANONICAL_HOST
10 AC_C_BIGENDIAN
11 AC_PROG_CPP
12 AC_PROG_RANLIB
13 AC_PROG_INSTALL
14 AC_PROG_LN_S
15 AC_PATH_PROG(AR, ar)
16 AC_PATH_PROGS(PERL, perl)
17 AC_PATH_PROGS(JAVAC, javac)
18 AC_PATH_PROGS(JAR, jar)
19 AC_PATH_PROGS(JAVAH, javah)
20 AC_SUBST(PERL)
21
22 # Checks for data types
23 AC_CHECK_SIZEOF(char, 1)
24 AC_CHECK_SIZEOF(short int, 2)
25 AC_CHECK_SIZEOF(int, 4)
26 AC_CHECK_SIZEOF(long int, 4)
27 AC_CHECK_SIZEOF(long long int, 8)
28 AC_CHECK_SIZEOF(void *, 1)
29
30 AC_CHECK_LIB(rt, sem_init, , )
31 AC_CHECK_LIB(posix4, sem_wait, , )
32
33 AC_MSG_CHECKING([whether sem_init works])
34 AC_TRY_RUN(
35         [
36 #include <semaphore.h>
37 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
38         ],
39         [AC_MSG_RESULT(yes)],
40         [
41                 AC_MSG_RESULT(no)
42                 AC_DEFINE(BROKEN_SEM_INIT)
43                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
44         ]
45 )
46
47 AC_CHECK_LIB(lz4, LZ4_compress_default, , )
48 AC_FUNC_STRFTIME
49 AC_CHECK_FUNC(pwritev, [AC_DEFINE(HAVE_PWRITEV)], )
50
51 # Checks for header files.
52 AC_CHECK_HEADERS(sys/file.h sys/types.h sys/uio.h dirent.h sys/param.h libgen.h \
53    stdint.h fcntl.h errno.h limits.h jni.h \
54    sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
55    ctype.h unistd.h time.h sys/stat.h sys/time.h unistd.h sys/mman.h lz4.h)
56
57 JAVA_BITS=java-bits
58 if test "x$ac_cv_header_jni_h" != "xyes" ; then
59         JAVA_BITS=
60         AC_MSG_WARN([Not building java bits due to jni.h absence (set CPPFLAGS?)])
61 fi
62 AC_SUBST(JAVA_BITS)
63
64 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
65         AC_TRY_COMPILE(
66                 [ #include <sys/types.h> ],
67                 [ u_int a; a = 1; (void)a; ],
68                 [ ac_cv_have_u_int="yes" ],
69                 [ ac_cv_have_u_int="no" ]
70         )
71 ])
72
73 if test "x$GCC" = "xyes" ; then
74     CFLAGS="$CFLAGS -Wall -Wno-int-to-pointer-cast -Werror"
75 fi
76
77 if test "x$ac_cv_have_u_int" = "xyes" ; then
78         AC_DEFINE(HAVE_U_INT)
79         have_u_int=1
80 fi
81
82 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
83         AC_TRY_COMPILE(
84                 [ #include <sys/types.h> ],
85                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1; (void)a; (void)b; (void)c; ],
86                 [ ac_cv_have_intxx_t="yes" ],
87                 [ ac_cv_have_intxx_t="no" ]
88         )
89 ])
90 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
91         AC_DEFINE(HAVE_INTXX_T)
92         have_intxx_t=1
93 fi
94        
95 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
96         AC_TRY_COMPILE(
97                 [ #include <sys/types.h> ],
98                 [ int64_t a; a = 1; (void)a; ],
99                 [ ac_cv_have_int64_t="yes" ],
100                 [ ac_cv_have_int64_t="no" ]
101         )
102 ])
103 if test "x$ac_cv_have_int64_t" = "xyes" ; then
104         AC_DEFINE(HAVE_INT64_T)
105         have_int64_t=1
106 fi
107        
108 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
109         AC_TRY_COMPILE(
110                 [ #include <sys/types.h> ],
111                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1; (void)a; (void)b; (void)c; ],
112                 [ ac_cv_have_u_intxx_t="yes" ],
113                 [ ac_cv_have_u_intxx_t="no" ]
114         )
115 ])
116 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
117         AC_DEFINE(HAVE_U_INTXX_T)
118         have_u_intxx_t=1
119 fi
120
121 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
122         AC_TRY_COMPILE(
123                 [ #include <sys/types.h> ],
124                 [ u_int64_t a; a = 1; (void)a; ],
125                 [ ac_cv_have_u_int64_t="yes" ],
126                 [ ac_cv_have_u_int64_t="no" ]
127         )
128 ])
129 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
130         AC_DEFINE(HAVE_U_INT64_T)
131         have_u_int64_t=1
132 fi
133
134 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
135            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
136 then
137         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
138         AC_TRY_COMPILE(
139                 [
140 #include <sys/bitypes.h>
141                 ],
142                 [
143                         int8_t a; int16_t b; int32_t c;
144                         u_int8_t e; u_int16_t f; u_int32_t g;
145                         a = b = c = e = f = g = 1;
146                         (void)a; (void)b; (void)c;
147                         (void)e; (void)f; (void)g;
148                 ],
149                 [
150                         AC_DEFINE(HAVE_U_INTXX_T)
151                         AC_DEFINE(HAVE_INTXX_T)
152                         AC_MSG_RESULT(yes)
153                 ],
154                 [AC_MSG_RESULT(no)]
155         )
156 fi
157
158 if test -z "$have_u_intxx_t" ; then
159         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
160                 AC_TRY_COMPILE(
161                         [
162 #include <sys/types.h>
163                         ],
164                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; (void)a; (void)b; (void)c; ],
165                         [ ac_cv_have_uintxx_t="yes" ],
166                         [ ac_cv_have_uintxx_t="no" ]
167                 )
168         ])
169         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
170                 AC_DEFINE(HAVE_UINTXX_T)
171         fi
172 fi
173
174 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
175         AC_TRY_COMPILE(
176                 [
177 #include <sys/types.h>
178 #include <sys/socket.h>
179                 ],
180                 [socklen_t foo; foo = 1235; (void)foo; ],
181                 [ ac_cv_have_socklen_t="yes" ],
182                 [ ac_cv_have_socklen_t="no" ]
183         )
184 ])
185 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
186         AC_DEFINE(HAVE_SOCKLEN_T)
187 fi
188
189 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
190         AC_TRY_COMPILE(
191                 [
192 #include <sys/types.h>
193                 ],
194                 [ size_t foo; foo = 1235; (void)foo; ],
195                 [ ac_cv_have_size_t="yes" ],
196                 [ ac_cv_have_size_t="no" ]
197         )
198 ])
199 if test "x$ac_cv_have_size_t" = "xyes" ; then
200         AC_DEFINE(HAVE_SIZE_T)
201 fi
202
203 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
204         AC_TRY_COMPILE(
205                 [
206 #include <sys/types.h>
207                 ],
208                 [ ssize_t foo; foo = 1235; (void)foo; ],
209                 [ ac_cv_have_ssize_t="yes" ],
210                 [ ac_cv_have_ssize_t="no" ]
211         )
212 ])
213 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
214         AC_DEFINE(HAVE_SSIZE_T)
215 fi
216
217 docdir="docs"
218 mansubdir="man"
219 AC_SUBST(docdir)
220 AC_SUBST(mansubdir)
221
222 AC_CHECK_LIB(pthread, pthread_create)
223
224 DOTSO=so
225 LIBSHORT='libjlog.$(DOTSO)'
226 LIBMAJOR='libjlog.$(DOTSO).$(MAJOR_VERSION)'
227 LIBLONG='libjlog.$(DOTSO).$(VERSION)'
228 LD_LIBJLOG_VERSION='-Wl,-soname,libjlog.$(DOTSO).$(MAJOR_VERSION)'
229 case $host in
230   *solaris*)
231     RLDFLAG="-R"
232     if test "x$ac_compiler_gnu" = "xyes" ; then
233        # GCC
234        SHCFLAGS="$SHCFLAGS -fPIC -D_REENTRANT"
235        CFLAGS="$CFLAGS"
236        SHLD="$CC -shared"
237     else
238        # Sun C compiler
239        SHCFLAGS="$SHCFLAGS -KPIC -mt"
240        CFLAGS="$CFLAGS -mt"
241        LIBS="-mt $LIBS"
242        SHLD="$CC -G"
243     fi
244     ;;
245   *linux*)
246     CFLAGS="$CFLAGS -D_BSD_SOURCE -D_SVID_SOURCE"
247     RLDFLAG="-Wl,--rpath="
248     case `uname -m` in
249       *x86_64*)
250         SHCFLAGS="$SHCFLAGS -fPIC"
251         ;;
252     esac
253     SHCFLAGS="$SHCFLAGS -shared"
254     SHLD="$CC -shared -rdynamic"
255     ;;
256   *darwin*)
257     DOTSO=dylib
258     LIBSHORT='libjlog.$(DOTSO)'
259     LIBMAJOR='libjlog.$(MAJOR_VERSION).$(DOTSO)'
260     LIBLONG='libjlog.$(VERSION).$(DOTSO)'
261     LD_LIBJLOG_VERSION='-current_version $(VERSION) -install_name $(libdir)/libjlog.$(MAJOR_VERSION).$(DOTSO)'
262     SHCFLAGS="$CFLAGS"
263     SHLD="$CC -dynamiclib -single_module -undefined dynamic_lookup"
264     ;;
265   *freebsd*)
266     SHCFLAGS="$CFLAGS -fPIC -pthread"
267     SHLD="$CC -shared -rdynamic"
268     ;;
269   *)
270     AC_MSG_ERROR(need to handle this case)
271     exit 1
272     ;;
273 esac
274 AC_SUBST(DOTSO)
275 AC_SUBST(LIBSHORT)
276 AC_SUBST(LIBMAJOR)
277 AC_SUBST(LIBLONG)
278 AC_SUBST(LD_LIBJLOG_VERSION)
279 AC_SUBST(SHLD)
280 AC_SUBST(SHCFLAGS)
281 AC_SUBST(LDFLAGS)
282 AC_SUBST(RLDFLAG)
283
284 AC_OUTPUT([
285 Makefile
286 perl/Makefile.PL
287 ])
Note: See TracBrowser for help on using the browser.