Add missing #include for some headers
[wave300.git] / configure.ac
blob916fa05d4c05a921ef6d3cc164e7bfa4e2e91777
1 dnl $Id$
3 AC_PREREQ(2.63)
4 m4_include([branch_version.m4])
5 AC_INIT([mtlk], [MTLK_BRANCH_VERSION], [])
6 AC_CONFIG_SRCDIR([mtlk_version])
7 AC_CONFIG_HEADER([config.h])
9 AC_CANONICAL_HOST
11 AC_MSG_CHECKING([for toolchain to use])
12 AC_ARG_WITH(app-toolchain,
13             AS_HELP_STRING([--with-app-toolchain],
14                            [use specified aplication toolchain instead of default one]),
15             [override_app_toolchain=$withval],
16             [unset override_app_toolchain])
17 AS_IF([test "x$override_app_toolchain" = x],
18       [AC_MSG_RESULT(default)],
19       [AC_MSG_RESULT($override_app_toolchain)])
22 AC_MSG_CHECKING([for kernel to use])
23 AC_ARG_WITH(kernel,
24             AS_HELP_STRING([--with-kernel],
25                            [use specified kernel instead of default one]),
26             [override_kernel=$withval],
27             [unset override_kernel])
28 AS_IF([test "x$override_kernel" = x],
29       [AC_MSG_RESULT(default)],
30       [AC_MSG_RESULT($override_kernel)])
32 AC_MSG_CHECKING([for kernel compiler prefix to use])
33 AC_ARG_WITH(kernel-cross-compile,
34             AS_HELP_STRING([--with-kernel-cross-compile],
35                            [use specified kernel compiler prefix instead of default one]),
36             [override_kernel_cross_compile=$withval],
37             [unset override_kernel_cross_compile])
38 AS_IF([test "x$override_kernel_cross_compile" = x],
39       [AC_MSG_RESULT(default)],
40       [AC_MSG_RESULT($override_kernel_cross_compile)])
42 . $(pwd)/.config
44 AC_MSG_CHECKING([for environment configuration file])
45 AC_MSG_RESULT([${CONFIG_ENVIRONMENT_NAME}])
47 AC_MSG_CHECKING([for rflib])
48 AS_IF([test "x${CONFIG_USE_PREBUILT_RFLIB}" = xy],
50         __rflib_name="mtlk_rflib.a"
51         AS_IF([test -f "${CONFIG_RFLIB_PATH}/${__rflib_name}"],
52         [
53                 rf_library_place="$PWD/wireless/driver/rflib"
55                 mkdir -p "${rf_library_place}" && \
56                 cp -s "${CONFIG_RFLIB_PATH}/${__rflib_name}" "${rf_library_place}/${__rflib_name}"
58                 AS_IF([test -f "${rf_library_place}/${__rflib_name}"],
59                 [
60                         AC_MSG_RESULT([use prebuilt RF library '${CONFIG_RFLIB_PATH}/${__rflib_name}'])
61                 ],[
62                         AC_MSG_ERROR([Can not prepare RF library '${rf_library_place}/${__rflib_name}'])
63                 ])
64         ],[
65                 AC_MSG_ERROR([Missed prebuilt RF library '${CONFIG_RFLIB_PATH}/${__rflib_name}'])
66         ])
67 ],[
68         AC_MSG_RESULT([use runtime build])
71 AM_CONDITIONAL([USE_PREBUILT_RFLIB],
72                [test "x${CONFIG_USE_PREBUILT_RFLIB}" = xy])
75 get_toolchain_path()
77   echo ${override_app_toolchain:-$DEFAULT_TOOLCHAIN_PATH}
80 get_kernel_dir()
82   echo ${override_kernel:-$DEFAULT_KERNEL_DIR}
85 get_kernel_cross_compile()
87   echo ${override_kernel_cross_compile:-$DEFAULT_KERNEL_CROSS_COMPILE}
90 . ${srcdir}/support/${CONFIG_ENVIRONMENT_NAME}.env
92 AC_SUBST(CUSTOM_APP_ENV_INFO)
93 AC_SUBST([APP_TOOLCHAIN_PATH], [$(get_toolchain_path)])
95 kernel_dir=$(get_kernel_dir)
97 # MTLK_TOOLCHAIN_COMPONENT_PATH(COMPONENT-NAME, VAR-NAME)
98 # --------------------------------------
99 AC_DEFUN([MTLK_TOOLCHAIN_COMPONENT_PATH],
100          [{ AC_MSG_CHECKING([for toolchain [$1]])
101             AS_IF([test x"${[$2]}" = x""],
102                   [AS_IF([test x"`echo $CC | grep 'gcc$'`" != x""],
103                           [[$2]=`echo $CC | sed -e's/gcc$/[$1]/g'`], [])
104                    AS_IF([test -x "${[$2]}"],
105                          [], [[$2]=""])],
106                   [])
107             AC_MSG_RESULT([${[$2]}]);
108           }])
110 MTLK_TOOLCHAIN_COMPONENT_PATH(strip, STRIP)
111 MTLK_TOOLCHAIN_COMPONENT_PATH(ranlib, RANLIB)
113 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], [`readlink -f ${srcdir}/support/${CONFIG_ENVIRONMENT_NAME}.env`])
115 ENV_CFLAGS="$CFLAGS"
116 ENV_CPPFLAGS="$CPPFLAGS"
117 ENV_CXXFLAGS="$CXXFLAGS"
118 ENV_LDFLAGS="$LDFLAGS"
120 # MTLK_CONDITIONAL_COMPONENT(CONDITIONAL-VAR, CONFIG-VAR, COMPONENT-NAME)
121 # --------------------------------------
122 AC_DEFUN([MTLK_CONDITIONAL_COMPONENT],
123          [{ AM_CONDITIONAL([$1], [test "x${[$2]}" = xy ])
124             AC_MSG_CHECKING([whether to build [$3]])
125             AS_IF([test x${[$2]} = xy], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
126           }])
128 MTLK_CONDITIONAL_COMPONENT([BUILD_DRIVER], [CONFIG_LIN_DRV], [the wireless driver])
130 AC_MSG_CHECKING([for supported hardware set])
131 supported_hw_list=`set | grep CONFIG_LINDRV_HW_.\*=y | \
132                          sed -e's/CONFIG_LINDRV_HW_//g' -e's/=y//g' | \
133                          awk '{printf $0 " "}'`
134 AM_CONDITIONAL([AT_LEAST_ONE_HW_SUPPORTED],
135                [test "x$supported_hw_list" != x])
136 AM_COND_IF([BUILD_DRIVER],
137            [AM_COND_IF([AT_LEAST_ONE_HW_SUPPORTED],
138                        [AC_MSG_RESULT([$supported_hw_list])],
139                        [AC_MSG_ERROR([At least one hardware type must be supported by Linux driver])]
140                       )
141            ]
142           )
144 MTLK_CONDITIONAL_COMPONENT([BUILD_MTTOOLS], [CONFIG_LIN_MTTOOLS], [the MTTools])
146 MTLK_CONDITIONAL_COMPONENT([BUILD_RTLOGGER], [CONFIG_LIN_RTLOG_COMPONENTS],
147                            [remote logging tools])
149 MTLK_CONDITIONAL_COMPONENT([BUILD_DUT], [CONFIG_LIN_DUT],
150                            [the DUT components])
152 MTLK_CONDITIONAL_COMPONENT([BUILD_HELPER_TOOLS], [CONFIG_LIN_HELPER_TOOLS],
153                            [helper tools])
155 AM_CONDITIONAL([BUILD_WIRELESS_SHARED],
156                [test "x${CONFIG_LIN_RTLOG_COMPONENTS}" = xy || \
157                 test "x${CONFIG_LIN_MTTOOLS}" = xy \
158               ])
160 AM_CONDITIONAL([BUILD_WIRELESS_DATA],
161                [test "x${CONFIG_LIN_DRV}" = xy || \
162                 test "x${CONFIG_LIN_MTTOOLS}" = xy \
163               ])
165 AC_SUBST(cxx_ldadd)
167 # MTLK_CHECK_BUILDER_COMPONENT(COMPONENT-PATH, COMPONENT-NAME, [ACTION-IF-EMPTY=AC_MSG_ERROR(...)])
168 # --------------------------------------
169 AC_DEFUN([MTLK_CHECK_BUILDER_COMPONENT],
170          [{ AC_MSG_CHECKING([for $2])
171             AS_IF([test x[$1] = x],
172                   [
173                       AC_MSG_RESULT([not specified])
174                       m4_default([$3], [AC_MSG_ERROR([Path to $2 not specified])])
175                   ],
176                   [
177                     AS_IF([test -d [$1]],
178                           [
179                             _mtlk_processed_path=$1
180                             AC_MSG_RESULT([${_mtlk_processed_path}])
181                           ],
182                           [
183                             AC_MSG_RESULT([no])
184                             _mtlk_processed_path=$1
185                             AC_MSG_ERROR([$2 (${_mtlk_processed_path}) does not exist])
186                           ])
187                   ])
188          }])
190 MTLK_CHECK_BUILDER_COMPONENT(${kernel_dir}, [target kernel package])
192 AC_MSG_CHECKING([for target kernel compiler])
194 AS_IF([which $(get_kernel_cross_compile)gcc >/dev/null],
195       [ 
196          target_kernel_gcc=`which $(get_kernel_cross_compile)gcc`
197          AC_MSG_RESULT([${target_kernel_gcc}])
198       ], 
199       [AC_MSG_ERROR([Target kernel compiler not found])])
201 AC_SUBST(kernel_dir)
202 AC_SUBST(kernel_cross_compile, $(get_kernel_cross_compile))
203 AC_SUBST(kernel_cflags)
205 AS_IF([test "x$kernel_arch" != "x"],
206       [kernel_arch_var="ARCH=$kernel_arch"], 
207       [kernel_arch_var=""])
209 AC_SUBST(kernel_arch_var)
210 AC_SUBST(CUSTOM_DRV_ENV_INFO)
212 env_lib_path="$LD_LIBRARY_PATH"
213 AC_SUBST(env_lib_path)
214 export LD_LIBRARY_PATH
216 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
218 dnl For some reason configure script uses $ECHO variable
219 dnl which is empty. Probably bug in autoconf
220 AC_PATH_PROG([ECHO], [echo], [echo])
222 AC_PROG_CC
223 AC_PROG_CXX
224 AC_PROG_RANLIB
226 AC_CHECK_PROG(HAVE_READLINK, [readlink], [yes], [no])
227 AS_IF([test x${HAVE_READLINK} != xyes],
228       [AC_MSG_ERROR([readlink tool must be present and accessible via PATH variable])],
229       [])
231 CC="`cd $srcdir; pwd`/support/mtlkfront.sh $CC"
232 CXX="`cd $srcdir; pwd`/support/mtlkfront.sh $CXX"
234 #These variables will be used by mtlk_front.sh in following tests
235 export abs_builddir=$PWD
236 export abs_top_srcdir=`cd $srcdir; pwd`
237 export abs_tools_srcdir=$abs_top_srcdir/tools
239 AC_MSG_CHECKING([whether compiler frontend works for C programs])
240 AC_TRY_LINK(, [], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
241 AC_LANG_PUSH([C++])
242 AC_MSG_CHECKING([whether compiler frontend works for C++ programs])
243 AC_TRY_LINK(, [], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])])
244 AC_LANG_POP()
246 BUILDER_CC="`cd $srcdir; pwd`/support/mtlkfront.sh gcc"
247 BUILDER_CXX="`cd $srcdir; pwd`/support/mtlkfront.sh g++"
248 AC_SUBST(BUILDER_CC)
249 AC_SUBST(BUILDER_CXX)
251 cc_pic=-fPIC
252 AC_SUBST(cc_pic)
253 cc_shared=-shared
254 AC_SUBST(cc_shared)
256 ld_group_start=-Wl,--start-group
257 AC_SUBST(ld_group_start)
258 ld_group_end=-Wl,--end-group
259 AC_SUBST(ld_group_end)
262 dnl Does this compiler have built-in functions for atomic memory access?
263 AC_MSG_CHECKING([whether platform supports built-in atomics])
264 AC_TRY_LINK(,
266    int variable = 1;
267    return (__sync_add_and_fetch(&variable, 1)
268            && __sync_sub_and_fetch(&variable, 1)
269              && __sync_lock_test_and_set(&variable, 1)) ? 1 : 0;
270  ],
272    AC_MSG_RESULT([yes])
273    AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports builin atomics])
274  ],
276    AC_MSG_RESULT([no])
277  ])
279 AC_DEFINE(LINUX, 1, [Define as 1 to tell that we are building on Linux])
280 AC_DEFINE(MTLK_COPYRIGHT, ["Copyright(c) 2012 Lantiq Deutschland GmbH"],
281                           [Standard copyright string])
283 CFLAGS="$ENV_CFLAGS"
284 CPPFLAGS="$ENV_CPPFLAGS"
285 CXXFLAGS="$ENV_CXXFLAGS"
286 LDFLAGS="$ENV_LDFLAGS"
288 AC_CONFIG_FILES([Makefile
289                  tools/Makefile
290                  tools/dutserver/Makefile
291                  tools/dutserver/linux/Makefile
292                  tools/shared/Makefile
293                  tools/shared/3rd_party/Makefile
294                  tools/shared/3rd_party/iniparser/Makefile
295                  tools/shared/linux/Makefile
296                  wireless/Makefile
297                  wireless/shared/Makefile
298                  wireless/driver/Makefile
299                  wireless/driver/rflib/Makefile
300                  tools/rtlogger/Makefile
301                  tools/rtlogger/shared/Makefile
302                  tools/rtlogger/logserver/Makefile
303                  tools/rtlogger/logserver/linux/Makefile
304                  tools/rtlogger/logcnv/Makefile
305                  tools/rtlogger/prebuilt/Makefile
306                  tools/mtlkroot/Makefile
307                  tools/mttools/Makefile
308                  tools/mttools/shared/Makefile
309                  tools/mttools/drvhlpr/Makefile
310                  tools/mttools/mtdump/Makefile
311                  tools/mttools/mtlk_cli/Makefile
312                  tools/mttools/mtlk_cli_dbg_srv/Makefile
313                  tools/BCLSockServer/Makefile
314                  ])
316 AC_OUTPUT