-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure.ac
316 lines (259 loc) · 9.89 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
dnl $Id$
AC_PREREQ(2.63)
m4_include([branch_version.m4])
AC_INIT([mtlk], [MTLK_BRANCH_VERSION], [])
AC_CONFIG_SRCDIR([mtlk_version])
AC_CONFIG_HEADER([config.h])
AC_CANONICAL_HOST
AC_MSG_CHECKING([for toolchain to use])
AC_ARG_WITH(app-toolchain,
AS_HELP_STRING([--with-app-toolchain],
[use specified aplication toolchain instead of default one]),
[override_app_toolchain=$withval],
[unset override_app_toolchain])
AS_IF([test "x$override_app_toolchain" = x],
[AC_MSG_RESULT(default)],
[AC_MSG_RESULT($override_app_toolchain)])
AC_MSG_CHECKING([for kernel to use])
AC_ARG_WITH(kernel,
AS_HELP_STRING([--with-kernel],
[use specified kernel instead of default one]),
[override_kernel=$withval],
[unset override_kernel])
AS_IF([test "x$override_kernel" = x],
[AC_MSG_RESULT(default)],
[AC_MSG_RESULT($override_kernel)])
AC_MSG_CHECKING([for kernel compiler prefix to use])
AC_ARG_WITH(kernel-cross-compile,
AS_HELP_STRING([--with-kernel-cross-compile],
[use specified kernel compiler prefix instead of default one]),
[override_kernel_cross_compile=$withval],
[unset override_kernel_cross_compile])
AS_IF([test "x$override_kernel_cross_compile" = x],
[AC_MSG_RESULT(default)],
[AC_MSG_RESULT($override_kernel_cross_compile)])
. $(pwd)/.config
AC_MSG_CHECKING([for environment configuration file])
AC_MSG_RESULT([${CONFIG_ENVIRONMENT_NAME}])
AC_MSG_CHECKING([for rflib])
AS_IF([test "x${CONFIG_USE_PREBUILT_RFLIB}" = xy],
[
__rflib_name="mtlk_rflib.a"
AS_IF([test -f "${CONFIG_RFLIB_PATH}/${__rflib_name}"],
[
rf_library_place="$PWD/wireless/driver/rflib"
mkdir -p "${rf_library_place}" && \
cp -s "${CONFIG_RFLIB_PATH}/${__rflib_name}" "${rf_library_place}/${__rflib_name}"
AS_IF([test -f "${rf_library_place}/${__rflib_name}"],
[
AC_MSG_RESULT([use prebuilt RF library '${CONFIG_RFLIB_PATH}/${__rflib_name}'])
],[
AC_MSG_ERROR([Can not prepare RF library '${rf_library_place}/${__rflib_name}'])
])
],[
AC_MSG_ERROR([Missed prebuilt RF library '${CONFIG_RFLIB_PATH}/${__rflib_name}'])
])
],[
AC_MSG_RESULT([use runtime build])
])
AM_CONDITIONAL([USE_PREBUILT_RFLIB],
[test "x${CONFIG_USE_PREBUILT_RFLIB}" = xy])
get_toolchain_path()
{
echo ${override_app_toolchain:-$DEFAULT_TOOLCHAIN_PATH}
}
get_kernel_dir()
{
echo ${override_kernel:-$DEFAULT_KERNEL_DIR}
}
get_kernel_cross_compile()
{
echo ${override_kernel_cross_compile:-$DEFAULT_KERNEL_CROSS_COMPILE}
}
. ${srcdir}/support/${CONFIG_ENVIRONMENT_NAME}.env
AC_SUBST(CUSTOM_APP_ENV_INFO)
AC_SUBST([APP_TOOLCHAIN_PATH], [$(get_toolchain_path)])
kernel_dir=$(get_kernel_dir)
# MTLK_TOOLCHAIN_COMPONENT_PATH(COMPONENT-NAME, VAR-NAME)
# --------------------------------------
AC_DEFUN([MTLK_TOOLCHAIN_COMPONENT_PATH],
[{ AC_MSG_CHECKING([for toolchain [$1]])
AS_IF([test x"${[$2]}" = x""],
[AS_IF([test x"`echo $CC | grep 'gcc$'`" != x""],
[[$2]=`echo $CC | sed -e's/gcc$/[$1]/g'`], [])
AS_IF([test -x "${[$2]}"],
[], [[$2]=""])],
[])
AC_MSG_RESULT([${[$2]}]);
}])
MTLK_TOOLCHAIN_COMPONENT_PATH(strip, STRIP)
MTLK_TOOLCHAIN_COMPONENT_PATH(ranlib, RANLIB)
AC_SUBST([CONFIG_STATUS_DEPENDENCIES], [`readlink -f ${srcdir}/support/${CONFIG_ENVIRONMENT_NAME}.env`])
ENV_CFLAGS="$CFLAGS"
ENV_CPPFLAGS="$CPPFLAGS"
ENV_CXXFLAGS="$CXXFLAGS"
ENV_LDFLAGS="$LDFLAGS"
# MTLK_CONDITIONAL_COMPONENT(CONDITIONAL-VAR, CONFIG-VAR, COMPONENT-NAME)
# --------------------------------------
AC_DEFUN([MTLK_CONDITIONAL_COMPONENT],
[{ AM_CONDITIONAL([$1], [test "x${[$2]}" = xy ])
AC_MSG_CHECKING([whether to build [$3]])
AS_IF([test x${[$2]} = xy], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
}])
MTLK_CONDITIONAL_COMPONENT([BUILD_DRIVER], [CONFIG_LIN_DRV], [the wireless driver])
AC_MSG_CHECKING([for supported hardware set])
supported_hw_list=`set | grep CONFIG_LINDRV_HW_.\*=y | \
sed -e's/CONFIG_LINDRV_HW_//g' -e's/=y//g' | \
awk '{printf $0 " "}'`
AM_CONDITIONAL([AT_LEAST_ONE_HW_SUPPORTED],
[test "x$supported_hw_list" != x])
AM_COND_IF([BUILD_DRIVER],
[AM_COND_IF([AT_LEAST_ONE_HW_SUPPORTED],
[AC_MSG_RESULT([$supported_hw_list])],
[AC_MSG_ERROR([At least one hardware type must be supported by Linux driver])]
)
]
)
MTLK_CONDITIONAL_COMPONENT([BUILD_MTTOOLS], [CONFIG_LIN_MTTOOLS], [the MTTools])
MTLK_CONDITIONAL_COMPONENT([BUILD_RTLOGGER], [CONFIG_LIN_RTLOG_COMPONENTS],
[remote logging tools])
MTLK_CONDITIONAL_COMPONENT([BUILD_DUT], [CONFIG_LIN_DUT],
[the DUT components])
MTLK_CONDITIONAL_COMPONENT([BUILD_HELPER_TOOLS], [CONFIG_LIN_HELPER_TOOLS],
[helper tools])
AM_CONDITIONAL([BUILD_WIRELESS_SHARED],
[test "x${CONFIG_LIN_RTLOG_COMPONENTS}" = xy || \
test "x${CONFIG_LIN_MTTOOLS}" = xy \
])
AM_CONDITIONAL([BUILD_WIRELESS_DATA],
[test "x${CONFIG_LIN_DRV}" = xy || \
test "x${CONFIG_LIN_MTTOOLS}" = xy \
])
AC_SUBST(cxx_ldadd)
# MTLK_CHECK_BUILDER_COMPONENT(COMPONENT-PATH, COMPONENT-NAME, [ACTION-IF-EMPTY=AC_MSG_ERROR(...)])
# --------------------------------------
AC_DEFUN([MTLK_CHECK_BUILDER_COMPONENT],
[{ AC_MSG_CHECKING([for $2])
AS_IF([test x[$1] = x],
[
AC_MSG_RESULT([not specified])
m4_default([$3], [AC_MSG_ERROR([Path to $2 not specified])])
],
[
AS_IF([test -d [$1]],
[
_mtlk_processed_path=$1
AC_MSG_RESULT([${_mtlk_processed_path}])
],
[
AC_MSG_RESULT([no])
_mtlk_processed_path=$1
AC_MSG_ERROR([$2 (${_mtlk_processed_path}) does not exist])
])
])
}])
MTLK_CHECK_BUILDER_COMPONENT(${kernel_dir}, [target kernel package])
AC_MSG_CHECKING([for target kernel compiler])
AS_IF([which $(get_kernel_cross_compile)gcc >/dev/null],
[
target_kernel_gcc=`which $(get_kernel_cross_compile)gcc`
AC_MSG_RESULT([${target_kernel_gcc}])
],
[AC_MSG_ERROR([Target kernel compiler not found])])
AC_SUBST(kernel_dir)
AC_SUBST(kernel_cross_compile, $(get_kernel_cross_compile))
AC_SUBST(kernel_cflags)
AS_IF([test "x$kernel_arch" != "x"],
[kernel_arch_var="ARCH=$kernel_arch"],
[kernel_arch_var=""])
AC_SUBST(kernel_arch_var)
AC_SUBST(CUSTOM_DRV_ENV_INFO)
env_lib_path="$LD_LIBRARY_PATH"
AC_SUBST(env_lib_path)
export LD_LIBRARY_PATH
AM_INIT_AUTOMAKE([dist-bzip2 foreign])
dnl For some reason configure script uses $ECHO variable
dnl which is empty. Probably bug in autoconf
AC_PATH_PROG([ECHO], [echo], [echo])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_CHECK_PROG(HAVE_READLINK, [readlink], [yes], [no])
AS_IF([test x${HAVE_READLINK} != xyes],
[AC_MSG_ERROR([readlink tool must be present and accessible via PATH variable])],
[])
CC="`cd $srcdir; pwd`/support/mtlkfront.sh $CC"
CXX="`cd $srcdir; pwd`/support/mtlkfront.sh $CXX"
#These variables will be used by mtlk_front.sh in following tests
export abs_builddir=$PWD
export abs_top_srcdir=`cd $srcdir; pwd`
export abs_tools_srcdir=$abs_top_srcdir/tools
AC_MSG_CHECKING([whether compiler frontend works for C programs])
AC_TRY_LINK(, [], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether compiler frontend works for C++ programs])
AC_TRY_LINK(, [], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
AC_LANG_POP()
BUILDER_CC="`cd $srcdir; pwd`/support/mtlkfront.sh gcc"
BUILDER_CXX="`cd $srcdir; pwd`/support/mtlkfront.sh g++"
AC_SUBST(BUILDER_CC)
AC_SUBST(BUILDER_CXX)
cc_pic=-fPIC
AC_SUBST(cc_pic)
cc_shared=-shared
AC_SUBST(cc_shared)
ld_group_start=-Wl,--start-group
AC_SUBST(ld_group_start)
ld_group_end=-Wl,--end-group
AC_SUBST(ld_group_end)
dnl Does this compiler have built-in functions for atomic memory access?
AC_MSG_CHECKING([whether platform supports built-in atomics])
AC_TRY_LINK(,
[
int variable = 1;
return (__sync_add_and_fetch(&variable, 1)
&& __sync_sub_and_fetch(&variable, 1)
&& __sync_lock_test_and_set(&variable, 1)) ? 1 : 0;
],
[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports builin atomics])
],
[
AC_MSG_RESULT([no])
])
AC_DEFINE(LINUX, 1, [Define as 1 to tell that we are building on Linux])
AC_DEFINE(MTLK_COPYRIGHT, ["Copyright(c) 2012 Lantiq Deutschland GmbH"],
[Standard copyright string])
CFLAGS="$ENV_CFLAGS"
CPPFLAGS="$ENV_CPPFLAGS"
CXXFLAGS="$ENV_CXXFLAGS"
LDFLAGS="$ENV_LDFLAGS"
AC_CONFIG_FILES([Makefile
tools/Makefile
tools/dutserver/Makefile
tools/dutserver/linux/Makefile
tools/shared/Makefile
tools/shared/3rd_party/Makefile
tools/shared/3rd_party/iniparser/Makefile
tools/shared/linux/Makefile
wireless/Makefile
wireless/shared/Makefile
wireless/driver/Makefile
wireless/driver/rflib/Makefile
tools/rtlogger/Makefile
tools/rtlogger/shared/Makefile
tools/rtlogger/logserver/Makefile
tools/rtlogger/logserver/linux/Makefile
tools/rtlogger/logcnv/Makefile
tools/rtlogger/prebuilt/Makefile
tools/mtlkroot/Makefile
tools/mttools/Makefile
tools/mttools/shared/Makefile
tools/mttools/drvhlpr/Makefile
tools/mttools/mtdump/Makefile
tools/mttools/mtlk_cli/Makefile
tools/mttools/mtlk_cli_dbg_srv/Makefile
tools/BCLSockServer/Makefile
])
AC_OUTPUT