Skip to content

Commit

Permalink
Makefile fixes: 0.85.1 recut was unusable.
Browse files Browse the repository at this point in the history
When transitioning to git, I failed to test the build from a fresh
tarball extraction, so did not notice that the new SCRIPTSRC vs
SCRIPTDIST distinction made install impossible, because requisite source
files for regenerating a target were not available.

Simplest fix is also the most portable: strip out all targets intended
for distributors.  The segregated sections of the makefile have paid
off, it's a simple sed command to strip out.  So renamed "Makefile" to
"makefile" for the git repo, but the distributed version is a Makefile
with the distributor targets all ripped out, so that make(1) doesn't
think it has to rebuild the sources we distribute.

Additionally: when using install(1) to install to a directory, finish
the target path with "/./" so that if .../bin/ does not exist we don't
install the script as a file named "bin".  "/." is sufficient for my
install(1), but probably most portable to ensure target ends with a / if
we want directory semantics for how install(1) decides what to do.
  • Loading branch information
philpennock committed Jul 17, 2013
1 parent afaa1be commit f82c82a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Makefile → makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ all: $(SCRIPTNAME)
install: all install-bin install-man

install-bin: $(SCRIPTNAME)
$(INSTALLPROG) -m $(BINPERM) $(INSTALLARGS) $(SCRIPTNAME) $(INSTALLROOT)$(PREFIX)/$(BINDIR)
$(INSTALLPROG) -m $(BINPERM) $(INSTALLARGS) $(SCRIPTNAME) $(INSTALLROOT)$(PREFIX)/$(BINDIR)/./

# making the man-page is dependent upon files not distributed, so they're
# regenerated, so we don't list it as a dependency here -- instead we
# assume that the maintainer created it for us (as a tarball depenency)
install-man:
$(INSTALLPROG) -m $(MANPERM) $(INSTALLARGS) $(MANPAGE) $(INSTALLROOT)$(PREFIX)/$(MANDIR)/$(MANSECTDIR)
$(INSTALLPROG) -m $(MANPERM) $(INSTALLARGS) $(MANPAGE) $(INSTALLROOT)$(PREFIX)/$(MANDIR)/$(MANSECTDIR)/./

bin $(SCRIPTNAME): $(SCRIPTDIST)
$(SED) <"$(SCRIPTDIST)" >"$(SCRIPTNAME)" "1s:/.*:$(PERL5BIN):"
Expand All @@ -52,6 +52,14 @@ clean:

dist: tarball pgpsig

# The presence of SCRIPTSRV and git rules breaks install from outside the git
# repository; we fix it by just ripping out the distributors section from the
# tarball Makefile. So "makefile" in git and for use when making a release.
# "Makefile" for distribution. BSD make prefers "makefile" to "Makefile", so
# we can still use distributor targets when both are present.
Makefile: makefile
sed '/Targets after here are for distributors/,$$d' < makefile > Makefile

$(SCRIPTDIST): $(SCRIPTSRC) versionfile
perl -MFile::Slurp -p < $(SCRIPTSRC) > $(SCRIPTDIST) -e ' \
BEGIN { $$newver = read_file("versionfile"); chomp $$newver; }; \
Expand Down Expand Up @@ -82,4 +90,4 @@ datefile versionfile: .git/HEAD
TZ='' git show -s --format=%ci HEAD | cut -d ' ' -f 1 > datefile

distclean: clean
$(RM) -f "./$(MANPAGE)" ./ChangeLog ./versionfile ./datefile ./$(SCRIPTDIST)
$(RM) -f "./$(MANPAGE)" ./ChangeLog ./versionfile ./datefile ./$(SCRIPTDIST) ./Makefile

0 comments on commit f82c82a

Please sign in to comment.