From: Todd C. Miller Date: Tue, 8 Nov 2011 20:05:10 +0000 (-0500) Subject: Better devdir support in mkdep.pl X-Git-Tag: SUDO_1_8_4~161^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f375ee5f013eda4ea50fa5cc65de0065e1c5e9b8;p=sudo Better devdir support in mkdep.pl --- diff --git a/mkdep.pl b/mkdep.pl index 67acbd4bd..77f309fc8 100755 --- 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; diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index 7bf487ab5..ccdcb5412 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -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 \