root/configure.in

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

cleanup warnings and fix tputs in libedit, refs #34

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