summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/oprofile/oprofile/acinclude.m4
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/oprofile/oprofile/acinclude.m4')
-rw-r--r--meta/recipes-kernel/oprofile/oprofile/acinclude.m4600
1 files changed, 600 insertions, 0 deletions
diff --git a/meta/recipes-kernel/oprofile/oprofile/acinclude.m4 b/meta/recipes-kernel/oprofile/oprofile/acinclude.m4
new file mode 100644
index 0000000000..ffaa8288df
--- /dev/null
+++ b/meta/recipes-kernel/oprofile/oprofile/acinclude.m4
@@ -0,0 +1,600 @@
1dnl AX_KERNEL_OPTION(option, action-if-found, action-if-not-found)
2dnl see if autoconf.h defines the option
3AC_DEFUN([AX_KERNEL_OPTION], [
4SAVE_CFLAGS=$CFLAGS
5CFLAGS="-I$KINC -O2 -D__KERNEL__"
6AC_TRY_COMPILE( [#include <linux/config.h>],
7[
8#ifndef $1
9break_me_hard(\\\);
10#endif
11],[$2],[$3],)
12CFLAGS=$SAVE_CFLAGS
13])
14
15dnl Handle the 2.4 module inside module/
16AC_DEFUN([AX_CONFIG_MODULE],
17[
18if test ! -f $KINC/linux/autoconf.h; then
19 AC_MSG_ERROR([no suitably configured kernel include tree found])
20fi
21
22dnl --- Get Linux kernel version and compile parameters ---
23
24AC_SUBST(KVERS)
25AC_MSG_CHECKING([for kernel version])
26dnl it's like this to handle mandrake's fubar version.h - bug #471448
27eval KVERS=`gcc -I$KINC -E -dM $KINC/linux/version.h | grep -w UTS_RELEASE | awk '{print $[]3}'`
28AC_MSG_RESULT([$KVERS])
29case "$KVERS" in
302.2.*|2.4.*) ;;
31*) AC_MSG_ERROR([Unsupported kernel version])
32esac
33
34dnl Check for the minimal kernel version supported
35AC_MSG_CHECKING([kernel version])
36AX_KERNEL_VERSION(2, 2, 10, <=, AC_MSG_RESULT([ok]), AC_MSG_ERROR([check html documentation install section]))
37
38dnl linux/spinlock.h added at some point in past
39AC_MSG_CHECKING([for $KINC/linux/spinlock.h])
40if test -f $KINC/linux/spinlock.h; then
41 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DHAVE_LINUX_SPINLOCK_HEADER"
42 AC_MSG_RESULT([yes])
43else
44 AC_MSG_RESULT([no])
45fi
46
47AC_MSG_CHECKING([for rtc_lock])
48gcc -I$KINC -E $KINC/linux/mc146818rtc.h | grep rtc_lock >/dev/null
49if test "$?" -eq 0; then
50 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DRTC_LOCK"
51 AC_MSG_RESULT([yes])
52else
53 AC_MSG_RESULT([no])
54fi
55
56arch="unknown"
57AC_MSG_CHECKING(for x86-64 architecture)
58AX_KERNEL_OPTION(CONFIG_X86_64, x8664=1, x8664=0)
59AX_MSG_RESULT_YN($x8664)
60BUILD_HAMMER=no
61if test "$x8664" -eq 1; then
62 arch="x86"
63 BUILD_HAMMER=yes
64else
65 AC_MSG_CHECKING(for x86 architecture)
66 AX_KERNEL_OPTION(CONFIG_X86, x86=1, x86=0)
67 AX_KERNEL_OPTION(CONFIG_X86_WP_WORKS_OK, x86=1, x86=$x86)
68 AX_MSG_RESULT_YN($x86)
69 test "$x86" = 1 && arch="x86"
70
71 if test "$arch" = "unknown"; then
72 AC_MSG_CHECKING(for ia64 architecture)
73 AX_KERNEL_OPTION(CONFIG_IA64, ia64=1, ia64=0)
74 AX_MSG_RESULT_YN($ia64)
75 test "$ia64" = 1 && arch="ia64"
76 fi
77
78fi
79AC_SUBST(BUILD_HAMMER)
80
81test "$arch" = "unknown" && AC_MSG_ERROR(Unsupported architecture)
82
83dnl check to see if kernel verion appropriate for arch
84AC_MSG_CHECKING(arch/kernel version combination)
85case "$arch" in
86ia64)
87 AX_KERNEL_VERSION(2, 4, 18, <, AC_MSG_RESULT([ok]),
88 AC_MSG_ERROR([unsupported arch/kernel])) ;;
89*) AC_MSG_RESULT([ok])
90esac
91
92dnl for now we do not support PREEMPT patch
93AC_MSG_CHECKING([for preempt patch])
94AX_KERNEL_OPTION(CONFIG_PREEMPT,preempt=1,preempt=0)
95AX_MSG_RESULT_YN([$preempt])
96test "$preempt" = 0 || AC_MSG_ERROR([unsupported kernel configuration : CONFIG_PREEMPT])
97
98AC_SUBST(KINC)
99
100MODINSTALLDIR=/lib/modules/$KVERS
101
102OPROFILE_MODULE_ARCH=$arch
103AC_SUBST(OPROFILE_MODULE_ARCH)
104]
105)
106
107dnl AX_KERNEL_VERSION(major, minor, level, comparison, action-if-true, action-if-false)
108AC_DEFUN([AX_KERNEL_VERSION], [
109SAVE_CFLAGS=$CFLAGS
110CFLAGS="-I$KINC -D__KERNEL__ -Werror"
111AC_TRY_COMPILE(
112 [
113 #include <linux/version.h>
114 #include <linux/config.h>
115 ],
116 [
117 #if LINUX_VERSION_CODE $4 KERNEL_VERSION($1, $2, $3)
118 break_me_hard(\\\);
119 #endif
120 ],
121[$5],[$6],)
122CFLAGS=$SAVE_CFLAGS
123])
124
125
126dnl AX_MSG_RESULT_YN(a)
127dnl results "yes" iff a==1, "no" else
128AC_DEFUN([AX_MSG_RESULT_YN], [x=no
129test "x$1" = "x1" && x=yes
130AC_MSG_RESULT($x)])
131
132dnl AX_MALLOC_ATTRIBUTE - see if gcc will take __attribute__((malloc))
133AC_DEFUN([AX_MALLOC_ATTRIBUTE],
134[
135AC_MSG_CHECKING([whether malloc attribute is understood])
136SAVE_CFLAGS=$CFLAGS
137CFLAGS="-Werror $CFLAGS"
138AC_TRY_COMPILE(,[
139void monkey() __attribute__((malloc));
140],AC_MSG_RESULT([yes]); AC_DEFINE(MALLOC_ATTRIBUTE_OK, 1, [whether malloc attribute is understood]), AC_MSG_RESULT([no]))
141CFLAGS=$SAVE_CFLAGS
142]
143)
144
145dnl builtin_expect is used in module we can't add that in config.h
146AC_DEFUN([AX_BUILTIN_EXPECT],
147[
148AC_MSG_CHECKING([whether __builtin_expect is understood])
149SAVE_CFLAGS=$CFLAGS
150CFLAGS="-Werror $CFLAGS"
151AC_TRY_LINK(,[
152int i;
153if (__builtin_expect(i, 0)) { }
154],
155AC_MSG_RESULT([yes]); EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK",
156AC_MSG_RESULT([no]);)
157CFLAGS=$SAVE_CFLAGS
158]
159)
160
161dnl AX_EXTRA_DIRS - Let user specify extra dirs for include/libs
162AC_DEFUN([AX_EXTRA_DIRS],
163[
164AC_ARG_WITH(extra-includes,
165[ --with-extra-includes=DIR add extra include paths],
166 use_extra_includes="$withval",
167 use_extra_includes=NO
168)
169if test -n "$use_extra_includes" && \
170 test "$use_extra_includes" != "NO"; then
171 ac_save_ifs=$IFS
172 IFS=':'
173 for dir in $use_extra_includes; do
174 extra_includes="$extra_includes -I$dir"
175 done
176 IFS=$ac_save_ifs
177 CPPFLAGS="$CPPFLAGS $extra_includes"
178fi
179
180AC_ARG_WITH(extra-libs,
181[ --with-extra-libs=DIR add extra library paths],
182 use_extra_libs=$withval,
183 use_extra_libs=NO
184)
185if test -n "$use_extra_libs" && \
186 test "$use_extra_libs" != "NO"; then
187 ac_save_ifs=$IFS
188 IFS=':'
189 for dir in $use_extra_libs; do
190 extra_libraries="$extra_libraries -L$dir"
191 done
192 IFS=$ac_save_ifs
193 LDFLAGS="$LDFLAGS $extra_libraries"
194fi
195]
196)
197
198dnl AX_POPT_CONST - check popt prototype
199AC_DEFUN([AX_POPT_CONST],
200[
201AC_MSG_CHECKING([popt prototype])
202SAVE_CXXFLAGS=$CXXFLAGS
203CXXFLAGS="-Werror $CXXFLAGS"
204AC_TRY_COMPILE([#include <popt.h>],
205[
206int c; char **v;
207poptGetContext(0, c, v, 0, 0);
208],
209AC_MSG_RESULT([takes char **]);,
210AC_MSG_RESULT([takes const char **]); AC_DEFINE(CONST_POPT, 1, [whether popt prototype takes a const char **]))
211CXXFLAGS="$SAVE_CXXFLAGS"
212]
213)
214
215dnl AX_CHECK_SSTREAM - check if local sstream is needed to compile OK
216AC_DEFUN([AX_CHECK_SSTREAM],
217[
218AC_MSG_CHECKING([whether to use included sstream])
219AC_TRY_COMPILE([#include <sstream>], [],
220AC_MSG_RESULT([no]);,
221AC_MSG_RESULT([yes]); OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include")
222]
223)
224
225dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false)
226dnl exec action-if-true if typedef_name is a typedef to type else exec
227dnl action-if-false
228dnl currently work only with type typedef'ed in stddef.h
229AC_DEFUN([AX_CHECK_TYPEDEF], [
230dnl AC_LANG_PUSH(C) not in autoconf 2.13
231AC_LANG_SAVE
232AC_LANG_C
233SAVE_CFLAGS=$CFLAGS
234CFLAGS="-Werror $CFLAGS"
235
236AC_TRY_COMPILE(
237 [
238 #include <stddef.h>
239 ],
240 [
241 typedef void (*fct1)($1);
242 typedef void (*fct2)($2);
243 fct1 f1 = 0;
244 fct2 f2 = 0;
245 if (f1 == f2) {}
246 ],
247[$3],[$4])
248
249CFLAGS=$SAVE_CFLAGS
250AC_LANG_RESTORE
251])
252
253
254dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name)
255dnl set var_name to the typedef name of $1 which must be in canditate_list
256dnl else produce a fatal error
257AC_DEFUN([AX_TYPEDEFED_NAME], [
258 AC_MSG_CHECKING([type of $1])
259 for f in $2; do
260 AX_CHECK_TYPEDEF($1, $f, $3="$f", $3="")
261 if test -n "${$3}"; then
262 break
263 fi
264 done
265 if test -n "${$3}"; then
266 AC_MSG_RESULT([${$3}])
267 else
268 AC_MSG_ERROR([not found])
269 fi
270])
271
272dnl find a binary in the path
273AC_DEFUN([QT_FIND_PATH],
274[
275 AC_MSG_CHECKING([for $1])
276 AC_CACHE_VAL(qt_cv_path_$1,
277 [
278 qt_cv_path_$1="NONE"
279 if test -n "$$2"; then
280 qt_cv_path_$1="$$2";
281 else
282 dirs="$3"
283 qt_save_IFS=$IFS
284 IFS=':'
285 for dir in $PATH; do
286 dirs="$dirs $dir"
287 done
288 IFS=$qt_save_IFS
289
290 for dir in $dirs; do
291 if test -x "$dir/$1"; then
292 if test -n "$5"; then
293 evalstr="$dir/$1 $5 2>&1 "
294 if eval $evalstr; then
295 qt_cv_path_$1="$dir/$1"
296 break
297 fi
298 else
299 qt_cv_path_$1="$dir/$1"
300 break
301 fi
302 fi
303 done
304 fi
305 ])
306
307 if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then
308 AC_MSG_RESULT(not found)
309 $4
310 else
311 AC_MSG_RESULT($qt_cv_path_$1)
312 $2=$qt_cv_path_$1
313 fi
314])
315
316dnl Find the uic compiler on the path or in qt_cv_dir
317AC_DEFUN([QT_FIND_UIC],
318[
319 QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin)
320 if test -z "$ac_uic" -a "$FATAL" = 1; then
321 AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !])
322 fi
323])
324
325dnl Find the right moc in path/qt_cv_dir
326AC_DEFUN([QT_FIND_MOC],
327[
328 QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
329 QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
330
331 if test -n "$ac_moc1" -a -n "$ac_moc2"; then
332 dnl found both. Prefer Qt3's if it exists else moc2
333 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null
334 if test "$?" = 0; then
335 ac_moc=$ac_moc1;
336 else
337 ac_moc=$ac_moc2;
338 fi
339 else
340 if test -n "$ac_moc1"; then
341 ac_moc=$ac_moc1;
342 else
343 ac_moc=$ac_moc2;
344 fi
345 fi
346
347 if test -z "$ac_moc" -a "$FATAL" = 1; then
348 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !])
349 fi
350])
351
352dnl check a particular libname
353AC_DEFUN([QT_TRY_LINK],
354[
355 SAVE_LIBS="$LIBS"
356 LIBS="$LIBS $1"
357 AC_TRY_LINK([
358 #include <qglobal.h>
359 #include <qstring.h>
360 ],
361 [
362 QString s("mangle_failure");
363 #if (QT_VERSION < 221)
364 break_me_(\\\);
365 #endif
366 ],
367 qt_cv_libname=$1,
368 )
369 LIBS="$SAVE_LIBS"
370])
371
372dnl check we can do a compile
373AC_DEFUN([QT_CHECK_COMPILE],
374[
375 AC_MSG_CHECKING([for Qt library name])
376
377 AC_CACHE_VAL(qt_cv_libname,
378 [
379 AC_LANG_CPLUSPLUS
380 SAVE_CXXFLAGS=$CXXFLAGS
381 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
382
383 for libname in -lqt-mt -lqt3 -lqt2 -lqt;
384 do
385 QT_TRY_LINK($libname)
386 if test -n "$qt_cv_libname"; then
387 break;
388 fi
389 done
390
391 CXXFLAGS=$SAVE_CXXFLAGS
392 ])
393
394 if test -z "$qt_cv_libname"; then
395 AC_MSG_RESULT([failed])
396 if test "$FATAL" = 1 ; then
397 AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !])
398 fi
399 else
400 AC_MSG_RESULT([$qt_cv_libname])
401 fi
402])
403
404dnl get Qt version we're using
405AC_DEFUN([QT_GET_VERSION],
406[
407 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
408 [
409 AC_LANG_CPLUSPLUS
410 SAVE_CPPFLAGS=$CPPFLAGS
411 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
412
413 cat > conftest.$ac_ext <<EOF
414#line __oline__ "configure"
415#include "confdefs.h"
416#include <qglobal.h>
417"%%%"QT_VERSION_STR"%%%"
418EOF
419 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
420 grep '^"%%%"' 2>/dev/null | \
421 sed -e 's/"%%%"//g' -e 's/"//g'`
422 rm -f conftest.$ac_ext
423 CPPFLAGS=$SAVE_CPPFLAGS
424 ])
425
426 QT_VERSION=$lyx_cv_qtversion
427 AC_SUBST(QT_VERSION)
428])
429
430dnl start here
431AC_DEFUN([QT_DO_IT_ALL],
432[
433 dnl Please leave this alone. I use this file in
434 dnl oprofile.
435 FATAL=0
436
437 AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ],
438 [ qt_cv_dir=`eval echo "$withval"/` ])
439
440 AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ],
441 [ qt_cv_includes=`eval echo "$withval"` ])
442
443 AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.],
444 [ qt_cv_libraries=`eval echo "$withval"` ])
445
446 dnl pay attention to $QTDIR unless overridden
447 if test -z "$qt_cv_dir"; then
448 qt_cv_dir=$QTDIR
449 fi
450
451 dnl derive inc/lib if needed
452 if test -n "$qt_cv_dir"; then
453 if test -z "$qt_cv_includes"; then
454 qt_cv_includes=$qt_cv_dir/include
455 fi
456 if test -z "$qt_cv_libraries"; then
457 qt_cv_libraries=$qt_cv_dir/lib
458 fi
459 fi
460
461 dnl flags for compilation
462 QT_INCLUDES=
463 QT_LDFLAGS=
464 if test -n "$qt_cv_includes"; then
465 QT_INCLUDES="-I$qt_cv_includes"
466 fi
467 if test -n "$qt_cv_libraries"; then
468 QT_LDFLAGS="-L$qt_cv_libraries"
469 fi
470 AC_SUBST(QT_INCLUDES)
471 AC_SUBST(QT_LDFLAGS)
472
473 QT_FIND_MOC
474 MOC=$ac_moc
475 AC_SUBST(MOC)
476 QT_FIND_UIC
477 UIC=$ac_uic
478 AC_SUBST(UIC)
479
480 QT_CHECK_COMPILE
481
482 QT_LIB=$qt_cv_libname;
483 AC_SUBST(QT_LIB)
484
485 if test -n "$qt_cv_libname"; then
486 QT_GET_VERSION
487 fi
488])
489
490dnl AX_CXXFLAGS_OPTIONS(var-name, option)
491dnl add option to var-name if $CXX support it.
492AC_DEFUN([AX_CHECK_PRECOMPILED_HEADER], [
493AC_MSG_CHECKING([whether ${CXX} support precompiled header])
494AC_LANG_SAVE
495AC_LANG_CPLUSPLUS
496SAVE_CXXFLAGS=$CXXFLAGS
497dnl we consider than if -Winvalid-pch is accepted pch will works ...
498CXXFLAGS=-Winvalid-pch
499dnl but we don't want -Winvalid-pch else compilation will fail due -Werror and
500dnl the fact than some pch will be invalid for the given compilation option
501AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} -include bits/stdc++.h", AC_MSG_RESULT([no]))
502CXXFLAGS=$SAVE_CXXFLAGS
503AC_LANG_RESTORE
504])
505
506dnl AX_CHECK_DOCBOOK
507AC_DEFUN([AX_CHECK_DOCBOOK], [
508# It's just rude to go over the net to build
509XSLTPROC_FLAGS=--nonet
510DOCBOOK_ROOT=
511if test ! -f /etc/xml/catalog; then
512 for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/;
513 do
514 if test -d "$i"; then
515 DOCBOOK_ROOT=$i
516 fi
517 done
518
519 # Last resort - try net
520 if test -z "$DOCBOOK_ROOT"; then
521 XSLTPROC_FLAGS=
522 fi
523else
524 XML_CATALOG=/etc/xml/catalog
525 CAT_ENTRY_START='<!--'
526 CAT_ENTRY_END='-->'
527fi
528
529AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,)
530XSLTPROC_WORKS=no
531if test -n "$XSLTPROC"; then
532 AC_MSG_CHECKING([whether xsltproc works])
533
534 if test -n "$XML_CATALOG"; then
535 DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
536 else
537 DB_FILE="$DOCBOOK_ROOT/docbook.xsl"
538 fi
539
540 $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END
541<?xml version="1.0" encoding='ISO-8859-1'?>
542<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
543<book id="test">
544</book>
545END
546 if test "$?" = 0; then
547 XSLTPROC_WORKS=yes
548 fi
549 AC_MSG_RESULT($XSLTPROC_WORKS)
550fi
551AM_CONDITIONAL(have_xsltproc, test "$XSLTPROC_WORKS" = "yes")
552
553AC_SUBST(XML_CATALOG)
554AC_SUBST(XSLTPROC_FLAGS)
555AC_SUBST(DOCBOOK_ROOT)
556AC_SUBST(CAT_ENTRY_START)
557AC_SUBST(CAT_ENTRY_END)
558])
559
560dnl AX_CFLAGS_OPTIONS(var-name, option)
561dnl add option to var-name if $CC support it.
562AC_DEFUN([AX_CFLAGS_OPTION], [
563AC_MSG_CHECKING([whether ${CC} $2 is understood])
564AC_LANG_SAVE
565AC_LANG_C
566SAVE_CFLAGS=$CFLAGS
567CFLAGS=$2
568AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no]))
569CFLAGS=$SAVE_CFLAGS
570AC_LANG_RESTORE
571])
572
573
574dnl AX_CXXFLAGS_OPTIONS(var-name, option)
575dnl add option to var-name if $CXX support it.
576AC_DEFUN([AX_CXXFLAGS_OPTION], [
577AC_MSG_CHECKING([whether ${CXX} $2 is understood])
578AC_LANG_SAVE
579AC_LANG_CPLUSPLUS
580SAVE_CXXFLAGS=$CXXFLAGS
581CXXFLAGS=$2
582AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no]))
583CXXFLAGS=$SAVE_CXXFLAGS
584AC_LANG_RESTORE
585])
586
587dnl AX_COPY_IF_CHANGE(source, dest)
588dnl copy source to dest if they don't compare equally or if dest doesn't exist
589AC_DEFUN([AX_COPY_IF_CHANGE], [
590if test -r $2; then
591 if cmp $1 $2 > /dev/null; then
592 echo $2 is unchanged
593 else
594 cp -f $1 $2
595 fi
596else
597 cp -f $1 $2
598fi
599])
600