-
Notifications
You must be signed in to change notification settings - Fork 2
/
acinclude.m4
315 lines (262 loc) · 7.87 KB
/
acinclude.m4
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
# Open-MX
# Copyright © inria 2007-2011 (see AUTHORS file)
#
# The development of this software has been funded by Myricom, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License in COPYING.GPL for more details.
# PUSH_BUILDENV()
# ---------------
# Push the current build environment
AC_DEFUN([PUSH_BUILDENV],
[
__CPPFLAGS_save="$CPPFLAGS"
__CFLAGS_save="$CFLAGS"
__LDFLAGS_save="$LDFLAGS"
])
# POP_BUILDENV()
# --------------
# Pop the precedently pushed build environment
AC_DEFUN([POP_BUILDENV],
[
CPPFLAGS="$__CPPFLAGS_save"
CFLAGS="$__CFLAGS_save"
LDFLAGS="$__LDFLAGS_save"
])
# GET_BUILD_STRING(VAR)
# ---------------------
# Store the build string in VAR
AC_DEFUN([GET_BUILD_STRING],
[
$1="`id -run 2>/dev/null`@`uname -n`:`cd ${srcdir} && pwd` `date`"
])
# OMX_ENABLE(ARGNAME, SHELLVAR, DESC, MSG)
# ----------------------------------------
# Convenience wrapper over AC_ARG_ENABLE with the option deactivated by default
AC_DEFUN([OMX_ENABLE],
[
AC_MSG_CHECKING($4)
AC_ARG_ENABLE($1, AC_HELP_STRING(--enable-$1, $3), $2=$enableval, $2=no)
if test x$$2 = xyes ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
# OMX_DISABLE(ARGNAME, SHELLVAR, DESC, MSG)
# -----------------------------------------
# Convenience wrapper over AC_ARG_ENABLE with the option activated by default
AC_DEFUN([OMX_DISABLE],
[
AC_MSG_CHECKING($4)
AC_ARG_ENABLE($1, AC_HELP_STRING(--disable-$1, $3), $2=$enableval, $2=yes)
if test x$$2 = xyes ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
# OMX_DEFINE(NAME, VALUE, DESC, TEST)
# -----------------------------------
# Convenience wrapper over AC_DEFINE
AC_DEFUN([OMX_DEFINE],
[
if $4 ; then
AC_DEFINE_UNQUOTED($1, $2, $3)
fi
])
# OMX_WITH(ARGNAME, ARGSTRING, SHELLVAR, DESC, MSG, [DEFVAL])
# -------------------------------------------------
# Convenience wrapper over AC_ARG_WITH
AC_DEFUN([OMX_WITH],
[
AC_ARG_WITH($1, AC_HELP_STRING(--with-$1=<$2>, $4), $3=$withval, $3=$6)
AC_MSG_NOTICE($5)
])
# OMX_WITH_COND(ARGNAME, ARGSTRING, SHELLVAR, DESC, MSG, MSG_COND, [DEFVAL])
# --------------------------------------------------------------------------
# The same as AC_ARG_WITH but the message displaying can be controlled by a condition
AC_DEFUN([OMX_WITH_COND],
[
AC_ARG_WITH($1, AC_HELP_STRING(--with-$1=<$2>, $4), $3=$withval, $3=$7)
if $6 ; then
AC_MSG_NOTICE($5)
fi
])
# OMX_PROG_KCC([COMPILER])
# -----------------------
# Check whether the request compiler used to build kernel modules exists
AC_DEFUN([OMX_PROG_KCC],
[
AC_MSG_CHECKING(which compiler is used to build kernel modules)
if ! test -z $1 ; then
AC_MSG_RESULT($1)
AC_CHECK_PROGS(__KCC, $1)
if test -z $__KCC ; then
AC_MSG_ERROR(no compiler has been found to build kernel modules)
fi
else
AC_MSG_RESULT($CC)
fi
])
# OMX_FIND_KERNEL_HEADERS(VAR, PATHS)
# -----------------------------------
# Scan the directories in PATHS for one containing kernel headers and
# stores the result in VAR
AC_DEFUN([OMX_FIND_KERNEL_HEADERS],
[
AC_MSG_CHECKING(for kernel.h kernel header)
for dir in $2 ; do
if test -f $dir/include/linux/kernel.h ; then
$1=$dir
AC_MSG_RESULT($dir)
break
fi
done
if test -z $$1 ; then
AC_MSG_RESULT(not found in $2)
AC_MSG_ERROR(no kernel header found)
fi
])
# OMX_FIND_KERNEL_AUTOCONF_HEADER(VAR, PATHS)
# -------------------------------------------
# Look for the kernel autoconf header in the PATH lists and stores the first successful
# path in VAR
AC_DEFUN([OMX_FIND_KERNEL_AUTOCONF_HEADER],
[
AC_MSG_CHECKING(for autoconf.h kernel header)
for dir in $2 ; do
if test -f $dir/include/linux/autoconf.h -o -f $dir/include/generated/autoconf.h ; then
$1=$dir
AC_MSG_RESULT($dir)
break
fi
done
if test -z $$1 ; then
AC_MSG_RESULT(not found in $2)
AC_MSG_ERROR(no kernel autoconf header found)
fi
])
# OMX_CHECK_KBUILD_MAKEFILE(BUILD_TREE)
# -------------------------------------
# Check for the Kbuild Makefile in BUILD_TREE
AC_DEFUN([OMX_CHECK_KBUILD_MAKEFILE],
[
AC_MSG_CHECKING(for the Kbuild Makefile)
if test -f $1/Makefile ; then
AC_MSG_RESULT(found in $1)
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR(no Kbuild Makefile found)
fi
])
# OMX_GET_KERNEL_RELEASE(VAR, BUILD_TREE)
# ---------------------------------------
# Store in VAR the real Linux kernel release pointed by BUILD_TREE
AC_DEFUN([OMX_GET_KERNEL_RELEASE],
[
$1=$(make kernelrelease -C $2 M=dummy | grep -e '^[[0-9]]\+\.[[0-9]]\+')
])
# OMX_GET_KERNEL_GCC_VERSION(VAR)
# -------------------------------
# Store in VAR the version of GGC used to compile the kernel
AC_DEFUN([OMX_GET_KERNEL_GCC_VERSION],
[
$1=$(sed -e 's/.*gcc version \(.\..\).*/\1/' /proc/version)
])
# OMX_GET_GCC_VERSION(VAR, GCCPATH)
# ---------------------------------
# Assuming GCCPATH points to a GCC compiler, store in VAR the version of this compiler
AC_DEFUN([OMX_GET_GCC_VERSION],
[
$1=$($2 --version 2>/dev/null | sed -nr -e 's/.* ([[0-9]]+\.[[0-9]]+).*/\1/p' | head -1)
])
# OMX_SYMLINK_DRIVER_SOURCES()
# ----------------------------
# Symlink driver sources into the build tree if needed
AC_DEFUN([OMX_SYMLINK_DRIVER_SOURCES],
[
mkdir -p driver/linux
if test ! "$srcdir" -ef . ; then
# Symlink kernel sources into the build tree if needed
AC_MSG_NOTICE(creating symlinks to kernel sources in driver/linux/ ...)
for file in $srcdir/driver/linux/*.[[ch]] ; do
filename=$(basename $file)
AC_CONFIG_LINKS(driver/linux/$filename:driver/linux/$filename)
done
fi
])
# OMX_FIND_KBUILD_CFLAGS_ARG(VAR, BUILD_TREE)
# -------------------------------------------
# Get the type of CFLAGS directive supported by the kernel located in BUILD_TREE
# and store it in VAR
AC_DEFUN([OMX_FIND_KBUILD_CFLAGS_ARG],
[
AC_MSG_CHECKING(whether kernel build supports ccflags-y)
if test -d $2/scripts && grep ccflags-y -r $2/scripts > /dev/null ; then
AC_MSG_RESULT(yes)
$1=ccflags-y
else
AC_MSG_RESULT(no, reverting to EXTRA_CFLAGS)
$1=EXTRA_CFLAGS
fi
])
# OMX_CHECK_VALGRIND_HEADERS()
# ----------------------------
# Check for Valgrind headers
AC_DEFUN([OMX_CHECK_VALGRIND_HEADERS],
[
AC_MSG_CHECKING(whether Valgrind headers are available)
AC_PREPROC_IFELSE([AC_LANG_SOURCE(
[
#include <valgrind/memcheck.h>
#ifndef VALGRIND_MAKE_MEM_NOACCESS
#error VALGRIND_MAKE_MEM_NOACCESS not defined
#endif
]),
__valgrind_available=yes])
if test x$__valgrind_available = xyes ; then
AC_MSG_RESULT(yes)
$1=true
else
AC_MSG_RESULT(no)
$1=false
fi
])
# OMX_CHECK_KERNEL_HEADERS(BUILD_TREE, HEADER_TREE, LINUX_RELEASE)
# --------------------------
# Check whether Open-MX is compliant with the Linux kernel internal API
AC_DEFUN([OMX_CHECK_KERNEL_HEADERS],
[
AC_MSG_NOTICE(checking kernel headers...)
if ! $srcdir/driver/linux/check_kernel_headers.sh --force ./driver/linux/omx_checks.h "$1" "$2" "$3" ; then
AC_MSG_ERROR(Open-MX is not compliant with the Linux kernel internal API)
fi
])
# OMX_SYMLINK_TESTS()
# ----------------------------
# Symlink tests to omx_test_launcher
AC_DEFUN([OMX_SYMLINK_TESTS],
[
mkdir -p tests/helpers
AC_CONFIG_LINKS(tests/helpers/omx_test_double_app:tests/helpers/omx_test_double_app)
AC_CONFIG_LINKS(tests/helpers/omx_test_battery:tests/helpers/omx_test_battery)
AC_MSG_NOTICE(creating symlinks to omx_test_launcher in tests/launchers/ ...)
mkdir -p tests/launchers
for __t in $TEST_LIST ; do
ln -sf ../helpers/omx_test_launcher tests/launchers/$__t
done
AC_MSG_NOTICE(creating symlinks to omx_test_battery in tests/battery/ ...)
mkdir -p tests/battery
for __b in $BATTERY_LIST ; do
ln -sf ../helpers/omx_test_battery tests/battery/$__b
done
])