forked from archaelus/exmpp
-
Notifications
You must be signed in to change notification settings - Fork 13
/
configure.ac
443 lines (373 loc) · 12.2 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
dnl ------------------------------------------------------------------
dnl Autoconf initialization.
dnl ------------------------------------------------------------------
AC_INIT([exmpp], m4_esyscmd([(git describe 2>/dev/null || echo v0.9.9) | sed 's/^v//' |
sed 's/-\([0-9]\)-/-0\1-/' | tr -d '\n' || echo 1]),
[[email protected]], [exmpp])
AC_CONFIG_SRCDIR([include/exmpp.hrl])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([ac-aux])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign])
AC_PREREQ([2.60])
AC_REVISION([$Revision$])
dnl ------------------------------------------------------------------
dnl Internal functions for this configure script.
dnl ------------------------------------------------------------------
dnl EMKOPTS is used by Emakefile(s).
append_to_EMKOPTS () {
if test -z "[$]EMKOPTS"; then
EMKOPTS="[$]1"
else
EMKOPTS="[$]{EMKOPTS% }, [$]1"
fi
}
dnl Expand shell variables to have a nice output in the final report.
expand_var () {
local v=`eval echo '$'[$]1`
while test "`echo [$]v | grep [[$]] > /dev/null && echo nok`"; do
v=`eval echo [$]v`
done
echo [$]v
}
dnl ------------------------------------------------------------------
dnl Versioning.
dnl ------------------------------------------------------------------
dnl Release date.
dnl EXMPP_RELEASE_DATE=
dnl Is this a final release?
is_release=0
GITDESC1=`git describe --abbrev=0 || echo 1`
GITDESC2=`git describe --abbrev=4 || echo 1`
if test "${GITDESC1}" = "${GITDESC2}"; then
is_release=1
fi
dnl ------------------------------------------------------------------
dnl Compilater and other tools.
dnl ------------------------------------------------------------------
AC_PROG_CC_STDC
AC_PROG_LD
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_SED
COLORED_ECHO_INIT
dnl ------------------------------------------------------------------
dnl Libtool.
dnl ------------------------------------------------------------------
dnl Hack to skip C++/Fortran tests (stolen from Beep Media Player)
m4_undefine([AC_PROG_CXX])
m4_defun([AC_PROG_CXX],[])
m4_undefine([AC_PROG_F77])
m4_defun([AC_PROG_F77],[])
AM_DISABLE_STATIC
AM_ENABLE_SHARED
AM_PROG_LIBTOOL
dnl ------------------------------------------------------------------
dnl Options.
dnl ------------------------------------------------------------------
dnl Debugging option.
if test $is_release -eq 0; then
default_enable_debug="yes"
else
default_enable_debug="no"
fi
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],
[turn on debugging [[default=auto]]]),,
enable_debug=$default_enable_debug)
if test "x${enable_debug}" = "xyes"; then
dnl AC_DEFINE([DEBUG], [], [Enable debug])
append_to_EMKOPTS "debug_info"
append_to_EMKOPTS "{d, debug}"
else
CPPFLAGS="-DNDEBUG ${CPPFLAGS# }"
fi
dnl Print any warnings.
if test "x$GCC" = "xyes"; then
CFLAGS="${CFLAGS% } -Wall"
fi
append_to_EMKOPTS "report_warnings"
append_to_EMKOPTS "{warn_format, 1}"
append_to_EMKOPTS "warn_export_vars"
append_to_EMKOPTS "warn_shadow_vars"
append_to_EMKOPTS "warn_unused_import"
dnl Treat warnings as errors.
AC_ARG_ENABLE([warnings],
AC_HELP_STRING([--enable-warnings],
[treat warnings as errors [[default=yes]]]),,
enable_warnings="yes")
if test "x${enable_warnings}" = "xyes" -a "x${GCC}" = "xyes"; then
CFLAGS="${CFLAGS% } -Werror"
fi
dnl Compatibility modules.
AC_ARG_ENABLE([compat],
AC_HELP_STRING([--enable-compat],
[build compatibility modules [[default=no]]]),,
enable_compat="no")
if test "x${enable_compat}" = "xyes"; then
COMPAT_MODULES_START=","
COMPAT_MODULES=""
else
COMPAT_MODULES_START=" % Compatibility modules disabled:"
COMPAT_MODULES="%"
fi
AM_CONDITIONAL(BUILD_COMPAT, test "x${enable_compat}" = "xyes")
AC_SUBST(COMPAT_MODULES_START)
AC_SUBST(COMPAT_MODULES)
dnl Documentation.
AC_ARG_ENABLE([documentation],
AC_HELP_STRING([--enable-documentation],
[build documentation [[default=yes]]]),,
enable_documentation="yes")
AM_CONDITIONAL(ENABLE_DOCUMENTATION, test "x${enable_documentation}" = "xyes")
dnl Examples.
AC_ARG_ENABLE([examples],
AC_HELP_STRING([--enable-examples],
[build examples [[default=no]]]),,
enable_examples="no")
AM_CONDITIONAL(ENABLE_EXAMPLES, test "x${enable_examples}" = "xyes")
dnl Internal escaping function to use.
AC_ARG_ENABLE([escaping-using-cdata],
AC_HELP_STRING([--enable-escaping-using-cdata],
[escape XML text node with CDATA sections [[default=off]]]),,
enable_escaping_using_cdata="no")
if test "x${enable_escaping_using_cdata}" = "xyes"; then
append_to_EMKOPTS "{d, 'ESCAPE_USING_CDATA_SECTIONS'}"
fi
dnl ------------------------------------------------------------------
dnl Erlang environment.
dnl ------------------------------------------------------------------
echo
COLORED_ECHO([%BErlang environment%b])
dnl Available flags.
AC_ARG_WITH([erlang],
AC_HELP_STRING([--with-erlang=PREFIX],
[prefix where build machine's Erlang is installed (optional)]),
with_erlang=${withval%/},
with_erlang="")
dnl erl(1) is used to compile Erlang modules.
if test "x${with_erlang}" = "x"; then
AC_ERLANG_PATH_ERL
AC_ERLANG_PATH_ERLC
else
erl_path="${with_erlang}/bin"
AC_ERLANG_PATH_ERL(, [$erl_path$PATH_SEPARATOR$PATH])
AC_ERLANG_PATH_ERLC(, [$erl_path$PATH_SEPARATOR$PATH])
fi
if test "x${ERL}" = "x"; then
AC_MSG_ERROR([
Erlang not found. Fill the ERL variable with erl(1) path or provide
Erlang prefix with --with-erlang.])
fi
dnl escript(1) is used by the testsuite.
AC_ARG_VAR([ESCRIPT], [Erlang/OTP interpreter command [autodetected]])
if test "x${ESCRIPT}" = "x"; then
if test "x${with_erlang}" = "x"; then
AC_PATH_PROG([ESCRIPT], [escript],,)
else
erl_path="${with_erlang}/bin"
AC_PATH_PROG([ESCRIPT], [escript],,
[$erl_path$PATH_SEPARATOR$PATH])
fi
else
AC_MSG_CHECKING([for escript])
AC_MSG_RESULT([$ESCRIPT])
fi
if test "x${ESCRIPT}" = "x"; then
AC_MSG_WARN([
escript(1) not found. Fill the ESCRIPT variable with escript(1) path if
you want to use the testsuite.])
fi
dnl Get Erlang $ROOT dir and lib dir.
AC_ERLANG_SUBST_ROOT_DIR
AC_ERLANG_SUBST_LIB_DIR
dnl Get ERTS version.
ERLANG_CHECK_ERTS
ERLANG_CHECK_RELEASE
dnl Erlang R12B-5 (ERTS 5.6.5) is required to build Exmpp.
AX_COMPARE_VERSION([${ERLANG_ERTS_VER}], [ge], [5.6.5],
[is_erlang_r12b="yes"],
[is_erlang_r12b="no"])
if test "x${is_erlang_r12b}" = "xno"; then
AC_MSG_ERROR([
Erlang R12B-5 is required to build Exmpp but only Erlang $ERLANG_RELEASE was found!])
fi
dnl Check for Erlang applications.
dnl Check for erl_interface (used by port drivers).
AC_ERLANG_CHECK_LIB([erl_interface],,
[AC_MSG_ERROR([erl_interface was not found!])])
dnl Check for EUnit (used for the testsuite).
if test "x${ESCRIPT}" = "x"; then
AC_ERLANG_CHECK_LIB([eunit],,)
fi
dnl Determine directories for installation.
if test "x${prefix}" = "xNONE"; then
dnl Inside Erlang lib directory.
ERLANG_INSTALL_LIB_DIR="${ERLANG_LIB_DIR}"
else
dnl Under $prefix
ERLANG_INSTALL_LIB_DIR="${prefix}"
fi
AC_ERLANG_SUBST_INSTALL_LIB_DIR
AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR(exmpp, ${VERSION})
dnl SMP support.
dnl
dnl Support is enabled by default for Erlang R12B and later ; disabled
dnl otherwise.
AC_MSG_CHECKING([for SMP support])
AC_ARG_ENABLE([smp-support],
AC_HELP_STRING([--enable-smp-support],
[enable SMP support [[default=yes]]]),,
enable_smp_support="yes")
AM_CONDITIONAL(ENABLE_SMP_SUPPORT, test "x${enable_smp_support}" = "xyes")
if test "x${enable_smp_support}" = "xyes"; then
AC_DEFINE(SMP_SUPPORT, [], [SMP support enabled in port drivers.])
AC_DEFINE(USE_RWLOCK, [], [Use rwlocks.])
AC_DEFINE(_REENTRANT, [], [_REENTRANT])
AC_MSG_RESULT([yes (Erlang $ERLANG_RELEASE)])
else
AC_MSG_RESULT([no (disabled by user)])
fi
dnl Do we have all the tools for the testsuite to be used.
if test "x${ERLANG_LIB_DIR_eunit}" != "xnot found" -a "x${ESCRIPT}" != "x"; then
enable_testsuite="yes"
else
enable_testsuite="no"
fi
AM_CONDITIONAL([ENABLE_TESTSUITE], [test "x${enable_testsuite}" = "xyes"])
dnl ------------------------------------------------------------------
dnl Dependencies.
dnl ------------------------------------------------------------------
echo
COLORED_ECHO([%BXML parsers dependencies%b])
dnl Expat port driver.
EXMPP_EXPAT(build_with_expat="yes", build_with_expat="no")
AM_CONDITIONAL(WITH_EXPAT, test "x${build_with_expat}" = "xyes")
if test "x${build_with_expat}" = "xyes"; then
append_to_EMKOPTS "{d, 'HAVE_EXPAT'}"
fi
dnl LibXML2 port driver.
PKG_CHECK_MODULES([LIBXML2], [libxml-2.0],
build_with_libxml2="yes", build_with_libxml2="no")
AM_CONDITIONAL(WITH_LIBXML2, test "x${build_with_libxml2}" = "xyes")
if test "x${build_with_libxml2}" = "xyes"; then
append_to_EMKOPTS "{d, 'HAVE_LIBXML2'}"
fi
echo
COLORED_ECHO([%BTLS engines dependencies%b])
dnl OpenSSL TLS port driver.
EXMPP_OPENSSL(build_with_openssl="yes", build_with_openssl="no")
AM_CONDITIONAL(WITH_OPENSSL, test "x${build_with_openssl}" = "xyes")
if test "x${build_with_openssl}" = "xyes"; then
append_to_EMKOPTS "{d, 'HAVE_OPENSSL'}"
fi
echo
COLORED_ECHO([%BCompression engines dependencies%b])
dnl Zlib compression port driver.
EXMPP_ZLIB(build_with_zlib="yes", build_with_zlib="no")
AM_CONDITIONAL(WITH_ZLIB, test "x${build_with_zlib}" = "xyes")
if test "x${build_with_zlib}" = "xyes"; then
append_to_EMKOPTS "{d, 'HAVE_ZLIB'}"
fi
dnl ------------------------------------------------------------------
dnl Detect Operating System.
dnl ------------------------------------------------------------------
echo
COLORED_ECHO([%BDetect Operating System%b])
AC_CANONICAL_SYSTEM
#AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$target")
#AC_SUBST(target_os)
case "$target_os" in
*darwin10*)
echo "Target OS is: Darwin10 (Mac OS X)"
AC_LANG(Erlang)
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([],[dnl
halt(case erlang:system_info(wordsize) of
8 -> 0; 4 -> 1 end)])],
[AC_MSG_NOTICE(found 64-bit Erlang)
CBIT=-m64],
[AC_MSG_NOTICE(found 32-bit Erlang)
CBIT=-m32])
;;
*)
echo "Target OS is: '$target_os'"
CBIT=""
;;
esac
CFLAGS="$CFLAGS $CBIT"
LD_SHARED="$LD_SHARED $CBIT"
echo "CBIT = '$CBIT'"
echo "CFLAGS = '$CFLAGS'"
echo "LD_SHARED = '$LD_SHARED'"
dnl ------------------------------------------------------------------
dnl Finale substitutions.
dnl ------------------------------------------------------------------
CPPFLAGS="${CPPFLAGS# }"
CFLAGS="${CFLAGS# }"
LDFLAGS="${LDFLAGS# }"
CPPFLAGS="${CPPFLAGS% }"
CFLAGS="${CFLAGS% }"
LDFLAGS="${LDFLAGS% }"
AC_SUBST(EMKOPTS)
AC_SUBST(EXMPP_RELEASE_DATE)
AC_SUBST(EXMPP_BUILD_ARCH)
AC_SUBST(EXMPP_HOST_ARCH)
exp_ERLANG_INSTALL_LIB_DIR_exmpp=`expand_var ERLANG_INSTALL_LIB_DIR_exmpp`
AC_SUBST(exp_ERLANG_INSTALL_LIB_DIR_exmpp)
AC_SUBST(ERL_DRIVER_LDFLAGS)
dnl ------------------------------------------------------------------
dnl Autoconf output.
dnl ------------------------------------------------------------------
echo
AM_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([
c_src/Makefile
include/Makefile
include/internal/Makefile
src/Makefile
src/Emakefile
ebin/Makefile
ebin/exmpp.app
ebin/exmpp.appup
doc/Makefile
testsuite/Makefile
examples/Makefile
examples/Emakefile
Makefile
])
AC_CONFIG_FILES([
testsuite/etest
], [chmod +x testsuite/etest])
AC_OUTPUT
dnl --------------------------------------------------
dnl Configuration report
dnl --------------------------------------------------
echo
COLORED_ECHO([ %B== exmpp ${PACKAGE_VERSION} ==%b])
echo
COLORED_ECHO([Configuration:])
COLORED_ECHO([ Prefix: ${prefix}])
COLORED_ECHO([ Application dir.: ${exp_ERLANG_INSTALL_LIB_DIR_exmpp}])
echo
COLORED_ECHO([ C compiler: ${CC} ${CFLAGS}])
COLORED_ECHO([ Erlang emulator: ${ERL}])
COLORED_ECHO([ Erlang compiler: ${ERLC}])
COLORED_ECHO([ Erlang interpreter: ${ESCRIPT}])
echo
COLORED_ECHO([ Debug/warnings: ${enable_debug}/${enable_warnings}])
COLORED_ECHO([ Compat modules: ${enable_compat}])
COLORED_ECHO([ Documentation: ${enable_documentation}])
COLORED_ECHO([ Testsuite: ${enable_testsuite}])
COLORED_ECHO([ Examples: ${enable_examples}])
echo
COLORED_ECHO([ XML parsers:])
COLORED_ECHO([ . Expat: ${build_with_expat}])
COLORED_ECHO([ . LibXML2: ${build_with_libxml2}])
echo
COLORED_ECHO([ TLS engines:])
COLORED_ECHO([ . OpenSSL: ${build_with_openssl}])
echo
COLORED_ECHO([ Compression engines:])
COLORED_ECHO([ . Zlib: ${build_with_zlib}])
echo