diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-02-08 16:36:45 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-02-08 16:36:45 -0500 |
commit | 7e704d7ac997387341e920e1757c24cac0efe5e9 (patch) | |
tree | a9f30eabaaad5496397a91053d3e03bab1ea57e4 /common.each.tail.mk | |
parent | 7785a72495e3eb0ea826b41720c241f58a15b601 (diff) |
Refactor the build system. Avoid recursive make.
This looks like a lot, but more things should "just work".
We have `make dist` now!
Diffstat (limited to 'common.each.tail.mk')
-rw-r--r-- | common.each.tail.mk | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/common.each.tail.mk b/common.each.tail.mk new file mode 100644 index 0000000..3192ddb --- /dev/null +++ b/common.each.tail.mk @@ -0,0 +1,82 @@ +# Copyright (C) 2015 Luke Shumaker +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +am_gen_files += .srcfiles.mk $(devtools-files) +am_out_files += $(filter-out $(am_src_files) $(am_gen_files),$(install-files)) \ + $(if $(pots),everything.pot) +am_sys_files += $(addprefix $(bindir)/,$(install-bins)) \ + $(addprefix $(pkgconfdir)/,$(install-confs)) \ + $(addprefix $(pkglibexecdir)/,$(install-libexecs) $(install-libs)) \ + $(addprefix $(pkgdocdir)/,$(install-docs)) \ + $(addprefix $(mandir)/man1/,$(filter %.1,$(install-mans))) \ + $(addprefix $(mandir)/man2/,$(filter %.2,$(install-mans))) \ + $(addprefix $(mandir)/man3/,$(filter %.3,$(install-mans))) \ + $(addprefix $(mandir)/man4/,$(filter %.4,$(install-mans))) \ + $(addprefix $(mandir)/man5/,$(filter %.5,$(install-mans))) \ + $(addprefix $(mandir)/man6/,$(filter %.6,$(install-mans))) \ + $(addprefix $(mandir)/man7/,$(filter %.7,$(install-mans))) \ + $(addprefix $(mandir)/man8/,$(filter %.8,$(install-mans))) +am_clean_files += *.pot *.ugly .tmp* + +exec_$(outdir) := $(exec_$(outdir)) $(install-bins) $(install-libexecs) + +_is_executable = $(filter $(exec_$(@D)),$(@F)) + +$(srcdir)/%.in: $(devtoolsdir)/%.in + cp -T '$<' '$@' +$(srcdir)/%.in: $(devtoolsdir)/lib/% + cp -T '$<' '$@' +$(outdir)/%: $(srcdir)/%.in + @echo 'EDIT < $< > $@'; $(edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@' +$(outdir)/%: $(srcdir)/%.ronn + ronn --roff $(RONNFLAGS) < '$<' > '$@' +$(outdir)/%.html: $(srcdir)/%.ronn + ronn --html $(RONNFLAGS) < '$<' > '$@' +$(outdir)/%.pot: $(outdir)/% $(topsrcdir)/src/lib/librexgettext + $(topsrcdir)/src/lib/librexgettext $(LIBREXGETTEXT_FLAGS) '$<' > '$@' +$(outdir)/%.pot: $(srcdir)/% $(topsrcdir)/src/lib/librexgettext + $(topsrcdir)/src/lib/librexgettext $(LIBREXGETTEXT_FLAGS) '$<' > '$@' +$(outdir)/everything.pot: $(addprefix $(outdir)/,$(addsuffix .pot,$(pots))) + cat $^ | $(pofmt) > '$@' + +# If we have a .patch file, the flow is: +# $(devtoolsdir)/%.in -> %.in + %.patch -> %.ugly -> % +_do_patch = $(filter $(patsubst %.patch,%,$(filter %.patch,$(detect-all))),$(patsubst %.in,%,$(devtools-files))) +$(outdir)/%.ugly: $(srcdir)/%.in $(srcdir)/%.patch + cp -T $< $@ + patch $@ $(<D)/$*.patch +$(sort $(addprefix $(outdir)/,$(_do_patch))): $(outdir)/%: $(outdir)/%.ugly + @echo 'EDIT < $< > $@'; $(edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@' + @echo 'INDENT $@'; $(call indent,$@) + +$(DESTDIR)$(pkgconfdir)/% : $(outdir)/% ; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(pkgdocdir)/% : $(outdir)/% ; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man1/%.1: $(outdir)/%.1; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man2/%.2: $(outdir)/%.2; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man3/%.3: $(outdir)/%.3; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man4/%.4: $(outdir)/%.4; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man5/%.5: $(outdir)/%.5; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man6/%.6: $(outdir)/%.6; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man7/%.7: $(outdir)/%.7; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(mandir)/man8/%.8: $(outdir)/%.8; install -T -Dm644 '$<' '$@' +$(DESTDIR)$(pkglibexecdir)/%: $(outdir)/% ; mkdir -p '$(@D)' && cp -T '$<' '$@' +$(DESTDIR)$(bindir)/% : $(outdir)/% ; install -T -Dm755 '$<' '$@' +# Repeat the last two rules again with explicit targets because +# otherwise it would try to do src/xbs->/bin/xbs instead of +# src/xbs/xbs->/bin/xbs +ifneq ($(filter $(notdir $(outdir)),$(install-files)),) +$(DESTDIR)$(pkglibexecdir)/$(notdir $(outdir)): $(DESTDIR)$(pkglibexecdir)/%: $(outdir)/% ; mkdir -p '$(@D)' && cp -T '$<' '$@' +$(DESTDIR)$(bindir)/$(notdir $(outdir)): $(DESTDIR)$(bindir)/% : $(outdir)/% ; install -T -Dm755 '$<' '$@' +endif |