]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Build shadow header files if there is no unified kernel header tree
authorRuss Allbery <rra@debian.org>
Wed, 1 Apr 2009 01:41:40 +0000 (18:41 -0700)
committerRuss Allbery <rra@debian.org>
Wed, 1 Apr 2009 01:41:40 +0000 (18:41 -0700)
Debian's 2.6.29 packages no longer include symlinks from the
architecture-specific header tree to the common header tree; instead,
they use the kbuild machinery with multiple include paths to overlay
the two header files.  Adjust both the Autoconf probes to always use
kbuild and the script that generates the build tree.  For the latter,
when we don't have a unified header tree, we need to generate headers
in the place where the OpenAFS source expects them that include the
linux/* headers.

Patch from Aaron M. Ucko.

src/cf/linux-test3.m4
src/libafs/make_kbuild_makefile.pl

index 8c3b296f98aba910127c57a24c23ef929ef10f5c..a02562f131ce4c4cdb2f6d8d731aeb7e94f95263 100644 (file)
@@ -1,12 +1,8 @@
 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],[
@@ -16,17 +12,16 @@ if test "x$enable_redhat_buildsys" = "xyes"; then
   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)
@@ -76,11 +71,9 @@ AC_SUBST(MPS)
 
 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
@@ -88,15 +81,11 @@ AC_TRY_COMPILE(
   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)
 ])
index dd10db1e327f637d251575ece4bc612b8c164c27..7f73a761d93608973580661d41865d3295401a8d 100755 (executable)
@@ -90,12 +90,61 @@ foreach (@objects) {
   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}";