root/configure.in

Revision 0a06b2cbef3380c0fa794480d2fae8b4b1431f92, 12.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

refs #50

  • 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 else
29   CFLAGS="$CFLAGS -g"
30 fi
31
32 CPPFLAGS="$CPPFLAGS "'-I$(top_srcdir)/src'
33
34 case $host in
35 *-*-darwin*)
36         PICFLAGS="-fPIC"
37         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
38         SHLD="$CC -dynamiclib -flat_namespace -undefined suppress"
39         MODULEEXT=bundle
40         RLDFLAG="-Wl,--rpath="
41         ;;
42 *-*-solaris*)
43         AC_MSG_CHECKING([32 or 64 bit Solaris assembly])
44         if test -n "`echo $CFLAGS | grep m64`"; then
45                 AC_MSG_RESULT([64])
46                 ATOMIC_OBJS="noit_atomic_sol_x86_64.o"
47         else
48                 AC_MSG_RESULT([32])
49                 ATOMIC_OBJS="noit_atomic_sol_x86_32.o"
50         fi
51         PICFLAGS="-Kpic"
52         MODULELD="$CC -G"
53         SHLD="$CC -G"
54         MODULEEXT=so
55         RLDFLAG="-R"
56         WHOLE_ARCHIVE="-Wl,-z -Wl,allextract"
57         NOWHOLE_ARCHIVE="-Wl,-z -Wl,defaultextract"
58         ;;
59 *-*-openbsd*)
60         PICFLAGS="-fpic"
61         LDFLAGS="$LDFLAGS -Wl,-E"
62         MODULELD="$CC -shared"
63         SHLD="$CC -shared"
64         MODULEEXT=so
65         LDFLAGS="$LDFLAGS -L/usr/local/lib"
66         CFLAGS="$CFLAGS -I/usr/local/include"
67         RLDFLAG="-Wl,--rpath="
68         WHOLE_ARCHIVE="-Wl,--whole-archive"
69         NOWHOLE_ARCHIVE="-Wl,--no-whole-archive"
70         ;;
71 *-*-linux*)
72         LDFLAGS="$LDFLAGS -Wl,-E"
73         CPPFLAGS="$CPPFLAGS"
74         PICFLAGS="-fpic"
75         MODULELD="$CC -shared"
76         SHLD="$CC -shared"
77         MODULEEXT=so
78         RLDFLAG="-Wl,--rpath="
79         WHOLE_ARCHIVE="-Wl,--whole-archive"
80         NOWHOLE_ARCHIVE="-Wl,--no-whole-archive"
81         ;;
82 *)
83         PICFLAGS="-fpic"
84         MODULELD="$CC -shared"
85         MODULEEXT=so
86         RLDFLAG="-Wl,--rpath="
87         ;;
88 esac
89 AC_SUBST(SHLD)
90 AC_SUBST(RLDFLAG)
91 AC_SUBST(MODULELD)
92 AC_SUBST(MODULEEXT)
93 AC_SUBST(WHOLE_ARCHIVE)
94 AC_SUBST(NOWHOLE_ARCHIVE)
95 AC_SUBST(ATOMIC_OBJS)
96 AC_DEFINE_UNQUOTED(MODULEEXT, "$MODULEEXT", [module extension])
97
98 # Checks for data types
99 AC_CHECK_SIZEOF(char, 1)
100 AC_CHECK_SIZEOF(short int, 2)
101 AC_CHECK_SIZEOF(int, 4)
102 AC_CHECK_SIZEOF(long int, 4)
103 AC_CHECK_SIZEOF(long long int, 8)
104 AC_CHECK_SIZEOF(void *, 1)
105
106 AC_CHECK_LIB(z, compress2, , [AC_MSG_ERROR(*** zlib is required ***)])
107 AC_CHECK_LIB(rt, sem_init, , )
108 AC_CHECK_LIB(posix4, sem_wait, , )
109 AC_CHECK_LIB(pthread, pthread_create, , )
110 AC_CHECK_LIB(uuid, uuid_generate, , [AC_MSG_ERROR(*** uuid is required ***)])
111 # Some libraries provide an unparse_lower command
112 # we use that, so if it isn't present, we'll need
113 # to implement it.
114 AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE(HAVE_UUID_UNPARSE_LOWER)], )
115 AC_CHECK_LIB(util, openpty, , )
116 AC_CHECK_LIB(termcap, tputs, , )
117 AC_CHECK_LIB(curses, clear, , [AC_MSG_ERROR([curses not found, but required])])
118
119 CPPFLAGS="$CPPFLAGS `pcre-config --cflags`"
120 LDFLAGS="$LDFLAGS `pcre-config --libs`"
121 AC_CHECK_LIB(pcre, pcre_compile, ,
122         [
123                 AC_MSG_ERROR([libpcre not found, but required])
124         ]
125 )
126 AC_CHECK_LIB(crypto, ERR_load_CRYPTO_strings, ,
127         [
128                 AC_MSG_ERROR([libcrypto not found, but required])
129         ]
130 )
131 AC_CHECK_LIB(ssl, SSL_library_init, ,
132         [
133                 AC_MSG_ERROR([libssl not found, but required])
134         ]
135 )
136
137 old_LIBS=$LIBS
138 old_CFLAGS=$CFLAGS
139 AC_CHECK_LIB(pq, PQconnectdb,
140         [
141                 LIBS="$LIBS -lpq"
142                 PGLIBS="$LIBS"
143                 AC_SUBST(PGLIBS)
144         ],
145         [
146                 AC_MSG_ERROR([libpq required])
147         ]
148 )
149
150 AC_MSG_CHECKING([libpq includes])
151 PQICFLAGS=`pg_config --includedir`
152 if test -n "$PQICFLAGS" ; then
153   CFLAGS="$CFLAGS -I$PQICFLAGS"
154 fi
155
156 AC_TRY_LINK([
157         #include <libpq-fe.h>
158         ],
159         [ PGconn *dbh = PQconnectdb(""); ],
160         [],
161         [ AC_MSG_ERROR([Cannot compile/link against libpq]) ]
162 )
163 PGCFLAGS=$CFLAGS
164 AC_SUBST(PGCFLAGS)
165
166 LIBS=$old_LIBS
167 CFLAGS=$old_CFLAGS
168
169 ########
170 #
171 # CHECK FOR VARIOUS MODULE CRITERIA
172 # We don't track the libs themselves, as we'll just explictly link
173 # against the in the makefile if we enable them to build (by adding
174 # them to the BUILD_MODULES list).
175 #
176 ########
177
178 # Should we build snmp checks?
179 SAVELIBS="$LIBS"
180 AC_CHECK_LIB(netsnmp, snmp_sess_open,
181         [
182                 BUILD_MODULES="$BUILD_MODULES snmp.$MODULEEXT"
183         ],
184         [
185                 AC_MSG_WARN([No libnetsnmp, skipping snmp module])
186         ]
187 )
188 LIBS="$SAVELIBS"
189
190 # Should we build ssh2 checks?
191 SAVELIBS="$LIBS"
192 AC_CHECK_LIB(ssh2, libssh2_session_init_ex,
193         [
194                 BUILD_MODULES="$BUILD_MODULES ssh2.$MODULEEXT"
195         ],
196         [
197                 AC_MSG_WARN([No libssh2, skipping ssh2 module])
198         ]
199 )
200 LIBS="$SAVELIBS"
201
202 AC_MSG_CHECKING([libxml2 cflags])
203 XML2CFLAGS=`xml2-config --cflags`
204 CFLAGS="$CFLAGS $XML2CFLAGS"
205 AC_MSG_RESULT([$XML2CFLAGS])
206
207 AC_MSG_CHECKING([libxml2 libs])
208 XML2LIBS=`xml2-config --libs`
209 LIBS="$LIBS $XML2LIBS"
210 AC_MSG_RESULT([$XML2LIBS])
211
212 APRPREFIX="`apr-1-config --prefix`"
213 AC_MSG_CHECKING([libserf cflags])
214 AC_SUBST(APRPREFIX)
215 AC_MSG_RESULT([$APRPREFIX])
216
217 AC_MSG_CHECKING([libserf cflags])
218 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
219 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
220 AC_SUBST(SERFCFLAGS)
221 AC_MSG_RESULT([$SERFCFLAGS])
222
223 AC_MSG_CHECKING([libserf libs])
224 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
225 AC_SUBST(SERFLIBS)
226 AC_MSG_RESULT([$SERFLIBS])
227
228 AC_TRY_LINK([],
229         [ issetugid(); ],
230         [ ac_cv_libc_defines_issetugid="yes" ],
231         [ ac_cv_libc_defines_issetugid="no" ]
232 )
233 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
234         AC_DEFINE(HAVE_ISSETUGID)
235 fi
236
237 AC_MSG_CHECKING([whether sem_init works])
238 AC_TRY_RUN(
239         [
240 #include <semaphore.h>
241 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
242         ],
243         [
244                 AC_MSG_RESULT(yes)
245                 AC_DEFINE(WORKING_SEM_INIT)
246         ],
247         [
248                 AC_MSG_RESULT(no)
249                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
250         ]
251 )
252
253 AC_FUNC_STRFTIME
254 AC_CHECK_FUNCS(ssetugid strlcpy strnstrn openpty inet_pton inet_ntop getopt \
255                poll)
256
257 # Checks for header files.
258 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
259                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
260                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
261                  term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \
262                  sys/ioctl_compat.h sys/filio.h util.h sys/time.h sys/mman.h \
263                  stropts.h sys/stream.h alloca.h sys/wait.h)
264
265 AC_MSG_CHECKING(for tputs() function final argument type)
266 AC_EGREP_CPP([tputs.*[(][       ]*char[         ]*[)]],
267                 [#if defined(HAVE_TERM_H)
268                  #include <term.h>
269                  #endif
270                  #if defined(HAVE_CURSES_H)
271                  #include <curses.h>
272                  #endif],
273                 [AC_MSG_RESULT(char)
274                  AC_DEFINE(TPUTS_TAKES_CHAR)],
275                 [AC_MSG_RESULT(not char)])
276
277 AC_CACHE_CHECK([for epoll support], ac_cv_have_epoll, [
278         AC_TRY_LINK(
279                 [ #include <sys/types.h> ],
280                 [ u_int a; a = epoll_create(); ],
281                 [ ac_cv_have_epoll="yes" ],
282                 [ ac_cv_have_epoll="no" ]
283         )
284 ])
285 if test "x$ac_cv_have_epoll" = "xyes" ; then
286         AC_DEFINE(HAVE_EPOLL)
287         EVENTER_OBJS="$EVENTER_OBJS eventer_epoll_impl.o"
288         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "epoll")
289         have_epoll=1
290 fi
291
292 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
293         AC_TRY_LINK(
294                 [ #include <sys/types.h> ],
295                 [ u_int a; a = kqueue(); ],
296                 [ ac_cv_have_kqueue="yes" ],
297                 [ ac_cv_have_kqueue="no" ]
298         )
299 ])
300 if test "x$ac_cv_have_kqueue" = "xyes" ; then
301         AC_DEFINE(HAVE_KQUEUE)
302         EVENTER_OBJS="$EVENTER_OBJS eventer_kqueue_impl.o"
303         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "kqueue")
304         have_kqueue=1
305 fi
306
307 AC_CACHE_CHECK([for Solaris ports support], ac_cv_have_ports, [
308         AC_TRY_LINK(
309                 [ #include <port.h> ],
310                 [ u_int a; a = port_create(); ],
311                 [ ac_cv_have_ports="yes" ],
312                 [ ac_cv_have_ports="no" ]
313         )
314 ])
315 if test "x$ac_cv_have_ports" = "xyes" ; then
316         AC_DEFINE(HAVE_PORTS)
317         EVENTER_OBJS="$EVENTER_OBJS eventer_ports_impl.o"
318         AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "ports")
319         have_ports=1
320 fi
321
322 AC_SUBST(EVENTER_OBJS)
323
324 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
325         AC_TRY_COMPILE(
326                 [ #include <sys/types.h> ],
327                 [ u_int a; a = 1;],
328                 [ ac_cv_have_u_int="yes" ],
329                 [ ac_cv_have_u_int="no" ]
330         )
331 ])
332 if test "x$ac_cv_have_u_int" = "xyes" ; then
333         AC_DEFINE(HAVE_U_INT)
334         have_u_int=1
335 fi
336
337 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
338         AC_TRY_COMPILE(
339                 [ #include <sys/types.h> ],
340                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
341                 [ ac_cv_have_intxx_t="yes" ],
342                 [ ac_cv_have_intxx_t="no" ]
343         )
344 ])
345 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
346         AC_DEFINE(HAVE_INTXX_T)
347         have_intxx_t=1
348 fi
349        
350 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
351         AC_TRY_COMPILE(
352                 [ #include <sys/types.h> ],
353                 [ int64_t a; a = 1;],
354                 [ ac_cv_have_int64_t="yes" ],
355                 [ ac_cv_have_int64_t="no" ]
356         )
357 ])
358 if test "x$ac_cv_have_int64_t" = "xyes" ; then
359         AC_DEFINE(HAVE_INT64_T)
360         have_int64_t=1
361 fi
362        
363 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
364         AC_TRY_COMPILE(
365                 [ #include <sys/types.h> ],
366                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
367                 [ ac_cv_have_u_intxx_t="yes" ],
368                 [ ac_cv_have_u_intxx_t="no" ]
369         )
370 ])
371 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
372         AC_DEFINE(HAVE_U_INTXX_T)
373         have_u_intxx_t=1
374 fi
375
376 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
377         AC_TRY_COMPILE(
378                 [ #include <sys/types.h> ],
379                 [ u_int64_t a; a = 1;],
380                 [ ac_cv_have_u_int64_t="yes" ],
381                 [ ac_cv_have_u_int64_t="no" ]
382         )
383 ])
384 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
385         AC_DEFINE(HAVE_U_INT64_T)
386         have_u_int64_t=1
387 fi
388
389 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
390            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
391 then
392         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
393         AC_TRY_COMPILE(
394                 [
395 #include <sys/bitypes.h>
396                 ],
397                 [
398                         int8_t a; int16_t b; int32_t c;
399                         u_int8_t e; u_int16_t f; u_int32_t g;
400                         a = b = c = e = f = g = 1;
401                 ],
402                 [
403                         AC_DEFINE(HAVE_U_INTXX_T)
404                         AC_DEFINE(HAVE_INTXX_T)
405                         AC_MSG_RESULT(yes)
406                 ],
407                 [AC_MSG_RESULT(no)]
408         )
409 fi
410
411 if test -z "$have_u_intxx_t" ; then
412         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
413                 AC_TRY_COMPILE(
414                         [
415 #include <sys/types.h>
416                         ],
417                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
418                         [ ac_cv_have_uintxx_t="yes" ],
419                         [ ac_cv_have_uintxx_t="no" ]
420                 )
421         ])
422         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
423                 AC_DEFINE(HAVE_UINTXX_T)
424         fi
425 fi
426
427 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
428         AC_TRY_COMPILE(
429                 [
430 #include <sys/types.h>
431 #include <sys/socket.h>
432                 ],
433                 [socklen_t foo; foo = 1235;],
434                 [ ac_cv_have_socklen_t="yes" ],
435                 [ ac_cv_have_socklen_t="no" ]
436         )
437 ])
438 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
439         AC_DEFINE(HAVE_SOCKLEN_T)
440 fi
441
442 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
443         AC_TRY_COMPILE(
444                 [
445 #include <sys/types.h>
446                 ],
447                 [ size_t foo; foo = 1235; ],
448                 [ ac_cv_have_size_t="yes" ],
449                 [ ac_cv_have_size_t="no" ]
450         )
451 ])
452 if test "x$ac_cv_have_size_t" = "xyes" ; then
453         AC_DEFINE(HAVE_SIZE_T)
454 fi
455
456 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
457         AC_TRY_COMPILE(
458                 [
459 #include <sys/types.h>
460                 ],
461                 [ ssize_t foo; foo = 1235; ],
462                 [ ac_cv_have_ssize_t="yes" ],
463                 [ ac_cv_have_ssize_t="no" ]
464         )
465 ])
466 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
467         AC_DEFINE(HAVE_SSIZE_T)
468 fi
469
470 AC_SUBST(BUILD_MODULES)
471
472 docdir="docs"
473 mansubdir="man"
474 AC_SUBST(docdir)
475 AC_SUBST(mansubdir)
476 SHCFLAGS="$PICFLAGS $CFLAGS"
477 AC_SUBST(SHCFLAGS)
478
479 AC_MSG_CHECKING([Resolving libexec path...])
480 fullpath=$libexecdir
481 while test "x$temppath" != "x$fullpath" ; do
482   temppath=$fullpath
483   fullpath=`eval echo ${fullpath}`
484 done
485 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
486 AC_MSG_RESULT([$fullpath/noit])
487 AC_DEFINE_UNQUOTED(MODULES_DIR, "${fullpath}/noit")
488 MODULES_DIR=${fullpath}/noit
489 AC_SUBST(MODULES_DIR)
490
491 AC_MSG_CHECKING([Resolving sysconfdir path...])
492 fullpath=$sysconfdir
493 while test "x$temppath" != "x$fullpath" ; do
494   temppath=$fullpath
495   fullpath=`eval echo ${fullpath}`
496 done
497 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
498 AC_MSG_RESULT([$fullpath])
499 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
500 ETC_DIR=${fullpath}
501 AC_SUBST(ETC_DIR)
502
503
504 AC_OUTPUT([
505 Makefile
506 src/Makefile
507 src/eventer/Makefile
508 src/jlog/Makefile
509 src/jlog/perl/Makefile.PL
510 src/udns/Makefile
511 src/modules/Makefile
512 src/modules-lua/Makefile
513 src/utils/Makefile
514 src/noitedit/Makefile
515 src/lua/Makefile
516 sql/Makefile
517 test/Makefile
518 ])
Note: See TracBrowser for help on using the browser.