root/configure.in

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

reorder ssl/crypto lib check and make the lack of libnetsmp and libssh2 non-fatal

  • Property mode set to 100755
Line 
1 AC_INIT(src/noitd.c)
2 AC_CANONICAL_HOST
3 AC_CONFIG_HEADER(src/noit_config.h)
4 AC_CONFIG_HEADER(src/jlog/jlog_config.h)
5
6 AC_PROG_CC
7 AC_C_INLINE
8 AC_C_BIGENDIAN
9 AC_PROG_CPP
10 AC_PROG_RANLIB
11 AC_PROG_INSTALL
12 AC_PROG_LN_S
13 AC_PATH_PROG(AR, ar)
14 AC_PATH_PROGS(PERL, perl)
15 AC_SUBST(PERL)
16
17 if test "x$CC" = "xgcc" ; then
18   CFLAGS="$CFLAGS -g -Wall"
19 fi
20
21 case $host in
22 *-*-darwin*)
23         PICFLAGS="-fPIC"
24         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
25         MODULEEXT=bundle
26         ;;
27 *-*-solaris*)
28         PICFLAGS="-Kpic"
29         MODULELD="$CC -G"
30         MODULEEXT=so
31         ;;
32 *-*-openbsd*)
33         PICFLAGS="-fpic"
34         LDFLAGS="$LDFLAGS -Wl,-E"
35         MODULELD="$CC -shared"
36         MODULEEXT=so
37         LDFLAGS="$LDFLAGS -L/usr/local/lib"
38         CFLAGS="$CFLAGS -I/usr/local/include -I/usr/local/include/postgresql"
39         ;;
40 *)
41         PICFLAGS="-fpic"
42         MODULELD="$CC -shared"
43         MODULEEXT=so
44         ;;
45 esac
46 AC_SUBST(MODULELD)
47 AC_SUBST(MODULEEXT)
48 AC_DEFINE_UNQUOTED(MODULEEXT, "$MODULEEXT", [module extension])
49
50 # Checks for data types
51 AC_CHECK_SIZEOF(char, 1)
52 AC_CHECK_SIZEOF(short int, 2)
53 AC_CHECK_SIZEOF(int, 4)
54 AC_CHECK_SIZEOF(long int, 4)
55 AC_CHECK_SIZEOF(long long int, 8)
56 AC_CHECK_SIZEOF(void *, 1)
57
58 AC_CHECK_LIB(rt, sem_init, , )
59 AC_CHECK_LIB(posix4, sem_wait, , )
60 AC_CHECK_LIB(pthread, pthread_create, , )
61 AC_CHECK_LIB(uuid, uuid_generate, , )
62 AC_CHECK_LIB(util, openpty, , )
63 AC_CHECK_LIB(termcap, tputs, , )
64 AC_CHECK_LIB(curses, clear, , )
65 AC_CHECK_LIB(crypto, ERR_load_CRYPTO_strings, ,
66         [
67                 AC_MSG_ERROR([libssl not found, but required])
68         ]
69 )
70 AC_CHECK_LIB(ssl, SSL_library_init, ,
71         [
72                 AC_MSG_ERROR([libssl not found, but required])
73         ]
74 )
75
76 SAVELIBS="$LIBS"
77 AC_CHECK_LIB(pq, PQconnectdb,
78         [
79                 LIBS="$LIBS -lpq"
80                 PGLIBS="$LIBS"
81                 AC_SUBST(PGLIBS)
82         ],
83         [
84                 AC_MSG_ERROR([libpq required])
85         ]
86 )
87 AC_TRY_LINK([#include <libpq-fe.h>],
88         [ PGconn *dbh = PQconnectdb(""); ],
89         [],
90         [ AC_MSG_ERROR([Cannot compile/link against libpq]) ]
91 )
92 LIBS="$SAVELIBS"
93
94 ########
95 #
96 # CHECK FOR VARIOUS MODULE CRITERIA
97 # We don't track the libs themselves, as we'll just explictly link
98 # against the in the makefile if we enable them to build (by adding
99 # them to the BUILD_MODULES list).
100 #
101 ########
102
103 # Should we build snmp checks?
104 SAVELIBS="$LIBS"
105 AC_CHECK_LIB(netsnmp, snmp_sess_open,
106         [
107                 BUILD_MODULES="$BUILD_MODULES snmp.$MODULEEXT"
108         ],
109         [
110                 AC_MSG_WARN([No libnetsnmp, skipping snmp module])
111         ]
112 )
113 LIBS="$SAVELIBS"
114
115 # Should we build ssh2 checks?
116 SAVELIBS="$LIBS"
117 AC_CHECK_LIB(ssh2, libssh2_session_init_ex,
118         [
119                 BUILD_MODULES="$BUILD_MODULES ssh2.$MODULEEXT"
120         ],
121         [
122                 AC_MSG_WARN([No libssh2, skipping ssh2 module])
123         ]
124 )
125 LIBS="$SAVELIBS"
126
127 AC_MSG_CHECKING([libxml2 cflags])
128 XML2CFLAGS=`xml2-config --cflags`
129 CFLAGS="$CFLAGS $XML2CFLAGS"
130 AC_MSG_RESULT([$XML2CFLAGS])
131
132 AC_MSG_CHECKING([libxml2 libs])
133 XML2LIBS=`xml2-config --libs`
134 LIBS="$LIBS $XML2LIBS"
135 AC_MSG_RESULT([$XML2LIBS])
136
137 AC_MSG_CHECKING([libserf cflags])
138 SERFCFLAGS="`apr-1-config --cflags --cppflags`"
139 SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`"
140 AC_SUBST(SERFCFLAGS)
141 AC_MSG_RESULT([$SERFCFLAGS])
142
143 AC_MSG_CHECKING([libserf libs])
144 SERFLIBS="`apu-1-config --link-ld --ldflags --libs` `apr-1-config --link-ld --ldflags --libs`"
145 AC_SUBST(SERFLIBS)
146 AC_MSG_RESULT([$SERFLIBS])
147
148 AC_TRY_LINK([],
149         [ issetugid(); ],
150         [ ac_cv_libc_defines_issetugid="yes" ],
151         [ ac_cv_libc_defines_issetugid="no" ]
152 )
153 if test "x$ac_cv_libc_defines_issetugid" = "xyes" ; then
154         AC_DEFINE(HAVE_ISSETUGID)
155 fi
156
157 AC_MSG_CHECKING([whether sem_init works])
158 AC_TRY_RUN(
159         [
160 #include <semaphore.h>
161 int main(void){sem_t s;return (0 != sem_init(&s,0,0));}
162         ],
163         [AC_MSG_RESULT(yes)],
164         [
165                 AC_MSG_RESULT(no)
166                 AC_DEFINE(BROKEN_SEM_INIT)
167                 AC_MSG_WARN([****** sem_init() is broken, I'll implement one myself.])
168         ]
169 )
170
171 AC_FUNC_STRFTIME
172 AC_CHECK_FUNC(ssetugid strlcpy)
173
174 # Checks for header files.
175 AC_CHECK_HEADERS(sys/file.h sys/types.h dirent.h sys/param.h fcntl.h errno.h limits.h \
176                  sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \
177                  ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \
178                  term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \
179                  util.h sys/time.h sys/mman.h)
180
181 AC_CACHE_CHECK([for kqueue support], ac_cv_have_kqueue, [
182         AC_TRY_LINK(
183                 [ #include <sys/types.h> ],
184                 [ u_int a; a = kqueue(); ],
185                 [ ac_cv_have_kqueue="yes" ],
186                 [ ac_cv_have_kqueue="no" ]
187         )
188 ])
189 if test "x$ac_cv_have_kqueue" = "xyes" ; then
190         AC_DEFINE(HAVE_KQUEUE)
191         have_kqueue=1
192 fi
193
194
195 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
196         AC_TRY_COMPILE(
197                 [ #include <sys/types.h> ],
198                 [ u_int a; a = 1;],
199                 [ ac_cv_have_u_int="yes" ],
200                 [ ac_cv_have_u_int="no" ]
201         )
202 ])
203 if test "x$ac_cv_have_u_int" = "xyes" ; then
204         AC_DEFINE(HAVE_U_INT)
205         have_u_int=1
206 fi
207
208 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
209         AC_TRY_COMPILE(
210                 [ #include <sys/types.h> ],
211                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
212                 [ ac_cv_have_intxx_t="yes" ],
213                 [ ac_cv_have_intxx_t="no" ]
214         )
215 ])
216 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
217         AC_DEFINE(HAVE_INTXX_T)
218         have_intxx_t=1
219 fi
220        
221 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
222         AC_TRY_COMPILE(
223                 [ #include <sys/types.h> ],
224                 [ int64_t a; a = 1;],
225                 [ ac_cv_have_int64_t="yes" ],
226                 [ ac_cv_have_int64_t="no" ]
227         )
228 ])
229 if test "x$ac_cv_have_int64_t" = "xyes" ; then
230         AC_DEFINE(HAVE_INT64_T)
231         have_int64_t=1
232 fi
233        
234 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
235         AC_TRY_COMPILE(
236                 [ #include <sys/types.h> ],
237                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
238                 [ ac_cv_have_u_intxx_t="yes" ],
239                 [ ac_cv_have_u_intxx_t="no" ]
240         )
241 ])
242 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
243         AC_DEFINE(HAVE_U_INTXX_T)
244         have_u_intxx_t=1
245 fi
246
247 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
248         AC_TRY_COMPILE(
249                 [ #include <sys/types.h> ],
250                 [ u_int64_t a; a = 1;],
251                 [ ac_cv_have_u_int64_t="yes" ],
252                 [ ac_cv_have_u_int64_t="no" ]
253         )
254 ])
255 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
256         AC_DEFINE(HAVE_U_INT64_T)
257         have_u_int64_t=1
258 fi
259
260 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
261            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
262 then
263         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
264         AC_TRY_COMPILE(
265                 [
266 #include <sys/bitypes.h>
267                 ],
268                 [
269                         int8_t a; int16_t b; int32_t c;
270                         u_int8_t e; u_int16_t f; u_int32_t g;
271                         a = b = c = e = f = g = 1;
272                 ],
273                 [
274                         AC_DEFINE(HAVE_U_INTXX_T)
275                         AC_DEFINE(HAVE_INTXX_T)
276                         AC_MSG_RESULT(yes)
277                 ],
278                 [AC_MSG_RESULT(no)]
279         )
280 fi
281
282 if test -z "$have_u_intxx_t" ; then
283         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
284                 AC_TRY_COMPILE(
285                         [
286 #include <sys/types.h>
287                         ],
288                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
289                         [ ac_cv_have_uintxx_t="yes" ],
290                         [ ac_cv_have_uintxx_t="no" ]
291                 )
292         ])
293         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
294                 AC_DEFINE(HAVE_UINTXX_T)
295         fi
296 fi
297
298 AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t, [
299         AC_TRY_COMPILE(
300                 [
301 #include <sys/types.h>
302 #include <sys/socket.h>
303                 ],
304                 [socklen_t foo; foo = 1235;],
305                 [ ac_cv_have_socklen_t="yes" ],
306                 [ ac_cv_have_socklen_t="no" ]
307         )
308 ])
309 if test "x$ac_cv_have_socklen_t" = "xyes" ; then
310         AC_DEFINE(HAVE_SOCKLEN_T)
311 fi
312
313 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
314         AC_TRY_COMPILE(
315                 [
316 #include <sys/types.h>
317                 ],
318                 [ size_t foo; foo = 1235; ],
319                 [ ac_cv_have_size_t="yes" ],
320                 [ ac_cv_have_size_t="no" ]
321         )
322 ])
323 if test "x$ac_cv_have_size_t" = "xyes" ; then
324         AC_DEFINE(HAVE_SIZE_T)
325 fi
326
327 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
328         AC_TRY_COMPILE(
329                 [
330 #include <sys/types.h>
331                 ],
332                 [ ssize_t foo; foo = 1235; ],
333                 [ ac_cv_have_ssize_t="yes" ],
334                 [ ac_cv_have_ssize_t="no" ]
335         )
336 ])
337 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
338         AC_DEFINE(HAVE_SSIZE_T)
339 fi
340
341 AC_SUBST(BUILD_MODULES)
342
343 docdir="docs"
344 mansubdir="man"
345 AC_SUBST(docdir)
346 AC_SUBST(mansubdir)
347
348 CPPFLAGS='-I$(top_srcdir)/src'
349 SHCFLAGS="$PICFLAGS $CFLAGS"
350 AC_SUBST(SHCFLAGS)
351
352 AC_MSG_CHECKING([Resolving libexec path...])
353 fullpath=$libexecdir
354 while test "x$temppath" != "x$fullpath" ; do
355   temppath=$fullpath
356   fullpath=`eval echo ${fullpath}`
357 done
358 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
359 AC_MSG_RESULT([$fullpath])
360 AC_DEFINE_UNQUOTED(MODULES_DIR, "${fullpath}")
361 MODULES_DIR=${fullpath}
362 AC_SUBST(MODULES_DIR)
363
364 AC_MSG_CHECKING([Resolving sysconfdir path...])
365 fullpath=$sysconfdir
366 while test "x$temppath" != "x$fullpath" ; do
367   temppath=$fullpath
368   fullpath=`eval echo ${fullpath}`
369 done
370 fullpath=`echo $fullpath | sed "s~NONE~$ac_default_prefix~"`
371 AC_MSG_RESULT([$fullpath])
372 AC_DEFINE_UNQUOTED(ETC_DIR, "${fullpath}")
373 ETC_DIR=${fullpath}
374 AC_SUBST(ETC_DIR)
375
376
377 AC_OUTPUT([
378 Makefile
379 src/Makefile
380 src/eventer/Makefile
381 src/jlog/Makefile
382 src/modules/Makefile
383 src/utils/Makefile
384 src/noitedit/Makefile
385 ])
Note: See TracBrowser for help on using the browser.