root/configure.in

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

need to find postgres includes and pass CFLAGS and LDFLAGS to serf's build, refs #32

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