Better devdir support in mkdep.pl
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 8 Nov 2011 20:05:10 +0000 (15:05 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 8 Nov 2011 20:05:10 +0000 (15:05 -0500)
mkdep.pl
plugins/sudoers/Makefile.in

index 67acbd4bd5c8c8e7890baa2c5edd0298a29a027f..77f309fc8fe797b98b40cd27d617d71e8fe38580 100755 (executable)
--- a/mkdep.pl
+++ b/mkdep.pl
@@ -9,6 +9,7 @@ die "usage: $0 Makefile ...\n" unless $#ARGV >= 0;
 my @incpaths;
 my %dir_vars;
 my %implicit;
+my %generated;
 
 # Read in MANIFEST fail if present
 my %manifest;
@@ -48,6 +49,7 @@ sub mkdep {
     $makefile =~ s/\\\n//mg;
 
     # Expand some configure bits
+    $makefile =~ s:\@DEV\@::g;
     $makefile =~ s:\@COMMON_OBJS\@:aix.lo:;
     $makefile =~ s:\@SUDO_OBJS\@:preload.o selinux.o sesh.o sudo_noexec.lo:;
     $makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo plugin_error.lo:;
@@ -70,6 +72,13 @@ sub mkdep {
        push(@incpaths, $1) unless $1 eq ".";
     }
 
+    # Check for generated files
+    if ($makefile =~ /GENERATED\s*=\s*(.+)$/m) {
+       foreach (split(/\s+/, $1)) {
+           $generated{$_} = 1;
+       }
+    }
+
     # Values of srcdir, top_srcdir, top_builddir, incdir
     %dir_vars = ();
     $file =~ m:^(.*)/+[^/]+:;
@@ -108,6 +117,7 @@ sub mkdep {
            } elsif (exists $manifest{$src}) {
                $src = $manifest{$src};
                foreach (sort { length($b) <=> length($a) } keys %dir_vars) {
+                   next if $_ eq "devdir";
                    last if $src =~ s:^\Q$dir_vars{$_}/\E:\$\($_\)/:;
                }
            } else {
@@ -198,10 +208,15 @@ sub find_header {
     return ("\$(top_builddir\)/$hdr", "./${hdr}.in") if -r "./${hdr}.in";
     return ("./$hdr", "$dir_vars{'srcdir'}/${hdr}.in") if -r "$dir_vars{'srcdir'}/${hdr}.in";
 
+    if (exists $generated{$hdr}) {
+       my $hdr_path = $dir_vars{'devdir'} . '/' . $hdr;
+       return ('$(devdir)/' . $hdr, $hdr_path) if -r $hdr_path;
+    }
     foreach my $inc (@incpaths) {
        my $hdr_path = "$inc/$hdr";
        # resolve variables in include path
        foreach (keys %dir_vars) {
+           next if $_ eq "devdir";
            $hdr_path =~ s/\$[\(\{]$_[\)\}]/$dir_vars{$_}/g;
        }
        return ("$inc/$hdr", $hdr_path) if -r $hdr_path;
index 7bf487ab53586337eaf4fb5501e75ccdbb49c7d9..ccdcb54127ad62139a3ec44c8e81ff60901e2783 100644 (file)
@@ -417,7 +417,7 @@ check_iolog_path.o: $(srcdir)/regress/iolog_path/check_iolog_path.c \
                     $(devdir)/def_data.h $(srcdir)/logging.h \
                     $(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h \
                     $(incdir)/sudo_debug.h $(incdir)/gettext.h \
-                    $(srcdir)/def_data.c
+                    $(devdir)/def_data.c
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/regress/iolog_path/check_iolog_path.c
 check_wrap.o: $(srcdir)/regress/logging/check_wrap.c $(top_builddir)/config.h \
               $(incdir)/missing.h $(incdir)/error.h
@@ -435,7 +435,7 @@ defaults.lo: $(srcdir)/defaults.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
              $(srcdir)/defaults.h $(devdir)/def_data.h $(srcdir)/logging.h \
              $(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h \
              $(incdir)/sudo_debug.h $(incdir)/gettext.h $(srcdir)/parse.h \
-             $(devdir)/gram.h $(srcdir)/def_data.c
+             $(devdir)/gram.h $(devdir)/def_data.c
        $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/defaults.c
 env.lo: $(srcdir)/env.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
         $(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
@@ -486,7 +486,7 @@ gram.lo: $(devdir)/gram.c $(top_builddir)/config.h $(top_builddir)/config.h \
          $(incdir)/fileops.h $(srcdir)/defaults.h $(devdir)/def_data.h \
          $(srcdir)/logging.h $(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h \
          $(incdir)/sudo_debug.h $(incdir)/gettext.h $(srcdir)/parse.h \
-         $(srcdir)/toke.h
+         $(srcdir)/toke.h $(devdir)/gram.h
        $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(devdir)/gram.c
 group_plugin.lo: $(srcdir)/group_plugin.c $(top_builddir)/config.h \
                  $(top_srcdir)/compat/dlfcn.h $(srcdir)/sudoers.h \