-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
339 lines (283 loc) · 9.32 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
dnl ------------------------------------------------------------------
dnl Autoconf initialization.
dnl ------------------------------------------------------------------
AC_INIT([otis], [1.0.13])
AC_CONFIG_SRCDIR([src/otis_app.erl])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([ac-aux])
AM_INIT_AUTOMAKE([1.11 -Wall foreign])
AC_PREREQ([2.64])
ECHO=echo
COLORED_ECHO_INIT
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 Options.
dnl ------------------------------------------------------------------
dnl Debugging option.
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],
[turn on debugging [[default=yes]]]),,
enable_debug=yes)
if test "x${enable_debug}" = "xyes"; then
append_to_EMKOPTS "{d, debug}"
fi
AC_ARG_ENABLE([warnings],
AC_HELP_STRING([--enable-warnings],
[treat warnings as errors [[default=no]]]),,
enable_warnings=no)
if test "x${enable_warnings}" = "xyes"; then
append_to_EMKOPTS "warnings_as_errors"
fi
AC_ARG_ENABLE([export_all],
AC_HELP_STRING([--enable-export-all],
[export all Erlang functions [[default=no]]]),,
enable_export_all=no)
if test "x${enable_export_all}" = "xyes"; then
append_to_EMKOPTS "export_all"
fi
dnl Include debug symbols.
append_to_EMKOPTS "debug_info"
dnl Print any warnings.
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 ------------------------------------------------------------------
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 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 dialyzer(1) is used by the testsuite.
AC_ARG_VAR([DIALYZER], [Erlang/OTP discrepancy analyzer [autodetected]])
if test "x${DIALYZER}" = "x"; then
if test "x${with_erlang}" = "x"; then
AC_PATH_PROG([DIALYZER], [dialyzer],,)
else
erl_path="${with_erlang}/bin"
AC_PATH_PROG([DIALYZER], [dialyzer],,
[$erl_path$PATH_SEPARATOR$PATH])
fi
else
AC_MSG_CHECKING([for dialyzer])
AC_MSG_RESULT([$DIALYZER])
fi
if test "x${DIALYZER}" = "x"; then
AC_MSG_WARN([
dialyzer(1) not found. Fill the DIALYZER variable with dialyzer(1) path if
you want it to be run during the testsuite.])
fi
dnl Declare ERL_LIBS as precious.
AC_ARG_VAR([ERL_LIBS], [Erlang/OTP applications search path [none]])
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 R14B02 (ERTS 5.8.3) is required.
AX_COMPARE_VERSION([${ERLANG_ERTS_VER}], [ge], [5.8.3],
[is_erlang_r14b02="yes"],
[is_erlang_r14b02="no"])
if test "x${is_erlang_r14b02}" = "xno"; then
AC_MSG_ERROR([
Erlang R14B02 is required but only Erlang $ERLANG_RELEASE was found!])
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(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
dnl ------------------------------------------------------------------
dnl Erlang applicatons.
dnl ------------------------------------------------------------------
dnl "compiler" install directory.
AC_ARG_WITH([erlang_compiler],
AC_HELP_STRING([--with-erlang-compiler=PREFIX],
[prefix where the "compiler" Erlang application is installed (optional)]),
with_erlang_compiler=${withval%/},
with_erlang_compiler="")
ERL_LIBS_save=$ERL_LIBS
if test "x${with_erlang_compiler}" != "x"; then
ERL_LIBS="${with_erlang_compiler}:${ERL_LIBS}"
fi
export ERL_LIBS
AC_ERLANG_CHECK_LIB([compiler],, [AC_MSG_ERROR([
"compiler" Erlang application not found.
Provide compiler install path with --with-erlang-compiler.])])
ERL_LIBS=$ERL_LIBS_save
export ERL_LIBS
dnl "tools" install directory.
AC_ARG_WITH([erlang_tools],
AC_HELP_STRING([--with-erlang-tools=PREFIX],
[prefix where the "tools" Erlang application is installed (optional)]),
with_erlang_tools=${withval%/},
with_erlang_tools="")
ERL_LIBS_save=$ERL_LIBS
if test "x${with_erlang_tools}" != "x"; then
ERL_LIBS="${with_erlang_tools}:${ERL_LIBS}"
fi
export ERL_LIBS
AC_ERLANG_CHECK_LIB([tools],, [AC_MSG_ERROR([
"tools" Erlang application not found.
Provide tools install path with --with-erlang-tools.])])
ERL_LIBS=$ERL_LIBS_save
export ERL_LIBS
dnl "eunit" install directory.
AC_ARG_WITH([erlang_eunit],
AC_HELP_STRING([--with-erlang-eunit=PREFIX],
[prefix where the "eunit" Erlang application is installed (optional)]),
with_erlang_eunit=${withval%/},
with_erlang_eunit="")
ERL_LIBS_save=$ERL_LIBS
if test "x${with_erlang_eunit}" != "x"; then
ERL_LIBS="${with_erlang_eunit}:${ERL_LIBS}"
fi
export ERL_LIBS
AC_ERLANG_CHECK_LIB([eunit],, [AC_MSG_WARN([
"eunit" Erlang application not found.
Provide eunit install path with --with-erlang-eunit.])])
ERL_LIBS=$ERL_LIBS_save
export ERL_LIBS
dnl "yamerl" install directory.
AC_ARG_WITH([erlang_yamerl],
AC_HELP_STRING([--with-erlang-yamerl=PREFIX],
[prefix where the "yamerl" Erlang application is installed (optional)]),
with_erlang_yamerl=${withval%/},
with_erlang_yamerl="")
ERL_LIBS_save=$ERL_LIBS
if test "x${with_erlang_yamerl}" != "x"; then
ERL_LIBS="${with_erlang_yamerl}:${ERL_LIBS}"
fi
export ERL_LIBS
AC_ERLANG_CHECK_LIB([yamerl],, [AC_MSG_ERROR([
"yamerl" Erlang application not found.
Provide yamerl install path with --with-erlang-yamerl.])])
ERL_LIBS=$ERL_LIBS_save
export ERL_LIBS
dnl "yaws" install directory.
AC_ARG_WITH([erlang_yaws],
AC_HELP_STRING([--with-erlang-yaws=PREFIX],
[prefix where the "yaws" Erlang application is installed (optional)]),
with_erlang_yaws=${withval%/},
with_erlang_yaws="")
ERL_LIBS_save=$ERL_LIBS
if test "x${with_erlang_yaws}" != "x"; then
ERL_LIBS="${with_erlang_yaws}:${ERL_LIBS}"
fi
export ERL_LIBS
AC_ERLANG_CHECK_LIB([yaws],, [AC_MSG_WARN([
"yaws" Erlang application not found.
Provide yaws install path with --with-erlang-yaws.])])
ERL_LIBS=$ERL_LIBS_save
export ERL_LIBS
AM_CONDITIONAL([HAVE_YAWS], [test "x${ERLANG_LIB_DIR_yaws}" != "xnot found"])
dnl ------------------------------------------------------------------
dnl Final substitutions.
dnl ------------------------------------------------------------------
AC_SUBST(EMKOPTS)
AC_SUBST(APP_RELEASE_DATE)
AC_SUBST(APP_DISTSUFFIX)
exp_ERLANG_INSTALL_LIB_DIR_otis=`expand_var ERLANG_INSTALL_LIB_DIR_otis`
AC_SUBST(exp_ERLANG_INSTALL_LIB_DIR_otis)
dnl ------------------------------------------------------------------
dnl Autoconf output.
dnl ------------------------------------------------------------------
echo
AM_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([
include/Makefile
src/Makefile
src/Emakefile.in
ebin/Makefile
ebin/otis.app.in
ebin/otis.appup
priv/Makefile
testsuite/Makefile
testsuite/etest
Makefile
])
AC_CONFIG_FILES([
testsuite/dialyzer
], [chmod +x testsuite/dialyzer])
AC_OUTPUT
dnl --------------------------------------------------
dnl Configuration report
dnl --------------------------------------------------
echo
COLORED_ECHO([ %B== ${PACKAGE_NAME} ${PACKAGE_VERSION}${APP_DISTSUFFIX} ==%b])
echo
COLORED_ECHO([Configuration:])
COLORED_ECHO([ Prefix: ${prefix}])
COLORED_ECHO([ Application dir.: ${exp_ERLANG_INSTALL_LIB_DIR_otis}])
echo
COLORED_ECHO([ Erlang emulator: ${ERL}])
COLORED_ECHO([ Erlang compiler: ${ERLC}])
COLORED_ECHO([ Erlang interpreter: ${ESCRIPT}])
echo
COLORED_ECHO([ Debug: ${enable_debug}])
COLORED_ECHO([ Warnings as errors: ${enable_warnings}])
COLORED_ECHO([ Export all: ${enable_export_all}])
echo