forked from yarrick/iodine
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfigure.ac
215 lines (168 loc) · 6.07 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# Process this file with autoconf to produce a configure script.
# Prologue
AC_PREREQ([2.69])
AC_INIT([iodine],[0.8.0],[[email protected]],[],[http://dev.kryo.se/iodine/])
AC_CONFIG_SRCDIR([src/iodine.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([autotools])
AC_CONFIG_AUX_DIR([autotools])
AM_INIT_AUTOMAKE([subdir-objects foreign -Wall])
# Misc
# Define OS to upcased "uname --kernel-name", i.e., LINUX, DARWIN, etc.
# Used by Makefile.am as cpp symbol to define.
# We use autotools canonical designation to allow cross compilation.
# It would be reasonable to, at some point, update the C sources to
# use these more canonical designations.
# But for now, we must adjust some of them.
AC_MSG_CHECKING([environment to compile for])
AC_CANONICAL_HOST
# No need to adjust these: FREEBSD, NETBSD, OPENBSD, BEOS
AS_CASE([${host_os}],
[linux-gnu], [OS=LINUX],
[mingw32], [OS=WINDOWS32],
[macos], [OS=DARWIN],
[linux-android], [OS=ANDROID],
[OS="$(echo ${host_os}|tr "a-z" "A-Z")"])
uname_os="$(uname | tr "a-z" "A-Z")"
# Avoid, e.g., OS=DARWIN15.6.0
AS_CASE([${uname_os}],
[DARWIN], [OS=DARWIN])
AC_MSG_NOTICE([host_os: ${host_os}])
AC_MSG_NOTICE([uname_os: ${uname_os}])
AC_MSG_NOTICE([adjusted OS: ${OS}])
AC_SUBST([OS])
AS_CASE([${OS}],
[WINDOWS32],
AC_DEFINE([WINVER],[0x0501],
[Define appropriately on MS Windows 32]))
# The AC_SUBST for GITREVISION is used only in legacy stanza; remove
# when unused in Makefile.am, leaving only the config.h #define.
AC_SUBST([GITREVISION],[$(git describe --tags --always --dirty || echo not-in-git)])
AC_DEFINE_UNQUOTED([GITREVISION],["${GITREVISION}"],
[Precise git commit checked out when building])
# Checks for programs
AC_MSG_CHECKING([whether configure should try to set CFLAGS])
if test "x${CFLAGS+set}" = xset; then
enable_cflags_setting=no
else
enable_cflags_setting=yes
CFLAGS_ORIG="$CFLAGS"
fi
AC_MSG_RESULT($enable_cflags_setting)
AC_PROG_CC
AC_PROG_CC_STDC
AS_IF([test "x${ac_cv_prog_cc_stdc}" = xno],
[AC_MSG_WARN([Unable to engage Standard C (C99) option])],)
# This is to avoid
# error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
# whose definition is guarded by _GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS
AX_CFLAGS_WARN_ALL
AC_PROG_INSTALL
# Restore CFLAGS (preserve debug flags)
test "x$enable_cflags_setting" = xyes && CFLAGS="$CFLAGS_ORIG"
# Process options
AC_ARG_ENABLE([systemd],
[AS_HELP_STRING([--enable-systemd],
[enable systemd support @<:@default=check@:>@])],,
[enable_systemd=check])
AC_ARG_ENABLE([selinux],
[AS_HELP_STRING([--enable-selinux],
[enable selinux support @<:@default=check@:>@])],,
[enable_selinux=check])
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[enable debugging, default: no]),
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],
[debug=false])
AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
# Checks for libraries
# Unclear why pthread is needed.
# Uncomment and replace ? by called procedure requiring -lpthread.
#AC_SEARCH_LIBS([?], [pthread])
AC_SEARCH_LIBS([uncompress], [z])
# Enable systemd per option by setting HAVE_SYSTEMD
AS_CASE([${enable_systemd}],
[yes|check],
[AC_MSG_CHECKING([systemd])
AC_SEARCH_LIBS([sd_listen_fds], [systemd-daemon])
AC_CHECK_FUNC([sd_listen_fds],
[AC_MSG_RESULT([enabled: systemd])
AC_DEFINE([HAVE_SYSTEMD],[1],
[Define to 1 to enable systemd support])],
AS_CASE([${enable_systemd}],
[yes],
AC_MSG_ERROR([systemd support not available]),
AC_MSG_RESULT([disabled: systemd])))],
[no],,
[AC_MSG_ERROR([invalid argument, --enable-systemd=${enable_systemd}])])
# Enable selinux per option by setting HAVE_SETCON
AS_CASE([${enable_selinux}],
[yes|check],
[AC_SEARCH_LIBS([setcon], [selinux])
AC_CHECK_FUNCS([setcon],
AC_MSG_RESULT([enabled: selinux]),
AS_CASE([${enable_selinux}],
[yes],
AC_MSG_ERROR([selinux support not available]),
[check],
AC_MSG_RESULT([disabled: selinux])))],
[no],
AC_MSG_RESULT([disabled: selinux]),
[AC_MSG_ERROR([invalid argument, --enable-selinux=${enable_selinux}])])
# The check library is used for the unit testing. Not bothering to
# implement an --enable-tests option, as they are only run by "make
# check" so there is no user-level difference. If the unit tests
# won't even *compile* there is probably a better solution than just
# turning them off, and build time is minimal.
PKG_CHECK_MODULES([CHECK], [check],
AC_MSG_RESULT([enabled: unit testing]),
AC_MSG_RESULT([disabled: unit testing]))
AM_CONDITIONAL([HAVE_CHECK],[test -z "${CHECK_PKG_ERRORS}"])
# For each commented AC_SEARCH_LIBS below, uncomment and replace ? by
# called procedure provided only by that library on the platform(s) in
# question.
# for SunOS / solaris:
#AC_SEARCH_LIBS([?], [nsl])
# for BeOS:
#AC_SEARCH_LIBS([?], [bind])
#AC_SEARCH_LIBS([?], [bsd])
# for SunOS / solaris / BeOS:
#AC_SEARCH_LIBS([?], [socket])
# for Haiku:
#AC_SEARCH_LIBS([?], [network])
# for MS windows32:
#AC_SEARCH_LIBS([?], [ws2_32])
#AC_SEARCH_LIBS([?], [iphlpapi])
# Checks for headers
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h systemd/sd-daemon.h selinux/selinux.h])
# Checks for typedefs, structures, and compiler characteristics
AC_CHECK_TYPES([socklen_t],,
AC_DEFINE([socklen_t],[int],
[define to int if type socklen_t not found]),
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_CHECK_FUNCS([alarm dup2 inet_ntoa memset select socket strcasecmp strchr strdup strerror strrchr strstr bzero strtol gettimeofday])
# Epilogue
AC_CONFIG_FILES([Makefile])
AC_OUTPUT