From f3030244f64699021ec0d9cd9e4b4d67244d9df1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 25 Aug 2013 14:18:14 -0400 Subject: Make common-devtools.mk unnecessary. Move devtools chroot stuff into chroot-tools --- common.mk | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-) (limited to 'common.mk') diff --git a/common.mk b/common.mk index 60e3630..6c29c03 100644 --- a/common.mk +++ b/common.mk @@ -1,17 +1,67 @@ topdir := $(dir $(lastword $(MAKEFILE_LIST))) include $(topdir)/config.mk +pkgconfdir ?= $(sysconfdir)/libretools.d +pkglibexecdir ?= $(libexecdir)/libretools -################################################################################ +# Misc variables for use in recipes ############################################ -progs = $(shell find . -maxdepth 1 -type f -executable -printf '%f\n') -confs = $(shell find . -maxdepth 1 -type f -name '*.conf' -printf '%f\n') -mans = $(shell find . -maxdepth 1 -type f -name '*.ronn' -printf '%f\n' | sed 's/\.ronn$$//') +# Usage: OUTPUT +# Expand m4_include macros to use librelib +# This is used when using sources grabbed from devtools +edit = sed -e 's|m4_include(lib/\(.*\))|. $$(librelib \1)|' + +# Usage $(call indent,FILENAME) +# Command to auto-indent a file. +indent = emacs --batch $1 \ + --eval '(setq sh-basic-offset 8)' \ + --eval '(indent-region (point-min) (point-max) nil)' \ + -f save-buffer &>/dev/null + +# Usage: as a variable +# relative path to `/` from $(bindir) +# used for symlinking libexec files +rootdir = $(shell sed -r 's|^/||;s|[^/]+|..|g'<<<$(bindir)) + +# Detect things aboud the director we're in #################################### + +progs += $(filter-out $(no-progs),$(shell find . -maxdepth 1 -type f -executable -printf '%f\n')) +confs += $(filter-out $(no-conf) ,$(wildcard *.conf)) +mans += $(filter-out $(no-mans) ,$(patsubst %.ronn,%,$(wildcard *.ronn))) +docs += $(filter-out $(no-docs) ,$(wildcard *.md) $(wildcard *.ronn)) +libexecs += +libs += + +copy_files += +build_files += $(progs) $(confs) $(mans) $(patsubst %.in,%,$(copy_files)) +install_files += $(addprefix $(DESTDIR)$(bindir)/,$(progs)) \ + $(addprefix $(DESTDIR)$(pkgconfdir)/,$(confs)) \ + $(addprefix $(DESTDIR)$(pkglibexecdir)/,$(libexecs) $(libs)) \ + $(addprefix $(DESTDIR)$(docdir)/libretools/,$(docs)) \ + $(addprefix $(DESTDIR)$(mandir)/man1/,$(filter %.1,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man2/,$(filter %.2,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man3/,$(filter %.3,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man4/,$(filter %.4,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man5/,$(filter %.5,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man6/,$(filter %.6,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man7/,$(filter %.7,$(mans))) \ + $(addprefix $(DESTDIR)$(mandir)/man8/,$(filter %.8,$(mans))) +clean_files += $(patsubst %.in,%,$(copy_files)) $(copy_files) $(mans) $(wildcard *.pot) + +# Set the default target ####################################################### all: PHONY build -################################################################################ +# Copy (files from devtools) ################################################### + +copy: PHONY $(copy_files) + +%.in: $(devtoolsdir)/%.in + cp $< $@ +%.in: $(devtoolsdir)/lib/% + cp $< $@ + +# Build ######################################################################## -build_files = $(progs) $(confs) $(mans) build: PHONY $(build_files) %: %.ronn @@ -19,25 +69,29 @@ build: PHONY $(build_files) %.html: %.ronn ronn --html $(RONNFLAGS) < '$<' > '$@' -################################################################################ - -install_files = $(addprefix $(DESTDIR)$(libre_execdir)/,$(progs)) \ - $(addprefix $(DESTDIR)$(libre_confdir)/,$(confs)) \ - $(addprefix $(DESTDIR)$(mandir)/man1/,$(filter %.1,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man2/,$(filter %.2,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man3/,$(filter %.3,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man4/,$(filter %.4,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man5/,$(filter %.5,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man6/,$(filter %.6,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man7/,$(filter %.7,$(mans))) \ - $(addprefix $(DESTDIR)$(mandir)/man8/,$(filter %.8,$(mans))) +# Install ###################################################################### + install: PHONY $(install_files) -$(DESTDIR)$(libre_execdir)/%: % +# We sort the explicit targets because sort also removes duplicates; in a few +# cases, a target could be listed twice, which is a warning. + +# bindir: $(progs) vs $(libexecs) +$(sort $(addprefix $(DESTDIR)$(bindir)/,$(filter-out $(libexecs),$(progs)))): $(DESTDIR)$(bindir)/%: % + install -Dm755 '$<' '$@' +$(sort $(addprefix $(DESTDIR)$(bindir)/,$(libexecs))): $(DESTDIR)$(bindir)/%: % + install -d '$(@D)' + ln -sf '$(rootdir)$(pkglibexecdir)/$(@F)' "$@" +# pkglibexecdir: $(libexecs) vs $(libs) +$(sort $(addprefix $(DESTDIR)$(pkglibexecdir)/,$(libexecs))): $(DESTDIR)$(pkglibexecdir)/%: % install -Dm755 '$<' '$@' -$(DESTDIR)$(libre_confdir)/%: % +$(sort $(addprefix $(DESTDIR)$(pkglibexecdir)/,$(libs))): $(DESTDIR)$(pkglibexecdir)/%: % + install -Dm644 '$<' '$@' +# everything else +$(DESTDIR)$(pkgconfdir)/%: % + install -Dm644 '$<' '$@' +$(DESTDIR)$(docdir)/libretools/%: % install -Dm644 '$<' '$@' - $(DESTDIR)$(mandir)/man1/%.1: %.1 install -Dm644 '$<' '$@' $(DESTDIR)$(mandir)/man2/%.2: %.2 @@ -55,7 +109,14 @@ $(DESTDIR)$(mandir)/man7/%.7: %.7 $(DESTDIR)$(mandir)/man8/%.8: %.8 install -Dm644 '$<' '$@' -################################################################################ +# Clean ######################################################################## + +clean: PHONY clean-hook + rm -f -- $(clean_files) + +clean-hook: PHONY + +# Boiler-plate ################################################################# FORCE: PHONY PHONY: -- cgit v1.2.3-54-g00ecf