root/configure.in

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

refs #29

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