From dc9339b5699ee3b0d48145a1389f93e9e09d02a6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 30 Jan 2017 14:46:36 -0500 Subject: Update and tidy the build system for autothing v3. --- GNUmakefile | 13 +++ HACKING/build-system.md | 28 ++--- Makefile | 45 ++++---- build-aux/Makefile.each.head/20-libretools.mk | 59 ++++++----- build-aux/Makefile.each.tail/20-libretools.mk | 68 ++++++------ build-aux/Makefile.once.head/00-libretools.mk | 142 ++++++++++++++++++++++++++ build-aux/Makefile.once.head/20-libretools.mk | 83 --------------- build-aux/no-builtin-variables.mk | 15 --- config.mk | 15 +-- src/GNUmakefile | 1 + src/Makefile | 6 +- src/abslibre-tools/GNUmakefile | 1 + src/chroot-tools/GNUmakefile | 1 + src/chroot-tools/Makefile | 19 ++-- src/devtools/.gitignore | 1 + src/devtools/GNUmakefile | 1 + src/devtools/Makefile | 8 +- src/gitget/GNUmakefile | 1 + src/lib/GNUmakefile | 1 + src/lib/Makefile | 8 +- src/librefetch/GNUmakefile | 1 + src/librefetch/Makefile | 14 +-- src/toru/GNUmakefile | 1 + src/xbs-abs/GNUmakefile | 1 + src/xbs-abs/Makefile | 15 +-- src/xbs-abslibre/GNUmakefile | 1 + src/xbs-abslibre/Makefile | 5 +- src/xbs/GNUmakefile | 1 + src/xbs/Makefile | 1 + 29 files changed, 326 insertions(+), 230 deletions(-) create mode 100644 GNUmakefile create mode 100644 build-aux/Makefile.once.head/00-libretools.mk delete mode 100644 build-aux/Makefile.once.head/20-libretools.mk delete mode 100644 build-aux/no-builtin-variables.mk create mode 120000 src/GNUmakefile create mode 120000 src/abslibre-tools/GNUmakefile create mode 120000 src/chroot-tools/GNUmakefile create mode 120000 src/devtools/GNUmakefile create mode 120000 src/gitget/GNUmakefile create mode 120000 src/lib/GNUmakefile create mode 120000 src/librefetch/GNUmakefile create mode 120000 src/toru/GNUmakefile create mode 120000 src/xbs-abs/GNUmakefile create mode 120000 src/xbs-abslibre/GNUmakefile create mode 120000 src/xbs/GNUmakefile diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..0cdb67d --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,13 @@ +# This file is a hack to let us pass whatever flags we want to Make, +# since adjusting MAKEFLAGS at runtime only half-works. +# +# Most of the complexity is dancing around to avoid having any +# possibly conflicting identifiers. + +MAKEFLAGS += --no-print-directory +rest = $(wordlist 2,$(words $1),$1) +target = $(or $(firstword $(MAKECMDGOALS)),default) +$(or $(call rest,$(MAKECMDGOALS)),_$(target)): $(target) + @: +$(target): + @+$(MAKE) -f Makefile --no-builtin-rules --no-builtin-variables --warn-undefined-variables $(MAKECMDGOALS) diff --git a/HACKING/build-system.md b/HACKING/build-system.md index 40abd28..6c8381a 100644 --- a/HACKING/build-system.md +++ b/HACKING/build-system.md @@ -1,20 +1,24 @@ 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. +snippet system for GNU Make that I (lukeshu) 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 `module.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 `$(topsrcdir)/.git` exists, it knows to use git to generate it; otherwise it expects the file to exist: -| variable | file | -|--------------------+----------------------------------------| -| srcfiles | $(srcdir)/.srcfiles.mk | -| LIBRETOOLS_VERSION | $(topsrcdir)/.srcversion-libretools.mk | -| LIBRETOOLS_COMMIT | $(topsrcdir)/.srcversion-libretools.mk | -| DEVTOOLS_VERSION | $(topsrcdir)/.srcversion-devtools.mk | -| DEVTOOLS_COMMIT | $(topsrcdir)/.srcversion-devtools.mk | +| variable | file | +|----------------------+------------------------------------------| +| `files.src.src` | `$(topsrcdir)/.srcfiles.mk` | +| `LIBRETOOLS_VERSION` | `$(topsrcdir)/.srcversion-libretools.mk` | +| `LIBRETOOLS_COMMIT` | `$(topsrcdir)/.srcversion-libretools.mk` | +| `DEVTOOLS_VERSION` | `$(topsrcdir)/.srcversion-devtools.mk` | +| `DEVTOOLS_COMMIT` | `$(topsrcdir)/.srcversion-devtools.mk` | -`srcfiles` basically becomes `std.src_files`. +Now, the `Makefile`s in each directory are pretty bare. Most of +everything can be guesses by inspecting `$(files.src.src)` (Want to +add a shell program? Just commit the executable; the Makefile will +see it.) So, most of the real Makefile stuff is in the files +`build-aux/Makefile.*/??-libretools.mk`. diff --git a/Makefile b/Makefile index 0e9caa2..5e83abc 100644 --- a/Makefile +++ b/Makefile @@ -2,40 +2,47 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/config.mk include $(topsrcdir)/build-aux/Makefile.head.mk # these are the resulting packages -packages=libretools librelib gitget xbs +pkgs=libretools librelib gitget xbs # and which directories they contain -libretools=\ +pkg.libretools=\ src \ src/abslibre-tools \ src/chroot-tools \ src/devtools \ src/librefetch \ src/toru -librelib=src/lib -gitget=src/gitget -xbs=\ +pkg.librelib=src/lib +pkg.gitget=src/gitget +pkg.xbs=\ src/xbs \ src/xbs-abs \ src/xbs-abslibre -verbs=build install uninstall mostlyclean clean distclean maintainer-clean check -$(foreach verb,$(verbs),$(foreach package,$(packages),$(eval $(verb)-$(package): $(addsuffix /$(verb),$($(package)))))) -$(foreach verb,$(verbs),$(foreach package,$(packages),$(eval .PHONY: $(verb)-$(package)))) +define _pkg_rule +%(verb)-%(pkg): $(addsuffix /%(verb),$(pkg.%(pkg))) +.PHONY: %(verb)-%(pkg) +endef +$(eval $(foreach verb,$(nested.targets),$(foreach pkg,$(pkgs),\ + $(subst %(verb),$(verb),$(subst %(pkg),$(pkg),$(value _pkg_rule)))$(at.nl)))) -$(outdir)/check:: +$(outdir)/check: cd $(@D)/test && ./testenv $(TESTENVFLAGS) roundup _po_rule = \ -po/%(package).pot: $(addsuffix /everything.pot,$(%(package))); \ - cat $^ | msguniq -Fi --to-code=UTF-8 > '$@' || rm -f '$@' -$(foreach package,$(packages),$(eval $(subst %(package),$(package),$(value _po_rule)))) +po/%(pkg).pot: $(addsuffix /everything.pot,$(pkg.%(pkg))); \ + cat $^ | msguniq -Fi --to-code=UTF-8 > '$@' +$(eval $(foreach pkg,$(pkgs),\ + $(subst %(pkg),$(pkg),$(value _po_rule))$(at.nl))) -pots = -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/% +libretools.out.mans = +libretools.out.bins = +libretools.out.libexecs = +libretools.out.libs = +libretools.out.docs = +libretools.out.confs = +libretools.out = $(foreach pkg,$(pkgs),po/$(pkg).pot) + +files.src.gen += .srcversion-libretools.mk .srcversion-devtools.mk +nested.subdirs = $(foreach pkg,$(pkgs),$(pkg.$(pkg))) 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 index 90e9bda..20abd8b 100644 --- a/build-aux/Makefile.each.head/20-libretools.mk +++ b/build-aux/Makefile.each.head/20-libretools.mk @@ -1,35 +1,40 @@ +# Copyright (C) 2017 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 . + 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 +# Auto-detect ######################################################## -detect-ignore = -detect-ignore-exec = -detect-ignore-conf = -detect-ignore-ronn = -detect-ignore-md = HACKING.md -detect-ignore-sh = +libretools.src.devtools = -devtools-files = +libretools.out.mans = $(patsubst %.ronn,%,$(libretools.src.ronn)) +libretools.out.bins = $(libretools.src.exec) +libretools.out.libexecs = +libretools.out.libs = $(libretools.src.sh) +libretools.out.docs = $(libretools.src.md) +libretools.out.confs = $(libretools.src.conf) -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.out = $(libretools.out.mans) +libretools.out += $(libretools.out.bins) +libretools.out += $(libretools.out.libexecs) +libretools.out += $(libretools.out.libs) +libretools.out += $(libretools.out.docs) +libretools.out += $(libretools.out.confs) -libretools-files = $(libretools-mans) $(libretools-bins) $(libretools-libexecs) $(libretools-libs) $(libretools-docs) $(libretools-confs) -pots = $(libretools-bins) $(libretools-libexecs) $(libretools-libs) +libretools.pots = $(libretools.out.bins) +libretools.pots += $(libretools.out.libexecs) +libretools.pots += $(libretools.out.libs) diff --git a/build-aux/Makefile.each.tail/20-libretools.mk b/build-aux/Makefile.each.tail/20-libretools.mk index 0b74d41..c498396 100644 --- a/build-aux/Makefile.each.tail/20-libretools.mk +++ b/build-aux/Makefile.each.tail/20-libretools.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2015, 2016 Luke Shumaker +# Copyright (C) 2015-2017 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 @@ -13,40 +13,41 @@ # 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)))) +ifneq ($(sort $(wildcard $(addprefix $(srcdir)/,$(libretools.src.devtools)))),$(sort $(addprefix $(srcdir)/,$(libretools.src.devtools)))) 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)) +# Connect with `files` module ######################################## +files.src.gen += $(libretools.src.devtools) +files.out.all += $(filter-out $(files.src),$(libretools.out)) \ + $(if $(libretools.pots),everything.pot) +files.sys.all += $(addprefix $(bindir)/,$(libretools.out.bins)) \ + $(addprefix $(pkgconfdir)/,$(libretools.out.confs)) \ + $(addprefix $(pkglibexecdir)/,$(libretools.out.libexecs) $(libretools.out.libs)) \ + $(addprefix $(pkgdocdir)/,$(libretools.out.docs)) \ + $(addprefix $(mandir)/man1/,$(filter %.1,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man2/,$(filter %.2,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man3/,$(filter %.3,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man4/,$(filter %.4,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man5/,$(filter %.5,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man6/,$(filter %.6,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man7/,$(filter %.7,$(libretools.out.mans))) \ + $(addprefix $(mandir)/man8/,$(filter %.8,$(libretools.out.mans))) +files.out.int += *.pot *.ugly *.rej *.orig +# Generate rules ##################################################### $(srcdir)/%.in: $(devtoolsdir)/%.in cp -T '$<' '$@' $(srcdir)/%.in: $(devtoolsdir)/lib/% cp -T '$<' '$@' + +# Build rules ######################################################## +_is_executable = $(filter $(libretools.out.bins) $(libretools.out.libexecs),$(@F)) + $(outdir)/%: $(srcdir)/%.in - @echo 'EDIT < $< > $@'; $(edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@' + @echo 'EDIT < $< > $@'; $(libretools.edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@' $(outdir)/%: $(srcdir)/%.ronn ronn --roff $(RONNFLAGS) < '$<' > '$@' $(outdir)/%.html: $(srcdir)/%.ronn @@ -55,19 +56,20 @@ $(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) > '$@' +$(outdir)/everything.pot: $(addprefix $(outdir)/,$(addsuffix .pot,$(libretools.pots))) + cat $^ | $(libretools.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))) +_do_patch = $(filter $(patsubst %.patch,%,$(filter %.patch,$(libretools.src.git))),$(patsubst %.in,%,$(libretools.src.devtools))) $(outdir)/%.ugly: $(srcdir)/%.in $(srcdir)/%.patch cp -T $< $@ patch $@ $( $@'; $(edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@' - @echo 'INDENT $@'; $(call indent,$@) - + @echo 'EDIT < $< > $@'; $(libretools.edit) < '$<' | install -T -m$(if $(_is_executable),755,644) /dev/stdin '$@' + @echo 'INDENT $@'; $(call libretools.indent,$@) + +# Install rules ###################################################### $(DESTDIR)$(pkgconfdir)/% : $(outdir)/% ; install -T -Dm644 '$<' '$@' $(DESTDIR)$(pkgdocdir)/% : $(outdir)/% ; install -T -Dm644 '$<' '$@' $(DESTDIR)$(mandir)/man1/%.1: $(outdir)/%.1; install -T -Dm644 '$<' '$@' @@ -78,12 +80,12 @@ $(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)$(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 '$<' '$@' +ifneq ($(filter $(notdir $(outdir)),$(libretools.out)),) +$(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/00-libretools.mk b/build-aux/Makefile.once.head/00-libretools.mk new file mode 100644 index 0000000..8497d68 --- /dev/null +++ b/build-aux/Makefile.once.head/00-libretools.mk @@ -0,0 +1,142 @@ +# Copyright (C) 2015, 2017 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 . + +mod.libretools.description = (libretools) build rules +define mod.libretools.doc +# Inputs: +# - Install paths (Directory variables): +# - `pkgconfdir = $(sysconfdir)/libretools.d` +# - `pkgdocdir = $(docdir)/libretools` +# - `pkglibexecdir = $(libexecdir)/libretools` +# - Outputs (Directory variables): +# - `libretools.out.mans` +# - `libretools.out.bins` +# - `libretools.out.libexecs` +# - `libretools.out.libs` +# - `libretools.out.docs` +# - `libretools.out.confs` +# - `libretools.out` +# - Misc (Directory variables): +# - `libretools.src.devtools` +# - `libretools.pots` +# Outputs: +# - Autothing module configuration (Global variables): +# - `gitfiles.file` +# - `var` +# - Shell commands (Global variables) +# - `libretools.edit` +# - `libretools.indent` +# - `libretools.pofmt` +# - Source information +# - Directory variable : `libretools.src` +# - Directory variable : `libretools.src.exec` +# - Directory variable : `libretools.src.conf` +# - Directory variable : `libretools.src.ronn` +# - Directory variable : `libretools.src.md` +# - Directory variable : `libretools.src.sh` +# - File : `$(topsrcdir)/.srcversion-libretools.mk` +# - Global variable : `LIBRETOOLS_VERSION` +# - Global variable : `LIBRETOOLS_COMMIT` +# - File : `$(topsrcdir)/.srcversion-devtools.mk` +# - Global variable : `DEVTOOLS_VERSION` +# - Global variable : `DEVTOOLS_COMMIT` +# - Primary outputs: +# - Directory variable : `files.src.gen` +# - Directory variable : `files.out.all` +# - Directory variable : `files.sys.all` +# - Directory variable : `files.out.int` +# - Target : `$(srcdir)/%.in: $(devtoolsdir)/%.in` +# - Target : `$(outdir)/%: $(srcdir)/%.in` +# - Target : `$(outdir)/% : $(srcdir)/%.ronn` +# - Target : `$(outdir)/%.html: $(srcdir)/%.ronn` +# - Target : `$(outdir)/%.pot: $(outdir)/%` +# - Target : `$(outdir)/%.pot: $(srcdir)/%` +# - Target : `$(outdir)/everything.pot` +# - Target : `$(outdir)/%.ugly: $(srcdir)/%.in $(srcdir)/%.patch` +# - Target : `$(outdir)/%: $(outdir)/%.ugly +# - Target : `$(DESTDIR)...:` +# Misc: +# - Variable: `LIBREXGETTEXT_FLAGS` +endef +mod.quote.doc := $(value mod.quote.doc) + +# Configure how Make works ########################################### +.SECONDARY: +.DELETE_ON_ERROR: + +# Configure how Autothing modules work ############################### +gitfiles.file = .srcfiles.mk + +# Boilerplate ######################################################## +.PHONY: FORCE + +# Commands ########################################################### + +# 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 +libretools.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 libretools.indent,FILENAME) +# Command to auto-indent a file. +libretools.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 +libretools.pofmt = msguniq -Fi --to-code=UTF-8 + +# Auto-detect ######################################################## + +# It's easy to think of these as "each" variables, but because they +# will be evaluated on demand, only files.src.src needs to be "each". +libretools.src.git = $(files.src.src) +libretools.src.exec = $(patsubst $(srcdir)/%,%,$(shell find $(addprefix $(srcdir)/,$(libretools.src.git)) -executable 2>/dev/null)) +libretools.src.conf = $(filter %.conf,$(libretools.src.git)) +libretools.src.sh = $(filter %.sh ,$(libretools.src.git)) +libretools.src.ronn = $(filter %.ronn,$(libretools.src.git)) +libretools.src.md = $(filter-out HACKING.md,$(filter %.ronn %.md,$(libretools.src.git))) + +LIBREXGETTEXT_FLAGS ?= + +# Git Version ######################################################## + +-include $(topsrcdir)/.srcversion-libretools.mk +-include $(topsrcdir)/.srcversion-devtools.mk + +ifneq ($(wildcard $(topsrcdir)/.git),) +$(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) $@ +endif + +ifneq ($(wildcard $(devtoolsdir)/.git),) +$(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) $@ +endif diff --git a/build-aux/Makefile.once.head/20-libretools.mk b/build-aux/Makefile.once.head/20-libretools.mk deleted file mode 100644 index d7c3b0e..0000000 --- a/build-aux/Makefile.once.head/20-libretools.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 - -# 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))) - -LIBREXGETTEXT_FLAGS ?= - -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 deleted file mode 100644 index c3aef58..0000000 --- a/build-aux/no-builtin-variables.mk +++ /dev/null @@ -1,15 +0,0 @@ -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 - -# Because Make uses .LIBPATTERNS internally, it should always be -# defined in case --warn-undefined-variables -.LIBPATTERNS ?= diff --git a/config.mk b/config.mk index 69a1bb9..0d564e0 100644 --- a/config.mk +++ b/config.mk @@ -2,16 +2,15 @@ # indicate what the GNU standards dictate, when our values # differ. We're not a GNU package. -ifeq ($(topsrcdir),) +ifeq ($(origin topsrcdir),undefined) +topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) +topoutdir := $(topsrcdir) -topoutdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -topsrcdir := $(topoutdir) - -MAKEFLAGS += --warn-undefined-variables -include $(topsrcdir)/build-aux/no-builtin-variables.mk +# In case .srcversion-libretools.mk hasn't been generated yet. +LIBRETOOLS_VERSION ?= 0 PACKAGE = libretools -VERSION = $(firstword $(LIBRETOOLS_VERSION) 0) +VERSION = $(LIBRETOOLS_VERSION) DESTDIR = @@ -35,4 +34,6 @@ RONNFLAGS = --manual='libretools Manual' --organization='Parabola' TESTENVFLAGS ?= +.LIBPATTERNS ?= + endif diff --git a/src/GNUmakefile b/src/GNUmakefile new file mode 120000 index 0000000..bb60b1e --- /dev/null +++ b/src/GNUmakefile @@ -0,0 +1 @@ +../GNUmakefile \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 273a34b..2ba9534 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,11 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../config.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) +# Because against all common sense, the subdirectories of this +# directory aren't `nested.subdirs`, gitfiles includes the files in +# them in `files.src.src`. So, filter-out everything with a slash. +files.src.src := $(foreach f,$(files.src.src),$(if $(findstring /,$f),, $f )) include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/abslibre-tools/GNUmakefile b/src/abslibre-tools/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/abslibre-tools/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/chroot-tools/GNUmakefile b/src/chroot-tools/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/chroot-tools/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index 96fb837..93655d7 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -1,27 +1,28 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.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 -std.clean_files += chcleanup.lib +libretools.src.devtools = makechrootpkg.sh.in mkarchroot.in arch-nspawn.in +libretools.out.bins = chcleanup librechroot libremakepkg +libretools.out.libexecs = arch-nspawn chcleanup distcc-tool indent mkarchroot +libretools.out.libs = $(libretools.src.sh) makechrootpkg.sh +files.out.int += 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 $@ + m4 -I$(@D) -P $< | $(libretools.edit) | install -m755 /dev/stdin $@ $(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 -$(DESTDIR)$(bindir)/chcleanup: $(var)bindir $(var)libexecdir - mkdir -p $(@D) +$(DESTDIR)$(bindir)/chcleanup: $(var.)bindir $(var.)libexecdir + $(MKDIR_P) $(@D) ln -srfT $(DESTDIR)$(libexecdir)/libretools/chroot/chcleanup $@ -at.depdirs += ../lib +at.subdirs += ../lib include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/devtools/.gitignore b/src/devtools/.gitignore index d669bbd..b9fef64 100644 --- a/src/devtools/.gitignore +++ b/src/devtools/.gitignore @@ -1,4 +1,5 @@ * +!GNUmakefile !Makefile !.gitignore !*.patch diff --git a/src/devtools/GNUmakefile b/src/devtools/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/devtools/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/devtools/Makefile b/src/devtools/Makefile index 6d3f88c..4b7af11 100644 --- a/src/devtools/Makefile +++ b/src/devtools/Makefile @@ -1,12 +1,12 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk -libretools-bins += checkpkg find-libdeps finddeps lddd -devtools-files = $(addsuffix .in,$(libretools-bins)) -std.sys_files += $(bindir)/find-libprovides +libretools.out.bins = checkpkg find-libdeps finddeps lddd +libretools.src.devtools = $(addsuffix .in,$(libretools.out.bins)) +files.sys.all += $(bindir)/find-libprovides $(DESTDIR)$(bindir)/find-libprovides: - install -d $(@D) + $(MKDIR_P) $(@D) ln -sf find-libdeps $@ include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/gitget/GNUmakefile b/src/gitget/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/gitget/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/lib/GNUmakefile b/src/lib/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/lib/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/lib/Makefile b/src/lib/Makefile index 9d52440..eb2ffde 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -1,12 +1,12 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk -libretools-libs += common.sh conf.sh -devtools-files = common.sh.in +libretools.src.devtools = common.sh.in +libretools.out.libs += common.sh conf.sh # Build ############################################################## -$(outdir)/conf.sh: $(var)sysconfdir $(var)pkgconfdir +$(outdir)/conf.sh: $(var.)sysconfdir $(var.)pkgconfdir $(outdir)/common.sh: $(outdir)/%: $(srcdir)/%.in $(srcdir)/%.head $(srcdir)/%.tail $(outdir)/Makefile @echo "OUT $@" @@ -33,7 +33,7 @@ $(outdir)/blacklist.sh.pot: $(srcdir)/blacklist.sh $(srcdir)/librexgettext sed -r -e 's/^# (.*)/msgid "\1"\nmsgstr ""\n/' \ -e 's|^[0-9]*$$|#. embedded usage text\n#: $<:&|' && \ $( $@ + :; } | $(libretools.pofmt) > $@ $(outdir)/common.sh.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 $(outdir)/conf.sh.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 $(outdir)/librelib.pot : LIBREXGETTEXT_FLAGS += --simple=_l:2 diff --git a/src/librefetch/GNUmakefile b/src/librefetch/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/librefetch/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile index b40c15b..f11f0ed 100644 --- a/src/librefetch/Makefile +++ b/src/librefetch/Makefile @@ -1,13 +1,13 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk -libretools-bins = librefetch librefetch-install -libretools-confs += librefetch-makepkg.conf -libretools-libexecs += $(filter librefetchdir/%,$(detect-exec)) -libretools-libs += $(filter-out $(libretools-libexecs),$(filter librefetchdir/%,$(detect-all))) -pots = $(libretools-bins) +libretools.out.bins = librefetch librefetch-install +libretools.out.confs = $(libretools.src.conf) librefetch-makepkg.conf +libretools.out.libexecs = $(filter librefetchdir/%,$(libretools.src.exec)) +libretools.out.libs = $(filter-out $(libretools.out.libexecs),$(filter librefetchdir/%,$(libretools.src.git))) +libretools.pots = $(libretools.out.bins) -$(outdir)/librefetch-install: $(var)pkgconfdir -$(outdir)/librefetch-makepkg.conf: $(var)bindir +$(outdir)/librefetch-install: $(var.)pkgconfdir +$(outdir)/librefetch-makepkg.conf: $(var.)bindir include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/toru/GNUmakefile b/src/toru/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/toru/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/xbs-abs/GNUmakefile b/src/xbs-abs/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/xbs-abs/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/xbs-abs/Makefile b/src/xbs-abs/Makefile index 65be914..2d3d297 100644 --- a/src/xbs-abs/Makefile +++ b/src/xbs-abs/Makefile @@ -1,15 +1,16 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk + pkgconfdir = $(sysconfdir)/xbs pkglibexecdir = $(libexecdir)/xbs -_helpers = archrelease commitpkg -libretools-bins = -libretools-libexecs = helper-abs -pots += $(_helpers) -devtools-files += $(addsuffix .in,$(_helpers)) -std.out_files += $(_helpers) -std.sys_files += $(addprefix $(pkglibexecdir)/helper-abs.d/,$(_helpers)) +_helpers = archrelease commitpkg +libretools.out.bins = +libretools.out.libexecs = helper-abs +libretools.pots += $(_helpers) +libretools.src.devtools += $(addsuffix .in,$(_helpers)) +files.out.all += $(_helpers) +files.sys.all += $(addprefix $(pkglibexecdir)/helper-abs.d/,$(_helpers)) $(outdir)/commitpkg: $(srcdir)/commitpkg.in @echo "OUT $@" diff --git a/src/xbs-abslibre/GNUmakefile b/src/xbs-abslibre/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/xbs-abslibre/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/xbs-abslibre/Makefile b/src/xbs-abslibre/Makefile index 71da5e7..a86b958 100644 --- a/src/xbs-abslibre/Makefile +++ b/src/xbs-abslibre/Makefile @@ -1,8 +1,9 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk + pkglibexecdir = $(libexecdir)/xbs -libretools-bins = -libretools-libexecs = helper-abslibre +libretools.out.bins = +libretools.out.libexecs = helper-abslibre include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/xbs/GNUmakefile b/src/xbs/GNUmakefile new file mode 120000 index 0000000..54fdd42 --- /dev/null +++ b/src/xbs/GNUmakefile @@ -0,0 +1 @@ +../../GNUmakefile \ No newline at end of file diff --git a/src/xbs/Makefile b/src/xbs/Makefile index 24067e9..bc9f4c8 100644 --- a/src/xbs/Makefile +++ b/src/xbs/Makefile @@ -1,5 +1,6 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk + pkgconfdir = $(sysconfdir)/xbs include $(topsrcdir)/build-aux/Makefile.tail.mk -- cgit v1.2.2