root/configure.in

Revision 4be21f8e99fb918f5a8e4445dd3753a53eba9a72, 9.8 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 10 years ago)

fix it backup on BSDs, refs #12

  • Property mode set to 100755
Line 
1 AC_INIT(src/noitd.c)
2
3 node=`hostname | cut -f1 -d '.' | tr '[A-Z]' '[a-z]'`
4 if test -f ".configure.$node"; then
5         echo "***********************************************************"
6         echo "* Loading node specific configure settings for $node."
7         echo "***********************************************************"
8         . ./.configure.$node
9 fi
10
11 AC_CANONICAL_HOST
12 AC_CONFIG_HEADER(src/noit_config.h)
13 AC_CONFIG_HEADER(src/jlog/jlog_config.h)
14
15 AC_PROG_CC
16 AC_C_INLINE
17 AC_C_BIGENDIAN
18 AC_PROG_CPP
19 AC_PROG_RANLIB
20 AC_PROG_INSTALL
21 AC_PROG_LN_S
22 AC_PATH_PROG(AR, ar)
23 AC_PATH_PROGS(PERL, perl)
24 AC_SUBST(PERL)
25
26 if test "x$CC" = "xgcc" ; then
27   CFLAGS="$CFLAGS -g -Wall"
28 fi
29
30 CPPFLAGS='-I$(top_srcdir)/src'
31
32 case $host in
33 *-*-darwin*)
34         PICFLAGS="-fPIC"
35         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
36         SHLD="$CC -dynamiclib -flat_namespace -undefined suppress"
37         MODULEEXT=bundle
38         RLDFLAG="-Wl,--rpath="
39         ;;
40 *-*-solaris*)
41         PICFLAGS="-Kpic"
42         MODULELD="$CC -G"
43         SHLD="$CC -G"
44         MODULEEXT=so
45         RLDFLAG="-R"
46         ;;
47 *-*-openbsd*)
48         PICFLAGS="-fpic"
49         LDFLAGS="$LDFLAGS -Wl,-E"
50         MODULELD="$CC -shared"
51         SHLD="$CC -shared"
52         MODULEEXT=so
53         LDFLAGS="$LDFLAGS -L/usr/local/lib"
54         CFLAGS="$CFLAGS -I/usr/local/include -I/usr/local/include/postgresql"
55         RLDFLAG="-Wl,--rpath="
56         ;;
57 *-*-linux*)
58         CPPFLAGS="$CPPFLAGS -D__USE_XOPEN"
59         PICFLAGS="-fpic"
60         MODULELD="$CC -shared"
61         SHLD="$CC -shared"
62         MODULEEXT=so
63         RLDFLAG="-Wl,--rpath="
64         ;;
65 *)
66         PICFLAGS="-fpic"
67         MODULELD="$CC -shared"
68         MODULEEXT=so
69         RLDFLAG="-Wl,--rpath="
70         ;;
71 esac
72 AC_SUBST(SHLD)
73 AC_SUBST(RLDFLAG)
74 AC_SUBST(MODULELD)
75 AC_SUBST(MODULEEXT)
76 AC_DEFINE_UNQUOTED(MODULEEXT, "$MODULEEXT", [module extension])
77
78 # Checks for data types
79 AC_CHECK_SIZEOF(char, 1)
80 AC_CHECK_SIZEOF(short int, 2)
81 AC_CHECK_SIZEOF(int, 4)
82 AC_CHECK_SIZEOF(long int, 4)
83 AC_CHECK_SIZEOF(long long int, 8)
84 AC_CHECK_SIZEOF(void *, 1)
85
86 AC_CHECK_LIB(rt, sem_init, , )
87 AC_CHECK_LIB(posix4, sem_wait, , )
88 AC_CHECK_LIB(pthread, pthread_create, , )
89 AC_CHECK_LIB(uuid, uuid_generate, , )
90 # Some libraries provide an unparse_lower command
91 # we use that, so if it isn't present, we'll need
92 # to implement it.
93 AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE(HAVE_UUID_UNPARSE_LOWER)], )
94 AC_CHECK_LIB(util, openpty, , )
95 AC_CHECK_LIB(termcap, tputs, , )
96 AC_CHECK_LIB(curses, clear, , )
97 AC_CHECK_LIB(pcre, pcre_compile, ,
98         [
99                 AC_MSG_ERROR([libpcre not found, but required])
100         ]
101 )
102 AC_CHECK_LIB(crypto, ERR_load_CRYPTO_strings, ,
103         [
104                 AC_MSG_ERROR([libcrypto not found, but required])
105         ]
106 )
107 AC_CHECK_LIB(ssl, SSL_library_init, ,
108         [
109                 AC_MSG_ERROR([libssl not found, but required])
110         ]
111 )
112
113 SAVELIBS="$LIBS"
114 AC_CHECK_LIB(pq, PQconnectdb,
115         [
116                 LIBS="$LIBS -lpq"
117                 PGLIBS="$LIBS"
118                 AC_SUBST(PGLIBS)
119         ],
120         [
121                 AC_MSG_ERROR([libpq required])
122         ]
123 )
124
125 AC_MSG_CHECKING([libpq includes])
126 PQICFLAGS=`pg_config --includedir-server`
127 if test -n "$PQICFLAGS" ; then
128   CFLAGS="$CFLAGS -I$PQICFLAGS"
129 fi
130 AC_MSG_RESULT([$PQICFLAGS])
131
132 AC_TRY_LINK([
133         #include <libpq-fe.h>
134         #include <postgres.h>
135         #include <fmgr.h>
136         ],
137         [ PGconn *dbh = PQconnectdb(""); ],
138         [],
139         [ AC_MSG_ERROR([Cannot compile/link against libpq]) ]
140 )
141 LIBS="$SAVELIBS"
142
143 ########
144 #
145 # CHECK FOR VARIOUS MODULE CRITERIA
146 # We don't track the libs themselves, as we'll just explictly link
147 # against the in the makefile if we enable them to build (by adding
148 # them to the BUILD_MODULES list).
149 #
150 ########
151
152 # Should we build snmp checks?
153 SAVELIBS="$LIBS"
154 AC_CHECK_LIB(netsnmp, snmp_sess_open,
155         [
156                 BUILD_MODULES="$BUILD_MODULES snmp.$MODULEEXT"
157         ],
158         [
159                 AC_MSG_WARN([No libnetsnmp, skipping snmp module])
160         ]
161 )
162 LIBS="$SAVELIBS"
163
164 # Should we build ssh2 checks?
165 SAVELIBS="$LIBS"
166 AC_CHECK_LIB(ssh2, libssh2_session_init_ex,
167         [
168                 BUILD_MODULES="$BUILD_MODULES ssh2.$MODULEEXT"
169         ],
170         [
171                 AC_MSG_WARN([No libssh2, skipping ssh2 module])
172         ]
173 )
174 LIBS="$SAVELIBS"
175
176 AC_MSG_CHECKING([libxml2 cflags])
177 XML2CFLAGS=`xml2-config --cflags`
178 CFLAGS="$CFLAGS $XML2CFLAGS"
179 AC_MSG_RESULT([$XML2CFLAGS])
180
181 AC_MSG_CHECKING([libxml2 libs])
182 XML2LIBS=`xml2-config --libs`
183 LIBS="$LIBS $XML2LIBS"
184 AC_MSG_RESULT([$XML2LIBS])
185
186 AC_MSG_CHECKING([libserf cflags])
187 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
188 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
189 AC_SUBST(SERFCFLAGS)
190 AC_MSG_RESULT([$SERFCFLAGS])
191
192 AC_MSG_CHECKING([libserf libs])
193 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
194 AC_SUBST(SERFLIBS)
195 AC_MSG_RESULT([$SERFLIBS])
196
197 AC_TRY_LINK([],
198         [ issetugid(); ],
199         [ ac_cv_libc_defines_issetugid="yes" ],
200         [ ac_cv_libc_defines_issetugid="no" ]
201 )
202 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
203         AC_DEFINE(HAVE_ISSETUGID)
204 fi
205
206 AC_MSG_CHECKING([whether sem_init works])
207 AC_TRY_RUN(
208         [
209 #include <semaphore.h>
210 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
211         ],
212         [AC_MSG_RESULT(yes)],
213         [
214                 AC_MSG_RESULT(no)
215                 AC_DEFINE(BROKEN_SEM_INIT)
216                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
217         ]
218 )
219
220 AC_FUNC_STRFTIME
221 AC_CHECK_FUNC(ssetugid strlcpy)
222
223 # Checks for header files.
224 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
225                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
226                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
227                  term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \
228                  sys/ioctl_compat.h util.h sys/time.h sys/mman.h)
229
230 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
231         AC_TRY_LINK(
232                 [ #include <sys/types.h> ],
233                 [ u_int a; a = kqueue(); ],
234                 [ ac_cv_have_kqueue="yes" ],
235                 [ ac_cv_have_kqueue="no" ]
236         )
237 ])
238 if test "x$ac_cv_have_kqueue" = "xyes" ; then
239         AC_DEFINE(HAVE_KQUEUE)
240         EVENTER_OBJS="$EVENTER_OBJS eventer_kqueue_impl.o"
241         have_kqueue=1
242 fi
243
244 AC_SUBST(EVENTER_OBJS)
245
246 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
247         AC_TRY_COMPILE(
248                 [ #include <sys/types.h> ],
249                 [ u_int a; a = 1;],
250                 [ ac_cv_have_u_int="yes" ],
251                 [ ac_cv_have_u_int="no" ]
252         )
253 ])
254 if test "x$ac_cv_have_u_int" = "xyes" ; then
255         AC_DEFINE(HAVE_U_INT)
256         have_u_int=1
257 fi
258
259 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
260         AC_TRY_COMPILE(
261                 [ #include <sys/types.h> ],
262                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
263                 [ ac_cv_have_intxx_t="yes" ],
264                 [ ac_cv_have_intxx_t="no" ]
265         )
266 ])
267 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
268         AC_DEFINE(HAVE_INTXX_T)
269         have_intxx_t=1
270 fi
271        
272 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
273         AC_TRY_COMPILE(
274                 [ #include <sys/types.h> ],
275                 [ int64_t a; a = 1;],
276                 [ ac_cv_have_int64_t="yes" ],
277                 [ ac_cv_have_int64_t="no" ]
278         )
279 ])
280 if test "x$ac_cv_have_int64_t" = "xyes" ; then
281         AC_DEFINE(HAVE_INT64_T)
282         have_int64_t=1
283 fi
284        
285 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
286         AC_TRY_COMPILE(
287                 [ #include <sys/types.h> ],
288                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
289                 [ ac_cv_have_u_intxx_t="yes" ],
290                 [ ac_cv_have_u_intxx_t="no" ]
291         )
292 ])
293 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
294         AC_DEFINE(HAVE_U_INTXX_T)
295         have_u_intxx_t=1
296 fi
297
298 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
299         AC_TRY_COMPILE(
300                 [ #include <sys/types.h> ],
301                 [ u_int64_t a; a = 1;],
302                 [ ac_cv_have_u_int64_t="yes" ],
303                 [ ac_cv_have_u_int64_t="no" ]
304         )
305 ])
306 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
307         AC_DEFINE(HAVE_U_INT64_T)
308         have_u_int64_t=1
309 fi
310
311 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
312            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
313 then
314         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
315         AC_TRY_COMPILE(
316                 [
317 #include <sys/bitypes.h>
318                 ],
319                 [
320                         int8_t a; int16_t b; int32_t c;
321                         u_int8_t e; u_int16_t f; u_int32_t g;
322                         a = b = c = e = f = g = 1;
323                 ],
324                 [
325                         AC_DEFINE(HAVE_U_INTXX_T)
326                         AC_DEFINE(HAVE_INTXX_T)
327                         AC_MSG_RESULT(yes)
328                 ],
329                 [AC_MSG_RESULT(no)]
330         )
331 fi
332
333 if test -z "$have_u_intxx_t" ; then
334         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
335                 AC_TRY_COMPILE(
336                         [
337 #include <sys/types.h>
338                         ],
339                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
340                         [ ac_cv_have_uintxx_t="yes" ],
341                         [ ac_cv_have_uintxx_t="no" ]
342                 )
343         ])
344         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
345                 AC_DEFINE(HAVE_UINTXX_T)
346         fi
347 fi
348
349 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
350         AC_TRY_COMPILE(
351                 [
352 #include <sys/types.h>
353 #include <sys/socket.h>
354                 ],
355                 [socklen_t foo; foo = 1235;],
356                 [ ac_cv_have_socklen_t="yes" ],
357                 [ ac_cv_have_socklen_t="no" ]
358         )
359 ])
360 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
361         AC_DEFINE(HAVE_SOCKLEN_T)
362 fi
363
364 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
365         AC_TRY_COMPILE(
366                 [
367 #include <sys/types.h>
368                 ],
369                 [ size_t foo; foo = 1235; ],
370                 [ ac_cv_have_size_t="yes" ],
371                 [ ac_cv_have_size_t="no" ]
372         )
373 ])
374 if test "x$ac_cv_have_size_t" = "xyes" ; then
375         AC_DEFINE(HAVE_SIZE_T)
376 fi
377
378 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
379         AC_TRY_COMPILE(
380                 [
381 #include <sys/types.h>
382                 ],
383                 [ ssize_t foo; foo = 1235; ],
384                 [ ac_cv_have_ssize_t="yes" ],
385                 [ ac_cv_have_ssize_t="no" ]
386         )
387 ])
388 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
389         AC_DEFINE(HAVE_SSIZE_T)
390 fi
391
392 AC_SUBST(BUILD_MODULES)
393
394 docdir="docs"
395 mansubdir="man"
396 AC_SUBST(docdir)
397 AC_SUBST(mansubdir)
398
399 SHCFLAGS="$PICFLAGS $CFLAGS"
400 AC_SUBST(SHCFLAGS)
401
402 AC_MSG_CHECKING([Resolving libexec path...])
403 fullpath=$libexecdir
404 while test "x$temppath" != "x$fullpath" ; do
405   temppath=$fullpath
406   fullpath=`eval echo ${fullpath}`
407 done
408 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
409 AC_MSG_RESULT([$fullpath])
410 AC_DEFINE_UNQUOTED(MODULES_DIR, "${fullpath}")
411 MODULES_DIR=${fullpath}
412 AC_SUBST(MODULES_DIR)
413
414 AC_MSG_CHECKING([Resolving sysconfdir path...])
415 fullpath=$sysconfdir
416 while test "x$temppath" != "x$fullpath" ; do
417   temppath=$fullpath
418   fullpath=`eval echo ${fullpath}`
419 done
420 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
421 AC_MSG_RESULT([$fullpath])
422 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
423 ETC_DIR=${fullpath}
424 AC_SUBST(ETC_DIR)
425
426
427 AC_OUTPUT([
428 Makefile
429 src/Makefile
430 src/eventer/Makefile
431 src/jlog/Makefile
432 src/jlog/perl/Makefile.PL
433 src/modules/Makefile
434 src/utils/Makefile
435 src/noitedit/Makefile
436 test/Makefile
437 ])
Note: See TracBrowser for help on using the browser.