From d330445fb7f84748e70e67ca5bc44ce0a1a258f7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 9 Jun 2016 15:55:33 -0400 Subject: Work with the new version of autothing. --- .gitignore | 3 +- HACKING/build-system.md | 16 ++--- Makefile | 14 +++-- build-aux/Makefile.each.head/20-libretools.mk | 35 +++++++++++ build-aux/Makefile.each.tail/20-libretools.mk | 89 +++++++++++++++++++++++++++ build-aux/Makefile.once.head/20-libretools.mk | 81 ++++++++++++++++++++++++ build-aux/no-builtin-variables.mk | 11 ++++ common.each.head.mk | 35 ----------- common.each.tail.mk | 89 --------------------------- common.once.head.mk | 83 ------------------------- common.once.tail.mk | 0 config.mk | 11 +++- src/Makefile | 4 +- src/abslibre-tools/Makefile | 4 +- src/chroot-tools/Makefile | 10 +-- src/devtools/Makefile | 6 +- src/gitget/Makefile | 4 +- src/lib/Makefile | 4 +- src/librefetch/Makefile | 4 +- src/toru/Makefile | 4 +- src/xbs-abs/Makefile | 8 +-- src/xbs-abslibre/Makefile | 4 +- src/xbs/Makefile | 4 +- write-ifchanged | 11 ---- 24 files changed, 268 insertions(+), 266 deletions(-) create mode 100644 build-aux/Makefile.each.head/20-libretools.mk create mode 100644 build-aux/Makefile.each.tail/20-libretools.mk create mode 100644 build-aux/Makefile.once.head/20-libretools.mk create mode 100644 build-aux/no-builtin-variables.mk delete mode 100644 common.each.head.mk delete mode 100644 common.each.tail.mk delete mode 100644 common.once.head.mk delete mode 100644 common.once.tail.mk delete mode 100755 write-ifchanged diff --git a/.gitignore b/.gitignore index 49ed84d..00a200a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,10 +10,11 @@ /.srcversion-devtools.mk # The top-level distdir -/*-*/ +/libretools-*/ # File extensions *.ugly +*.tar *.tar.gz *.pot *.1 diff --git a/HACKING/build-system.md b/HACKING/build-system.md index 93770cc..40abd28 100644 --- a/HACKING/build-system.md +++ b/HACKING/build-system.md @@ -1,12 +1,8 @@ -The build system is built around an automake-like system for GNU Make -that I wrote. It is documented in `automake.txt`. It provides all of -the standard targets and such; you tell it what to do by setting a -series of `am_whatever` variables. I'm just going to call it -"automake" here. - -I also hook into non-exposed parts of automake with a couple of -`_am_whatever` variables. Hopefully I will come up with good ways to -expose the needed functionality in the future. +The build system is built around an Automake-replacing Makefile +snippet system for GNU Make that I wrote, called Autothing. It is +documented in `build-aux/Makfile.README.txt`. It provides all of the +standard targets and such; you tell it what to do by setting a series +of `at.whatever` or `std.whatever` variables. There are a couple of variables that get automatically set from git. This happens by `include`ing a hidden makefile that sets them; if @@ -21,4 +17,4 @@ otherwise it expects the file to exist: | DEVTOOLS_VERSION | $(topsrcdir)/.srcversion-devtools.mk | | DEVTOOLS_COMMIT | $(topsrcdir)/.srcversion-devtools.mk | -`srcfiles` basically becomes `am_src_files`. +`srcfiles` basically becomes `std.src_files`. diff --git a/Makefile b/Makefile index 5be5195..0e9caa2 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk # these are the resulting packages packages=libretools librelib gitget xbs @@ -31,9 +31,11 @@ po/%(package).pot: $(addsuffix /everything.pot,$(%(package))); \ $(foreach package,$(packages),$(eval $(subst %(package),$(package),$(value _po_rule)))) pots = -am_out_files += $(foreach package,$(packages),po/$(package).pot) -am_clean_files += .var.* -am_gen_files += .srcversion-libretools.mk .srcversion-devtools.mk -am_subdirs = src $(foreach package,$(packages),$($(package))) +std.out_files += $(foreach package,$(packages),po/$(package).pot) +std.clean_files += .var.* +std.gen_files += .srcversion-libretools.mk .srcversion-devtools.mk +at.subdirs = src $(foreach package,$(packages),$($(package))) +detect-ignore-md += HACKING/% +detect-ignore-exec += build-aux/% -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/build-aux/Makefile.each.head/20-libretools.mk b/build-aux/Makefile.each.head/20-libretools.mk new file mode 100644 index 0000000..90e9bda --- /dev/null +++ b/build-aux/Makefile.each.head/20-libretools.mk @@ -0,0 +1,35 @@ +pkgconfdir = $(sysconfdir)/libretools.d +pkgdocdir = $(docdir)/libretools +pkglibexecdir = $(libexecdir)/libretools + +# Detect things about the directory we're in #################################### + +srcfiles-ignore/$(srcdir) = $(addsuffix /%,$(at.subdirs/$(@D))) + +ifeq ($(wildcard $(topsrcdir)/.git),) +include $(srcdir)/.srcfiles.mk +else +$(srcdir)/.srcfiles.mk: FORCE + @echo srcfiles = $(filter-out $(srcfiles-ignore/$(@D)),$(shell cd $(@D) && git ls-files)) | $(WRITE_IFCHANGED) $@ +-include $(srcdir)/.srcfiles.mk +endif + +detect-ignore = +detect-ignore-exec = +detect-ignore-conf = +detect-ignore-ronn = +detect-ignore-md = HACKING.md +detect-ignore-sh = + +devtools-files = + +libretools-srcs = $(detect-all) +libretools-mans = $(patsubst %.ronn,%,$(detect-ronn)) +libretools-bins = $(detect-exec) +libretools-libexecs = +libretools-libs = $(detect-sh) +libretools-docs = $(detect-md) $(detect-ronn) +libretools-confs = $(detect-conf) + +libretools-files = $(libretools-mans) $(libretools-bins) $(libretools-libexecs) $(libretools-libs) $(libretools-docs) $(libretools-confs) +pots = $(libretools-bins) $(libretools-libexecs) $(libretools-libs) diff --git a/build-aux/Makefile.each.tail/20-libretools.mk b/build-aux/Makefile.each.tail/20-libretools.mk new file mode 100644 index 0000000..0b74d41 --- /dev/null +++ b/build-aux/Makefile.each.tail/20-libretools.mk @@ -0,0 +1,89 @@ +# Copyright (C) 2015, 2016 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 . + +ifneq ($(sort $(wildcard $(addprefix $(srcdir)/,$(devtools-files)))),$(sort $(addprefix $(srcdir)/,$(devtools-files)))) +ifeq ($(wildcard $(devtoolsdir)/),) +$(error config.mk:devtoolsdir points to a non-existant directory: $(devtoolsdir)) +endif +endif + +std.src_files += $(libretools-srcs) +std.gen_files += .srcfiles.mk $(devtools-files) +std.out_files += $(filter-out $(std.src_files) $(std.gen_files),$(libretools-files)) \ + $(if $(pots),everything.pot) +std.sys_files += $(addprefix $(bindir)/,$(libretools-bins)) \ + $(addprefix $(pkgconfdir)/,$(libretools-confs)) \ + $(addprefix $(pkglibexecdir)/,$(libretools-libexecs) $(libretools-libs)) \ + $(addprefix $(pkgdocdir)/,$(libretools-docs)) \ + $(addprefix $(mandir)/man1/,$(filter %.1,$(libretools-mans))) \ + $(addprefix $(mandir)/man2/,$(filter %.2,$(libretools-mans))) \ + $(addprefix $(mandir)/man3/,$(filter %.3,$(libretools-mans))) \ + $(addprefix $(mandir)/man4/,$(filter %.4,$(libretools-mans))) \ + $(addprefix $(mandir)/man5/,$(filter %.5,$(libretools-mans))) \ + $(addprefix $(mandir)/man6/,$(filter %.6,$(libretools-mans))) \ + $(addprefix $(mandir)/man7/,$(filter %.7,$(libretools-mans))) \ + $(addprefix $(mandir)/man8/,$(filter %.8,$(libretools-mans))) +std.clean_files += *.pot *.ugly *.rej *.orig .tmp* + +exec_$(outdir) := $(exec_$(outdir)) $(libretools-bins) $(libretools-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 $@ $( $@'; $(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)),$(libretools-files)),) +$(DESTDIR)$(pkglibexecdir)/$(notdir $(outdir)): $(DESTDIR)$(pkglibexecdir)/%: $(outdir)/% ; mkdir -p '$(@D)' && cp -T '$<' '$@' +$(DESTDIR)$(bindir)/$(notdir $(outdir)): $(DESTDIR)$(bindir)/% : $(outdir)/% ; install -T -Dm755 '$<' '$@' +endif diff --git a/build-aux/Makefile.once.head/20-libretools.mk b/build-aux/Makefile.once.head/20-libretools.mk new file mode 100644 index 0000000..48964d9 --- /dev/null +++ b/build-aux/Makefile.once.head/20-libretools.mk @@ -0,0 +1,81 @@ +# 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 . + +# Configure how Make works +MAKEFLAGS += --no-builtin-rules --no-builtin-variables +.SECONDARY: +.DELETE_ON_ERROR: + +.PHONY: FORCE + +# Magic for tracking variables that affect files. If a file changes +# based on a variable, just stick $(var)VARNAME as a dependency. +var = $(call at.path,$(topoutdir)/.var.) +$(var)%: FORCE + @printf '%s' '$($*)' | $(WRITE_IFCHANGED) $@ + +# Usage: OUTPUT +# Expand m4_include macros to use librelib +# This is used when using sources grabbed from devtools +# Magic for doing @variable@ replacement in files +edit = sed \ + -e 's|^\#!\s*/bin/bash|\#!/usr/bin/env bash|' \ + -e 's|m4_include(lib/\(.*\))|. "$$(librelib \1)"|' \ + $(foreach v,$(patsubst $(var)%,%,$(filter $(var)%,$^)), -e 's|@$(v)@|$($(v))|g' ) + +# Usage: $(call indent,FILENAME) +# Command to auto-indent a file. +indent = emacs --batch $1 \ + --eval '(setq make-backup-files nil)' \ + --eval '(setq sh-basic-offset 8)' \ + --eval '(defun sh-smie-sh-rules--fix (args) "fix bug in Emacs 24 sh-script.el" (if (equal args (list :after "then")) (list :after "if") args))' \ + --eval "(advice-add 'sh-smie-sh-rules :filter-args \#'sh-smie-sh-rules--fix)" \ + --eval '(indent-region (point-min) (point-max) nil)' \ + -f save-buffer &>/dev/null + +# Usage OUTPUT +# Normalize a .po(t) file +pofmt = msguniq -Fi --to-code=UTF-8 + +# It's easy to think of these as "each" variables, but because they +# will be evaluated on demand, only std.src_files needs to be "each". +detect-all = $(filter-out $(detect-ignore) ,$(srcfiles)) +detect-exec = $(filter-out $(detect-ignore-exec),$(patsubst $(srcdir)/%,%,$(shell find $(addprefix $(srcdir)/,$(detect-all)) -executable))) +detect-conf = $(filter-out $(detect-ignore-conf),$(filter %.conf ,$(detect-all))) +detect-ronn = $(filter-out $(detect-ignore-ronn),$(filter %.ronn ,$(detect-all))) +detect-md = $(filter-out $(detect-ignore-md) ,$(filter %.ronn %.md,$(detect-all))) +detect-sh = $(filter-out $(detect-ignore-sh) ,$(filter %.sh ,$(detect-all))) + +ifeq ($(wildcard $(topsrcdir)/.git),) +include $(topsrcdir)/.srcversion-libretools.mk +else +$(topsrcdir)/.srcversion-libretools.mk: FORCE + @{ \ + echo LIBRETOOLS_VERSION = $(patsubst v%,%,$(shell cd $(topsrcdir) && git describe --tags)); \ + echo LIBRETOOLS_COMMIT = $(shell cd $(topsrcdir) && git rev-parse HEAD); \ + :; } | $(WRITE_IFCHANGED) $@ +-include $(topsrcdir)/.srcversion-libretools.mk +endif + +ifeq ($(wildcard $(devtoolsdir)/.git),) +include $(topsrcdir)/.srcversion-devtools.mk +else +$(topsrcdir)/.srcversion-devtools.mk: FORCE + @{ \ + echo DEVTOOLS_VERSION = $(patsubst libretools-%,%,$(shell cd $(devtoolsdir) && git describe --tags)); \ + echo DEVTOOLS_COMMIT = $(shell cd $(devtoolsdir) && git rev-parse HEAD); \ + :; } | $(WRITE_IFCHANGED) $@ +-include $(topsrcdir)/.srcversion-devtools.mk +endif diff --git a/build-aux/no-builtin-variables.mk b/build-aux/no-builtin-variables.mk new file mode 100644 index 0000000..c236c73 --- /dev/null +++ b/build-aux/no-builtin-variables.mk @@ -0,0 +1,11 @@ +MAKEFLAGS += --no-builtin-variables + +# This version is more correct, but is slower: +# $(foreach v,$(shell bash -c 'comm -23 <(env -i $(MAKE) -f - <<<"\$$(info \$$(.VARIABLES))all:"|sed "s/ /\n/g"|sort) <(env -i $(MAKE) -R -f - <<<"\$$(info \$$(.VARIABLES))all:"|sed "s/ /\n/g"|sort)'), +# $(if $(filter default,$(origin $v)),$(eval undefine $v))) + +_default_variables = $(foreach v,$(.VARIABLES),$(if $(filter default,$(origin $v)),$v)) +$(foreach v,$(filter-out .% MAKE% SUFFIXES,$(_default_variables))\ + $(filter .LIBPATTERNS MAKEINFO,$(_default_variables)),\ + $(eval undefine $v)) +undefine _default_variables diff --git a/common.each.head.mk b/common.each.head.mk deleted file mode 100644 index e3a269e..0000000 --- a/common.each.head.mk +++ /dev/null @@ -1,35 +0,0 @@ -pkgconfdir = $(sysconfdir)/libretools.d -pkgdocdir = $(docdir)/libretools -pkglibexecdir = $(libexecdir)/libretools - -# Detect things about the directory we're in #################################### - -srcfiles-ignore/$(srcdir) = $(addsuffix /%,$(_am_subdirs/$(@D))) - -ifeq ($(wildcard $(topsrcdir)/.git),) -include $(srcdir)/.srcfiles.mk -else -$(srcdir)/.srcfiles.mk: FORCE - @echo srcfiles = $(filter-out $(srcfiles-ignore/$(@D)),$(shell cd $(@D) && git ls-files)) | $(write-ifchanged) $@ --include $(srcdir)/.srcfiles.mk -endif - -detect-ignore = -detect-ignore-exec = -detect-ignore-conf = -detect-ignore-ronn = -detect-ignore-md = HACKING.md -detect-ignore-sh = - -devtools-files = - -libretools-srcs = $(detect-all) -libretools-mans = $(patsubst %.ronn,%,$(detect-ronn)) -libretools-bins = $(detect-exec) -libretools-libexecs = -libretools-libs = $(detect-sh) -libretools-docs = $(detect-md) $(detect-ronn) -libretools-confs = $(detect-conf) - -libretools-files = $(libretools-mans) $(libretools-bins) $(libretools-libexecs) $(libretools-libs) $(libretools-docs) $(libretools-confs) -pots = $(libretools-bins) $(libretools-libexecs) $(libretools-libs) diff --git a/common.each.tail.mk b/common.each.tail.mk deleted file mode 100644 index e58b5c5..0000000 --- a/common.each.tail.mk +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (C) 2015, 2016 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 . - -ifneq ($(sort $(wildcard $(addprefix $(srcdir)/,$(devtools-files)))),$(sort $(addprefix $(srcdir)/,$(devtools-files)))) -ifeq ($(wildcard $(devtoolsdir)/),) -$(error config.mk:devtoolsdir points to a non-existant directory: $(devtoolsdir)) -endif -endif - -am_src_files += $(libretools-srcs) -am_gen_files += .srcfiles.mk $(devtools-files) -am_out_files += $(filter-out $(am_src_files) $(am_gen_files),$(libretools-files)) \ - $(if $(pots),everything.pot) -am_sys_files += $(addprefix $(bindir)/,$(libretools-bins)) \ - $(addprefix $(pkgconfdir)/,$(libretools-confs)) \ - $(addprefix $(pkglibexecdir)/,$(libretools-libexecs) $(libretools-libs)) \ - $(addprefix $(pkgdocdir)/,$(libretools-docs)) \ - $(addprefix $(mandir)/man1/,$(filter %.1,$(libretools-mans))) \ - $(addprefix $(mandir)/man2/,$(filter %.2,$(libretools-mans))) \ - $(addprefix $(mandir)/man3/,$(filter %.3,$(libretools-mans))) \ - $(addprefix $(mandir)/man4/,$(filter %.4,$(libretools-mans))) \ - $(addprefix $(mandir)/man5/,$(filter %.5,$(libretools-mans))) \ - $(addprefix $(mandir)/man6/,$(filter %.6,$(libretools-mans))) \ - $(addprefix $(mandir)/man7/,$(filter %.7,$(libretools-mans))) \ - $(addprefix $(mandir)/man8/,$(filter %.8,$(libretools-mans))) -am_clean_files += *.pot *.ugly *.rej *.orig .tmp* - -exec_$(outdir) := $(exec_$(outdir)) $(libretools-bins) $(libretools-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 $@ $( $@'; $(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)),$(libretools-files)),) -$(DESTDIR)$(pkglibexecdir)/$(notdir $(outdir)): $(DESTDIR)$(pkglibexecdir)/%: $(outdir)/% ; mkdir -p '$(@D)' && cp -T '$<' '$@' -$(DESTDIR)$(bindir)/$(notdir $(outdir)): $(DESTDIR)$(bindir)/% : $(outdir)/% ; install -T -Dm755 '$<' '$@' -endif diff --git a/common.once.head.mk b/common.once.head.mk deleted file mode 100644 index 33084fa..0000000 --- a/common.once.head.mk +++ /dev/null @@ -1,83 +0,0 @@ -# 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 . - -# Configure how Make works -MAKEFLAGS += --no-builtin-rules --no-builtin-variables -.SECONDARY: -.DELETE_ON_ERROR: - -.PHONY: FORCE - -write-ifchanged = $(topsrcdir)/write-ifchanged - -# Magic for tracking variables that affect files. If a file changes -# based on a variable, just stick $(var)VARNAME as a dependency. -var = $(call _am_path,$(topoutdir)/.var.) -$(var)%: FORCE - @printf '%s' '$($*)' | $(write-ifchanged) $@ - -# Usage: OUTPUT -# Expand m4_include macros to use librelib -# This is used when using sources grabbed from devtools -# Magic for doing @variable@ replacement in files -edit = sed \ - -e 's|^\#!\s*/bin/bash|\#!/usr/bin/env bash|' \ - -e 's|m4_include(lib/\(.*\))|. "$$(librelib \1)"|' \ - $(foreach v,$(patsubst $(var)%,%,$(filter $(var)%,$^)), -e 's|@$(v)@|$($(v))|g' ) - -# Usage: $(call indent,FILENAME) -# Command to auto-indent a file. -indent = emacs --batch $1 \ - --eval '(setq make-backup-files nil)' \ - --eval '(setq sh-basic-offset 8)' \ - --eval '(defun sh-smie-sh-rules--fix (args) "fix bug in Emacs 24 sh-script.el" (if (equal args (list :after "then")) (list :after "if") args))' \ - --eval "(advice-add 'sh-smie-sh-rules :filter-args \#'sh-smie-sh-rules--fix)" \ - --eval '(indent-region (point-min) (point-max) nil)' \ - -f save-buffer &>/dev/null - -# Usage OUTPUT -# Normalize a .po(t) file -pofmt = msguniq -Fi --to-code=UTF-8 - -# It's easy to think of these as "each" variables, but because they -# will be evaluated on demand, only am_src_files needs to be "each". -detect-all = $(filter-out $(detect-ignore) ,$(srcfiles)) -detect-exec = $(filter-out $(detect-ignore-exec),$(patsubst $(srcdir)/%,%,$(shell find $(addprefix $(srcdir)/,$(detect-all)) -executable))) -detect-conf = $(filter-out $(detect-ignore-conf),$(filter %.conf ,$(detect-all))) -detect-ronn = $(filter-out $(detect-ignore-ronn),$(filter %.ronn ,$(detect-all))) -detect-md = $(filter-out $(detect-ignore-md) ,$(filter %.ronn %.md,$(detect-all))) -detect-sh = $(filter-out $(detect-ignore-sh) ,$(filter %.sh ,$(detect-all))) - -ifeq ($(wildcard $(topsrcdir)/.git),) -include $(topsrcdir)/.srcversion-libretools.mk -else -$(topsrcdir)/.srcversion-libretools.mk: FORCE - @{ \ - echo LIBRETOOLS_VERSION = $(patsubst v%,%,$(shell cd $(topsrcdir) && git describe --tags)); \ - echo LIBRETOOLS_COMMIT = $(shell cd $(topsrcdir) && git rev-parse HEAD); \ - :; } | $(write-ifchanged) $@ --include $(topsrcdir)/.srcversion-libretools.mk -endif - -ifeq ($(wildcard $(devtoolsdir)/.git),) -include $(topsrcdir)/.srcversion-devtools.mk -else -$(topsrcdir)/.srcversion-devtools.mk: FORCE - @{ \ - echo DEVTOOLS_VERSION = $(patsubst libretools-%,%,$(shell cd $(devtoolsdir) && git describe --tags)); \ - echo DEVTOOLS_COMMIT = $(shell cd $(devtoolsdir) && git rev-parse HEAD); \ - :; } | $(write-ifchanged) $@ --include $(topsrcdir)/.srcversion-devtools.mk -endif diff --git a/common.once.tail.mk b/common.once.tail.mk deleted file mode 100644 index e69de29..0000000 diff --git a/config.mk b/config.mk index 414f761..5c45630 100644 --- a/config.mk +++ b/config.mk @@ -3,11 +3,14 @@ # differ. We're not a GNU package. ifeq ($(topsrcdir),) -topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -endif + +topoutdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) +topsrcdir := $(topoutdir) + +include $(topsrcdir)/build-aux/no-builtin-variables.mk PACKAGE = libretools -VERSION = $(LIBRETOOLS_VERSION) +VERSION = $(firstword $(LIBRETOOLS_VERSION) 0) DESTDIR = @@ -28,3 +31,5 @@ mandir = $(datarootdir)/man devtoolsdir = $(call abspath,$(topsrcdir)/../devtools-par) RONNFLAGS = --manual='libretools Manual' --organization='Parabola' + +endif diff --git a/src/Makefile b/src/Makefile index e1e5cf4..273a34b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk pkgconfdir = $(sysconfdir) srcfiles-ignore/$(srcdir) = $(addsuffix /%,abslibre-tools chroot-tools devtools gitget lib librefetch toru xbs xbs-abs xbs-abslibre) -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/abslibre-tools/Makefile b/src/abslibre-tools/Makefile index 2903f4a..a1b7765 100644 --- a/src/abslibre-tools/Makefile +++ b/src/abslibre-tools/Makefile @@ -1,4 +1,4 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index 48a1631..96fb837 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -1,19 +1,19 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk pkglibexecdir = $(libexecdir)/libretools/chroot libretools-bins = chcleanup librechroot libremakepkg libretools-libexecs += arch-nspawn chcleanup distcc-tool indent mkarchroot libretools-libs += makechrootpkg.sh devtools-files = makechrootpkg.sh.in mkarchroot.in arch-nspawn.in -am_clean_files += chcleanup.lib +std.clean_files += chcleanup.lib $(srcdir)/makechrootpkg.sh.in: $(srcdir)/%.sh.in: $(devtoolsdir)/%.in cp $< $@ $(outdir)/chcleanup: $(srcdir)/chcleanup.in $(outdir)/chcleanup.lib m4 -I$(@D) -P $< | $(edit) | install -m755 /dev/stdin $@ -$(outdir)/chcleanup.lib: $(call _am_path,$(topoutdir)/src/lib/common.sh) $(outdir)/Makefile +$(outdir)/chcleanup.lib: $(call at.path,$(topoutdir)/src/lib/common.sh) $(outdir)/Makefile bash -c '. $<; declare -f _l plain msg msg2 error' > $@ $(outdir)/distcc-tool.pot: LIBREXGETTEXT_FLAGS+=--simple=errusage @@ -22,6 +22,6 @@ $(DESTDIR)$(bindir)/chcleanup: $(var)bindir $(var)libexecdir mkdir -p $(@D) ln -srfT $(DESTDIR)$(libexecdir)/libretools/chroot/chcleanup $@ -am_depdirs = ../lib +at.depdirs += ../lib -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/devtools/Makefile b/src/devtools/Makefile index 72907f0..6d3f88c 100644 --- a/src/devtools/Makefile +++ b/src/devtools/Makefile @@ -1,12 +1,12 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk libretools-bins += checkpkg find-libdeps finddeps lddd devtools-files = $(addsuffix .in,$(libretools-bins)) -am_sys_files += $(bindir)/find-libprovides +std.sys_files += $(bindir)/find-libprovides $(DESTDIR)$(bindir)/find-libprovides: install -d $(@D) ln -sf find-libdeps $@ -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/gitget/Makefile b/src/gitget/Makefile index 2903f4a..a1b7765 100644 --- a/src/gitget/Makefile +++ b/src/gitget/Makefile @@ -1,4 +1,4 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/lib/Makefile b/src/lib/Makefile index 9e9b4a8..9d52440 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -1,5 +1,5 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk libretools-libs += common.sh conf.sh devtools-files = common.sh.in @@ -42,4 +42,4 @@ $(outdir)/librexgettext.pot: LIBREXGETTEXT_FLAGS += --simple=errusage ###################################################################### -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile index 26ee2ee..b40c15b 100644 --- a/src/librefetch/Makefile +++ b/src/librefetch/Makefile @@ -1,5 +1,5 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk libretools-bins = librefetch librefetch-install libretools-confs += librefetch-makepkg.conf @@ -10,4 +10,4 @@ pots = $(libretools-bins) $(outdir)/librefetch-install: $(var)pkgconfdir $(outdir)/librefetch-makepkg.conf: $(var)bindir -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/toru/Makefile b/src/toru/Makefile index 2903f4a..a1b7765 100644 --- a/src/toru/Makefile +++ b/src/toru/Makefile @@ -1,4 +1,4 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/xbs-abs/Makefile b/src/xbs-abs/Makefile index 248848f..65be914 100644 --- a/src/xbs-abs/Makefile +++ b/src/xbs-abs/Makefile @@ -1,5 +1,5 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk pkgconfdir = $(sysconfdir)/xbs pkglibexecdir = $(libexecdir)/xbs @@ -8,8 +8,8 @@ libretools-bins = libretools-libexecs = helper-abs pots += $(_helpers) devtools-files += $(addsuffix .in,$(_helpers)) -am_out_files += $(_helpers) -am_sys_files += $(addprefix $(pkglibexecdir)/helper-abs.d/,$(_helpers)) +std.out_files += $(_helpers) +std.sys_files += $(addprefix $(pkglibexecdir)/helper-abs.d/,$(_helpers)) $(outdir)/commitpkg: $(srcdir)/commitpkg.in @echo "OUT $@" @@ -24,4 +24,4 @@ $(outdir)/commitpkg: $(srcdir)/commitpkg.in $(DESTDIR)$(pkglibexecdir)/helper-abs.d/%: $(srcdir)/% install -Dm755 '$<' '$@' -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/xbs-abslibre/Makefile b/src/xbs-abslibre/Makefile index c946d5d..71da5e7 100644 --- a/src/xbs-abslibre/Makefile +++ b/src/xbs-abslibre/Makefile @@ -1,8 +1,8 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk pkglibexecdir = $(libexecdir)/xbs libretools-bins = libretools-libexecs = helper-abslibre -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/xbs/Makefile b/src/xbs/Makefile index 974586e..24067e9 100644 --- a/src/xbs/Makefile +++ b/src/xbs/Makefile @@ -1,5 +1,5 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk -include $(topsrcdir)/automake.head.mk +include $(topsrcdir)/build-aux/Makefile.head.mk pkgconfdir = $(sysconfdir)/xbs -include $(topsrcdir)/automake.tail.mk +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/write-ifchanged b/write-ifchanged deleted file mode 100755 index c65fa16..0000000 --- a/write-ifchanged +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -outfile=$1 -tmpfile="$(dirname "$outfile")/.tmp${outfile##*/}" - -cat > "$tmpfile" || exit $? -if cmp -s "$tmpfile" "$outfile"; then - rm -f "$tmpfile" || : -else - mv -f "$tmpfile" "$outfile" -fi -- cgit v1.2.2