-
Notifications
You must be signed in to change notification settings - Fork 31
/
configure.ac
167 lines (136 loc) · 5.3 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([libmowgli-2],[2.1.3],[https://github.com/atheme/libmowgli-2])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADER([src/libmowgli/platform/autoconf.h])
AC_CONFIG_MACRO_DIR([m4])
AH_TOP([
#ifndef MOWGLI_SRC_LIBMOWGLI_PLATFORM_AUTOCONF_H_INCLUDE_GUARD
#define MOWGLI_SRC_LIBMOWGLI_PLATFORM_AUTOCONF_H_INCLUDE_GUARD 1
])
AH_BOTTOM([
#endif /* !MOWGLI_SRC_LIBMOWGLI_PLATFORM_AUTOCONF_H_INCLUDE_GUARD */
])
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_CC_C99
AS_IF([test "x$ac_cv_prog_cc_c99" = "xno"], [
AC_MSG_ERROR([C compiler does not support C99], 1)
])
MORECFLAGS="-pipe -Wall -Wextra -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers"
AS_IF([test "x$GCC" = "xyes"], [
CFLAGS="$CFLAGS $MORECFLAGS"
])
AC_CHECK_HEADERS([poll.h winsock2.h sys/epoll.h sys/select.h sys/pstat.h sys/prctl.h])
AC_CHECK_FUNCS([fcntl kqueue mmap select dispatch_block port_create setproctitle pstat])
AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <machine/vmparam.h>
#include <sys/exec.h>
]], [[PS_STRINGS->ps_nargvstr = 1;
PS_STRINGS->ps_argvstr = "foo";]])],[pgac_cv_var_PS_STRINGS=yes],[pgac_cv_var_PS_STRINGS=no])])
if test "$pgac_cv_var_PS_STRINGS" = yes ; then
AC_DEFINE([HAVE_PS_STRINGS], [], [Define to 1 if the PS_STRINGS struct exists on your platform (likely no).])
fi
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib)
LIBMOWGLI_MODULES="core base container dns eventloop ext linebuf module object platform thread vio"
AC_SUBST(LIBMOWGLI_MODULES)
LIBMOWGLI_MODULE_BUILD="$(echo && echo x)"
LIBMOWGLI_MODULE_BUILD="${LIBMOWGLI_MODULE_BUILD%x}"
LIBMOWGLI_SHARED_MODULES=""
AC_ARG_ENABLE([shared], [AS_HELP_STRING([--disable-shared], [do not build shared library])])
AS_IF([test x"$enable_shared" != x"no"], [
BUILDSYS_SHARED_LIB
BUILDSYS_PROG_IMPLIB
AC_SUBST([LIBMOWGLI_SHARED_LIB], [${LIB_PREFIX}mowgli-2${LIB_SUFFIX}])
for i in $LIBMOWGLI_MODULES
do
UPPER="[$(echo $i | tr '[:lower:]' '[:upper:]')]"
LIBMOWGLI_SHARED_MODULES="$LIBMOWGLI_SHARED_MODULES $i/mowgli.$i.lib.a"
LIBMOWGLI_MODULE_BUILD="$LIBMOWGLI_MODULE_BUILD$(echo LIBMOWGLI_SHARED_$UPPER = mowgli.$i.lib.a && echo x)"
LIBMOWGLI_MODULE_BUILD="${LIBMOWGLI_MODULE_BUILD%x}"
done
])
LIBMOWGLI_STATIC_MODULES=""
AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static], [build static library])])
AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
AC_SUBST([LIBMOWGLI_STATIC_LIB], [libmowgli-2.a])
for i in $LIBMOWGLI_MODULES
do
UPPER="[$(echo $i | tr '[:lower:]' '[:upper:]')]"
LIBMOWGLI_STATIC_MODULES="$LIBMOWGLI_STATIC_MODULES $i/mowgli.$i.a"
LIBMOWGLI_MODULE_BUILD="$LIBMOWGLI_MODULE_BUILD$(echo LIBMOWGLI_STATIC_$UPPER = mowgli.$i.a && echo x)"
LIBMOWGLI_MODULE_BUILD="${LIBMOWGLI_MODULE_BUILD%x}"
done
])
AC_MSG_CHECKING(OS type)
case "$target" in
*-*-mingw32)
AC_MSG_RESULT([win32])
LIBMOWGLI_OS="win32"
LIBS="$LIBS -lwsock32 -lws2_32"
AS_IF([test x"$LIBMOWGLI_SHARED_MODULES" != x""], [
LIBMOWGLI_SHARED_MODULES="$LIBMOWGLI_SHARED_MODULES platform/win32/mowgli.platform.win32.lib.a"
LIBMOWGLI_MODULE_BUILD="$LIBMOWGLI_MODULE_BUILD$(echo LIBMOWGLI_SHARED_PLATFORM_WIN32 = mowgli.platform.win32.lib.a && echo x)"
LIBMOWGLI_MODULE_BUILD="${LIBMOWGLI_MODULE_BUILD%x}"
])
AS_IF([test x"$LIBMOWGLI_STATIC_MODULES" != x""], [
LIBMOWGLI_STATIC_MODULES="$LIBMOWGLI_STATIC_MODULES platform/win32/mowgli.platform.win32.a"
LIBMOWGLI_MODULE_BUILD="$LIBMOWGLI_MODULE_BUILD$(echo LIBMOWGLI_STATIC_PLATFORM_WIN32 = mowgli.platform.win32.a && echo x)"
LIBMOWGLI_MODULE_BUILD="${LIBMOWGLI_MODULE_BUILD%x}"
])
;;
*)
AC_MSG_RESULT([posix])
LIBMOWGLI_OS="posix"
ACX_PTHREAD
CPPFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"])
AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
;;
esac
AC_SUBST([LIBMOWGLI_OS])
AC_SUBST([LIBMOWGLI_SHARED_MODULES])
AC_SUBST([LIBMOWGLI_STATIC_MODULES])
AC_SUBST([LIBMOWGLI_MODULE_BUILD])
OPENSSL="no"
AX_CHECK_OPENSSL([
OPENSSL="yes"
AC_DEFINE(HAVE_OPENSSL,[1], [Define to 1 if OpenSSL is available])
])
AS_IF([test x"$OPENSSL" = x"yes"], [
LIBS="$LIBS $OPENSSL_LIBS"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
CPPFLAGS="$CPPFLAGS $OPENSSL_INCLUDES"
])
EXAMPLES_BUILD=""
EXAMPLES="no"
AC_ARG_ENABLE([examples], [AS_HELP_STRING([--enable-examples], [build examples])])
AS_IF([test x"$enable_examples" = x"yes"], [
EXAMPLES_BUILD="examples"
EXAMPLES="yes"
])
AC_SUBST(EXAMPLES_BUILD)
AC_ARG_ENABLE([heap-allocator],
[AS_HELP_STRING([--disable-heap-allocator], [Disable the heap allocator])],
[AS_IF([test x"$enable_heap_allocator" = x"no"], [
AC_DEFINE([DISABLE_HEAP_ALLOCATOR], [1], [Disable the heap allocator])])
], [enable_heap_allocator="yes"])
BUILDSYS_INIT
BUILDSYS_TOUCH_DEPS
AC_CONFIG_FILES([buildsys.mk extra.mk libmowgli-2.pc])
AC_OUTPUT
cat << _EOF_
Configuration:
OpenSSL support: ${OPENSSL}
Heap allocator: ${enable_heap_allocator}
Examples: ${EXAMPLES}
Now type "make" to build, and "make install" to install.
Thank you for using libmowgli.
_EOF_