From: Todd C. Miller Date: Wed, 26 Apr 2017 16:43:42 +0000 (-0600) Subject: Allow "make dist" and "make depend" to work for out of tree builds. X-Git-Tag: SUDO_1_8_20^2~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=495931f4a86c993a807b938fb366227a5617dcc8;p=sudo Allow "make dist" and "make depend" to work for out of tree builds. --- diff --git a/Makefile.in b/Makefile.in index a20f8b80d..f3621fd2e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -151,22 +151,18 @@ siglist.c signame.c: (cd lib/util && exec $(MAKE) $@) depend: siglist.c signame.c - @if test "$(srcdir)" != "."; then \ - echo "make depend only supported in the source directory"; \ - exit 1; \ - fi; \ - $(srcdir)/mkdep.pl $(srcdir)/lib/util/Makefile.in \ - $(srcdir)/plugins/sample/Makefile.in \ - $(srcdir)/plugins/group_file/Makefile.in \ - $(srcdir)/plugins/sudoers/Makefile.in \ - $(srcdir)/plugins/system_group/Makefile.in \ - $(srcdir)/src/Makefile.in $(srcdir)/lib/zlib/Makefile.in; \ - ./config.status --file $(srcdir)/lib/util/Makefile \ - --file $(srcdir)/plugins/sample/Makefile \ - --file $(srcdir)/plugins/group_file/Makefile \ - --file $(srcdir)/plugins/sudoers/Makefile \ - --file $(srcdir)/plugins/system_group/Makefile \ - --file $(srcdir)/src/Makefile --file $(srcdir)/lib/zlib/Makefile + $(top_srcdir)/mkdep.pl --builddir=`pwd` --srcdir=$(top_srcdir) \ + lib/util/Makefile.in lib/zlib/Makefile.in \ + plugins/group_file/Makefile.in plugins/sample/Makefile.in \ + plugins/sudoers/Makefile.in plugins/system_group/Makefile.in \ + src/Makefile.in && \ + $(top_builddir)/config.status --file $(top_builddir)/lib/util/Makefile \ + --file $(top_builddir)/plugins/sample/Makefile \ + --file $(top_builddir)/plugins/group_file/Makefile \ + --file $(top_builddir)/plugins/sudoers/Makefile \ + --file $(top_builddir)/plugins/system_group/Makefile \ + --file $(top_builddir)/src/Makefile \ + --file $(top_builddir)/lib/zlib/Makefile ChangeLog: if test -d $(srcdir)/.hg && cd $(srcdir); then \ @@ -284,7 +280,7 @@ install-nls: fi check-dist: update-pot compile-po - @if [ -d .hg ]; then \ + @if test -d $(srcdir)/.hg && cd $(srcdir); then \ if test `hg stat -am | wc -l` -ne 0; then \ echo "Uncommitted changes" 1>&2; \ hg stat -am 1>&2; \ @@ -295,10 +291,11 @@ check-dist: update-pot compile-po dist: check-dist force-dist force-dist: ChangeLog $(srcdir)/MANIFEST + cd $(top_srcdir) && \ pax -w -x ustar -s '/^/$(PACKAGE_TARNAME)-$(VERSION)\//' \ -f ../$(PACKAGE_TARNAME)-$(VERSION).tar \ - `$(SED) 's/[ ].*//' $(srcdir)/MANIFEST` - gzip -9f ../$(PACKAGE_TARNAME)-$(VERSION).tar + `$(SED) 's/[ ].*//' $(srcdir)/MANIFEST` && \ + gzip -9f ../$(PACKAGE_TARNAME)-$(VERSION).tar && \ ls -l ../$(PACKAGE_TARNAME)-$(VERSION).tar.gz package: $(srcdir)/sudo.pp diff --git a/mkdep.pl b/mkdep.pl index 67a596096..93f65efe6 100755 --- a/mkdep.pl +++ b/mkdep.pl @@ -19,21 +19,33 @@ use File::Temp qw/ :mktemp /; use Fcntl; use warnings; -die "usage: $0 Makefile ...\n" unless $#ARGV >= 0; +die "usage: $0 [--builddir=dir] [--srcdir=dir] Makefile.in ...\n" unless $#ARGV >= 0; my @incpaths; my %dir_vars; my %implicit; my %generated; +my $top_builddir = "."; +my $top_srcdir; -# Read in MANIFEST fail if present -my %manifest; -if (open(MANIFEST, ") { - chomp; - next unless /([^\/]+\.[cly])$/; - $manifest{$1} = $_; +# Check for srcdir and/or builddir, if present +while ($ARGV[0] =~ /^--(src|build)dir=(.*)/) { + if ($1 eq 'src') { + $top_srcdir = $2; + } else { + $top_builddir = $2; } + shift @ARGV; +} +chdir($top_srcdir) if defined($top_srcdir); + +# Read in MANIFEST or fail if not present +my %manifest; +die "unable to open MANIFEST: $!\n" unless open(MANIFEST, ") { + chomp; + next unless /([^\/]+\.[cly])$/; + $manifest{$1} = $_; } foreach (@ARGV) { @@ -101,6 +113,7 @@ sub mkdep { $dir_vars{'srcdir'} = $1 || '.'; $dir_vars{'devdir'} = $dir_vars{'srcdir'}; $dir_vars{'authdir'} = $dir_vars{'srcdir'} . "/auth"; + $dir_vars{'builddir'} = $top_builddir . "/" . $dir_vars{'srcdir'}; $dir_vars{'top_srcdir'} = '.'; #$dir_vars{'top_builddir'} = '.'; $dir_vars{'incdir'} = 'include'; @@ -184,8 +197,8 @@ sub find_depends { my ($deps, $code, %headers); if ($src !~ /\//) { - # XXX - want build dir not src dir - $src = "$dir_vars{'srcdir'}/$src"; + # generated file, local to build dir + $src = "$dir_vars{'builddir'}/$src"; } # resolve $(srcdir) etc.