build/autoconf/linux.m4
author Mike Hommey <mh+mozilla@glandium.org>
Sat, 04 Aug 2012 08:55:00 +0200
changeset 101422 040c3b5a99d09e1017d221fe3dfb24dfa92f3ec0
permissions -rw-r--r--
Bug 778740 - Allow to use Linux kernel headers for perf events. r=khuey

dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.

AC_DEFUN([MOZ_LINUX_PERF_EVENT],
[

MOZ_ARG_WITH_STRING(linux-headers,
[  --with-linux-headers=DIR
                          location where the Linux kernel headers can be found],
    linux_headers=$withval)

LINUX_HEADERS_INCLUDES=

if test "$linux_headers"; then
    LINUX_HEADERS_INCLUDES="-I$linux_headers"
fi

_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $LINUX_HEADERS_INCLUDES"

dnl Performance measurement headers.
MOZ_CHECK_HEADER(linux/perf_event.h,
    [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open,
        [AC_TRY_COMPILE([#include <asm/unistd.h>],[return sizeof(__NR_perf_event_open);],
        ac_cv_perf_event_open=yes,
        ac_cv_perf_event_open=no)])])
if test "$ac_cv_perf_event_open" = "yes"; then
    HAVE_LINUX_PERF_EVENT_H=1
else
    HAVE_LINUX_PERF_EVENT_H=
    LINUX_HEADERS_INCLUDES=
fi
AC_SUBST(HAVE_LINUX_PERF_EVENT_H)
AC_SUBST(LINUX_HEADERS_INCLUDES)

CFLAGS="$_SAVE_CFLAGS"

])