root/configure.in

Revision 87de1cfcf05cd971deb05d13c0d1be988ac9d801, 13.2 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

headurl and svnversion stuff to use, refs #93

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