[607565]: configure.in Maximize Restore History

Download this file

configure.in    173 lines (143 with data), 4.8 kB

#   Autoconf script for oprofile
#
#   Copyright 1999 Olaf Titz <olaf@bigred.inka.de>
#   Adapted for oprofile
#
#   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.
#

AC_REVISION($Id: configure.in,v 1.11 2000/08/28 17:09:21 moz Exp $)
AC_PREREQ(2.13)
AC_INIT(./oprofile.c)

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
PACKAGE=oprofile
VERSION=0.0.1

dnl -- local macros -- 
 
dnl AX_MSG_RESULT_YN(a)
dnl results "yes" iff a==1, "no" else
AC_DEFUN(AX_MSG_RESULT_YN, [x=no
test "x$1" = "x1" && x=yes
AC_MSG_RESULT($x)])

dnl AX_EGREP(expr, file, action-if-found, action-if-not-found)
dnl egrep for expr in file
AC_DEFUN(AX_EGREP, [dnl
changequote(, )dnl
  if egrep "$1" $2 >/dev/null 2>&1; then
changequote([, ])dnl
  ifelse([$3], , :, [$3])
ifelse([$4], , , [else
  $4
])dnl
fi
])

dnl AX_COMPILE_OPTION(option, action-if-found, action-if-not-found)
dnl see if autoconf.h defines the option
AC_DEFUN(AX_COMPILE_OPTION, [
SAVE_CFLAGS=$CFLAGS
CFLAGS="$KCFLAGS -I$KINC -O2 -D__KERNEL__"
AC_TRY_COMPILE( [#include <linux/config.h>],
[
#ifndef $1
break_me_hard(\\\);
#endif
],[$2],[$3],)
CFLAGS=$SAVE_CFLAGS
])

AC_PROG_CC
test "$GCC" || AC_ERROR(You would not have much luck compiling kernel code with non-gcc...)
AC_PROG_CPP
AC_CHECK_PROG(LD,ld,ld,)
test "$LD" || AC_ERROR(ld not found)

dnl  --- Find the Linux kernel, at least the headers ---
 
AC_SUBST(KSRC)
KSRC=/usr/src/linux
AC_ARG_WITH(linux, [  --with-linux=dir             Path to Linux source tree], KSRC=$withval)
AC_SUBST(KINC)

KINC=$KSRC/include
 
if test ! -f $KINC/linux/autoconf.h; then
  AC_MSG_ERROR(no suitably configured kernel include tree found)
fi

dnl  --- Get Linux kernel version and compile parameters ---

AC_SUBST(KVERS)
AC_MSG_CHECKING(for kernel version)
KVERS=`sed -n 's:^#define  *UTS_RELEASE  *\"\([^"]*\).*$:\1:p' $KINC/linux/version.h`
AC_MSG_RESULT($KVERS)
case "$KVERS" in
2.4.*|2.5.*) ;;
*) AC_MSG_ERROR(Unsupported kernel version)
esac

AC_MSG_CHECKING("whether $CC accepts -mpreferred-stack-boundary=2")
SAVE_CFLAGS=$CFLAGS
CFLAGS="-mpreferred-stack-boundary=2 $CFLAGS"
AC_TRY_COMPILE(,,AC_MSG_RESULT("yes");KCFLAGS="-mpreferred-stack-boundary=2 $KCFLAGS",AC_MSG_RESULT("no"))
CFLAGS=$SAVE_CFLAGS

AC_MSG_CHECKING(for x86 architecture)
AX_COMPILE_OPTION(CONFIG_X86,x86=1,x86=0)
AX_MSG_RESULT_YN($x86)
test "$x86" = 1 || AC_MSG_ERROR(Unsupported architecture)

AC_MSG_CHECKING(for SMP)
AX_COMPILE_OPTION(CONFIG_SMP,smp=1,smp=0)
AX_MSG_RESULT_YN($smp)
test "$smp" = 1 && echo "Warning: SMP totally untested !"

AC_MSG_CHECKING(for versioned modules)
mv=0
AX_COMPILE_OPTION(CONFIG_MODVERSIONS,mv=1,mv=0)
AX_MSG_RESULT_YN($mv)
test "$mv" = 1 && AC_DEFINE(MODVERSIONS)

AC_MSG_CHECKING(for local APIC)
AX_COMPILE_OPTION(CONFIG_X86_LOCAL_APIC,apic=1,apic=0)
AX_MSG_RESULT_YN($apic)
test "$apic" = 0 && AC_MSG_ERROR(local APIC not configured)

AC_MSG_CHECKING(for do_nmi patch)
nmipatch=0
AX_EGREP([^ *EXPORT_SYMBOL *\( *do_nmi *\) *], $KSRC/arch/i386/kernel/i386_ksyms.c, nmipatch=1)
AX_MSG_RESULT_YN($nmipatch)
test "$nmipatch" = 1 && KCFLAGS="$KCFLAGS -DOP_EXPORTED_DO_NMI"

KCFLAGS="-I$KINC $KCFLAGS"
AC_SUBST(KCFLAGS)

MODINSTALLDIR=/lib/modules/$KVERS/kernel/arch/i386/kernel
 
AC_ARG_WITH(module-dir,
[  --with-module-dir=dir        Path to module installation directory], MODINSTALLDIR=$withval)
AC_SUBST(MODINSTALLDIR)

AC_ARG_ENABLE(filter,
[  --enable-filter              Enable filtering on pid or pgrp value feature], KCFLAGS="$KCFLAGS -DPID_FILTER")

dnl --- user space configuration ---

AC_ARG_WITH(extra-includes,
[  --with-extra-includes=DIR    add extra include paths],
  use_extra_includes="$withval",
  use_extra_includes=NO
)
if test -n "$use_extra_includes" && \
        test "$use_extra_includes" != "NO"; then
  ac_save_ifs=$IFS
  IFS=':'
  for dir in $use_extra_includes; do
    extra_includes="$extra_includes -I$dir"
  done
  IFS=$ac_save_ifs
  CPPFLAGS="$CPPFLAGS $extra_includes"
fi

AC_ARG_WITH(extra-libs,
[  --with-extra-libs=DIR        add extra library paths],
  use_extra_libs=$withval,
  use_extra_libs=NO
)
if test -n "$use_extra_libs" && \
        test "$use_extra_libs" != "NO"; then
   ac_save_ifs=$IFS
   IFS=':'
   for dir in $use_extra_libs; do
     extra_libraries="$extra_libraries -L$dir"
   done
   IFS=$ac_save_ifs
fi

AC_SUBST(extra_includes)
AC_SUBST(extra_libraries)

AC_CHECK_LIB(popt, poptGetContext,, AC_MSG_ERROR(popt library not found))
AC_CHECK_LIB(iberty, cplus_demangle,, AC_MSG_ERROR(liberty library not found))
AC_CHECK_LIB(dl, dlopen,, AC_MSG_ERROR(dl library not found))
AC_CHECK_LIB(bfd, bfd_openr,, AC_MSG_ERROR(bfd library not found))

AC_OUTPUT(Makefile dae/Makefile pp/Makefile version.h)