AC_DEFUN([LINUX_KERNEL_LINUX_SYSCALL_H],[
AC_MSG_CHECKING(for linux/syscall.h in kernel)
- if test -f "${LINUX_KERNEL_PATH}/include/linux/syscall.h"; then
- ac_linux_syscall=yes
- AC_MSG_RESULT($ac_linux_syscall)
- else
- ac_linux_syscall=no
- AC_MSG_RESULT($ac_linux_syscall)
- fi
+ AC_TRY_KBUILD([#include <linux/syscall.h>], [],
+ [ac_linux_syscall=yes], [ac_linux_syscall=no])
+ AC_MSG_RESULT($ac_linux_syscall)
])
AC_DEFUN([LINUX_NEED_RHCONFIG],[
AC_MSG_WARN(Configured to build from a Red Hat SPEC file)
else
AC_MSG_CHECKING(for redhat kernel configuration)
- if test -f "${LINUX_KERNEL_PATH}/include/linux/rhconfig.h"; then
- ac_linux_rhconfig=yes
+ AC_TRY_KBUILD([#include <linux/rhconfig.h>], [],
+ [ac_linux_rhconfig=yes], [ac_linux_rhconfig=no])
+ AC_MSG_RESULT($ac_linux_rhconfig)
+ if test $ac_linux_rhconfig = yes; then
RHCONFIG_SP="-D__BOOT_KERNEL_UP=1 -D__BOOT_KERNEL_SMP=0"
RHCONFIG_MP="-D__BOOT_KERNEL_UP=0 -D__BOOT_KERNEL_SMP=1"
AC_MSG_RESULT($ac_linux_rhconfig)
if test ! -f "/boot/kernel.h"; then
AC_MSG_WARN([/boot/kernel.h does not exist. build may fail])
fi
- else
- ac_linux_rhconfig=no
- AC_MSG_RESULT($ac_linux_rhconfig)
fi
fi
AC_SUBST(RHCONFIG_SP)
AC_DEFUN([LINUX_KERNEL_SELINUX],[
AC_MSG_CHECKING(for SELinux kernel)
-save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="-I${LINUX_KERNEL_PATH}/include $CPPFLAGS"
AC_CACHE_VAL(ac_cv_linux_kernel_is_selinux,
[
-AC_TRY_COMPILE(
+AC_TRY_KBUILD(
[#include <linux/autoconf.h>],
[#ifndef CONFIG_SECURITY_SELINUX
#error not SELINUX
ac_cv_linux_kernel_is_selinux=yes,
ac_cv_linux_kernel_is_selinux=no)])
AC_MSG_RESULT($ac_cv_linux_kernel_is_selinux)
-CPPFLAGS="$save_CPPFLAGS"])
+])
AC_DEFUN([LINUX_KERNEL_LINUX_SEQ_FILE_H],[
AC_MSG_CHECKING(for linux/seq_file.h in kernel)
- if test -f "${LINUX_KERNEL_PATH}/include/linux/seq_file.h"; then
- ac_linux_seq_file=yes
- AC_MSG_RESULT($ac_linux_seq_file)
- else
- ac_linux_seq_file=no
- AC_MSG_RESULT($ac_linux_seq_file)
- fi
+ AC_TRY_KBUILD([#include <linux/seq_file.h>], [],
+ [ac_linux_seq_file=yes], [ac_linux_seq_file=no])
+ AC_MSG_RESULT($ac_linux_seq_file)
])
symlink($deps{$_}, "$KDIR/$src") or die "$KDIR/$src: $!\n";
}
-foreach $src (qw(h sys netinet)) {
- if (-e "$KDIR/$src" || -l "$KDIR/$src") {
- unlink("$KDIR/$src") or die "$KDIR/$src: $!\n";
+%remap = ('h' => 'linux', 'netinet' => 'linux', 'sys' => 'linux');
+if (-f "$vars{LINUX_KERNEL_PATH}/include/linux/types.h") {
+ foreach $src (keys %remap) {
+ if (-e "$KDIR/$src" || -l "$KDIR/$src") {
+ unlink("$KDIR/$src") or die "$KDIR/$src: $!\n";
+ }
+ symlink("$vars{LINUX_KERNEL_PATH}/include/linux", "$KDIR/$src")
+ or die "$KDIR/$src: $!\n";
+ }
+} else {
+ foreach $src (keys %remap) {
+ system ('rm', '-rf', "$KDIR/$src"); # too crude?
+ mkdir("$KDIR/$src", 0777) or die "$KDIR/$src: $!\n";
+ }
+ %seen = ();
+ @q = <$KDIR/*.[Sc]>;
+ @include_dirs = map { /^\// ? $_ : "$KDIR/$_" }
+ split /[\s\\]*-I/, $vars{COMMON_INCLUDE};
+ push @include_dirs, "$vars{TOP_SRCDIR}/../include/rx", "$vars{TOP_SRCDIR}/rx";
+ while (@q) {
+ $src = shift @q;
+ $content = new IO::File($src, O_RDONLY) or die "$src: $!\n";
+ LINE:
+ while (<$content>) {
+ chomp;
+ if (/^\s*#\s*include\s*[<"](?:\.\.\/)?([^\/>"]*)(.*?)[>"]/) {
+ $inc = "$1$2";
+ if (exists $seen{$inc}) {
+ next;
+ } elsif (exists $remap{$1} && $2 !~ /.\//) {
+ $H = new IO::File("$KDIR/$inc", O_WRONLY|O_CREAT|O_TRUNC, 0666)
+ or die "$KDIR/$inc: $!\n";
+ print $H "#include <linux$2>\n";
+ $H->close() or die "$KDIR/$inc: $!\n";
+ } else {
+ for $dir (@include_dirs) {
+ if (-f "$dir/$inc") {
+ push @q, "$dir/$inc";
+ $seen{$inc} = 1;
+ next LINE;
+ }
+ }
+ if ($1 =~ /^(arpa|asm|.*fs|i?net|kern|ksys|linux|mach|rpc|scsi|vm)$/
+ || !length($2)) {
+ # Safe to ignore silently.
+ } else {
+ warn "Ignoring $_ ($inc not found)\n";
+ }
+ }
+ $seen{$inc} = 1;
+ } elsif (/^\s*#\s*include/) {
+ warn "Ignoring $_ (unrecognized syntax)\n";
+ }
+ }
}
- symlink("$vars{LINUX_KERNEL_PATH}/include/linux", "$KDIR/$src")
- or die "$KDIR/$src: $!\n";
}
$cflags = "$vars{CFLAGS} $vars{COMMON_INCLUDE}";