summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-08-25 14:18:14 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-09-11 15:43:30 -0400
commitf3030244f64699021ec0d9cd9e4b4d67244d9df1 (patch)
tree2a2ed877b15799cbc33111528e286e6796c45e78
parentdabf1a9cf520d725f8eb767bb0112990f99fde05 (diff)
Make common-devtools.mk unnecessary. Move devtools chroot stuff into chroot-tools
-rw-r--r--Makefile4
-rw-r--r--common-devtools.mk10
-rw-r--r--common.mk105
-rw-r--r--config.mk2
-rw-r--r--doc/Makefile17
-rw-r--r--src/Makefile3
-rw-r--r--src/abslibre-tools/Makefile2
-rw-r--r--src/chroot-tools/.gitignore3
-rw-r--r--src/chroot-tools/Makefile34
-rw-r--r--src/chroot-tools/makechrootpkg.sh.patch (renamed from src/devtools/lib/makechrootpkg.sh.patch)0
-rw-r--r--src/devtools/.gitignore1
-rw-r--r--src/devtools/Makefile76
-rw-r--r--src/devtools/lib/.gitignore2
-rw-r--r--src/fullpkg/Makefile2
-rw-r--r--src/lib/Makefile42
-rw-r--r--src/librefetch/Makefile2
-rw-r--r--src/mips64el-tools/Makefile2
-rw-r--r--src/toru/Makefile2
18 files changed, 138 insertions, 171 deletions
diff --git a/Makefile b/Makefile
index 75d1771..3f95e6e 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ all: PHONY build
copy: PHONY $(addprefix copy-, $(packages))
build: PHONY $(addprefix build-, $(packages))
install: PHONY $(addprefix install-,$(packages))
+clean: PHONY $(addprefix clean-, $(packages))
check:
@cd test && ./testenv $(TESTENVFLAGS) roundup
@@ -33,11 +34,14 @@ check:
$(MAKE) -C $*
%/install: PHONY %
$(MAKE) -C $* install
+%/clean: PHONY %
+ $(MAKE) -C $* clean
.SECONDEXPANSION:
$(addprefix copy-, $(packages)): copy-%: PHONY $$(addsuffix /copy, $$($$*))
$(addprefix build-, $(packages)): build-%: PHONY $$(addsuffix /build, $$($$*))
$(addprefix install-,$(packages)): install-%: PHONY $$(addsuffix /install,$$($$*))
+$(addprefix clean-, $(packages)): clean-%: PHONY $$(addsuffix /clean, $$($$*))
################################################################################
diff --git a/common-devtools.mk b/common-devtools.mk
deleted file mode 100644
index c32db52..0000000
--- a/common-devtools.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-topdir := $(dir $(lastword $(MAKEFILE_LIST)))
-include $(topdir)/config.mk
-
-edit = sed -e 's|m4_include(lib/\(.*\))|. $$(librelib \1)|'
-
-all: PHONY build
-
-FORCE: PHONY
-PHONY:
-.PHONY: FORCE PHONY
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: <INPUT $(edit) >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:
diff --git a/config.mk b/config.mk
index 5a2d77b..548d4d3 100644
--- a/config.mk
+++ b/config.mk
@@ -10,8 +10,6 @@ DESTDIR=
prefix=/usr
exec_prefix=$(prefix)
bindir=$(exec_prefix)/bin
-#sbindir=$(exec_prefix)/sbin
-sbindir=$(exec_prefix)/bin
#libexecdir=$(exec_prefix)/libexec
libexecdir=$(exec_prefix)/lib
diff --git a/doc/Makefile b/doc/Makefile
index 4e496f3..23f8a8f 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,16 +1 @@
-topdir := $(realpath ..)
-include $(topdir)/config.mk
-
-files = $(wildcard *.md)
-
-all: PHONY build
-build: PHONY
-
-install: $(addprefix $(DESTDIR)$(docdir)/libretools/,$(files))
-
-$(DESTDIR)$(docdir)/libretools/%: %
- install -Dm644 '$<' '$@'
-
-FORCE: PHONY
-PHONY:
-.PHONY: FORCE PHONY
+include ../common.mk
diff --git a/src/Makefile b/src/Makefile
index 35a92a0..63f7782 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,3 +1,2 @@
-libre_execdir=$(bindir)
-libre_confdir=$(sysconfdir)
+pkgconfdir=$(sysconfdir)
include ../common.mk
diff --git a/src/abslibre-tools/Makefile b/src/abslibre-tools/Makefile
index 271cc5e..2c76089 100644
--- a/src/abslibre-tools/Makefile
+++ b/src/abslibre-tools/Makefile
@@ -1,3 +1 @@
-libre_execdir=$(bindir)
-libre_confdir=$(sysconfdir)/libretools.d
include ../../common.mk
diff --git a/src/chroot-tools/.gitignore b/src/chroot-tools/.gitignore
new file mode 100644
index 0000000..fbb07f7
--- /dev/null
+++ b/src/chroot-tools/.gitignore
@@ -0,0 +1,3 @@
+makechrootpkg.sh*
+!makechrootpkg.sh.patch
+archroot* \ No newline at end of file
diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile
index 27030e3..7f6a7ea 100644
--- a/src/chroot-tools/Makefile
+++ b/src/chroot-tools/Makefile
@@ -1,3 +1,33 @@
-libre_execdir=$(sbindir)
-libre_confdir=$(sysconfdir)/libretools.d
+# The makechrootpkg flow is:
+# $(devtoolsdir)/*.in -> *.sh.in + *.sh.patch -> *.sh.ugly -> *.sh
+
+copy_files = makechrootpkg.sh.in archroot.in
+libs = makechrootpkg.sh
+progs = archroot
+clean_files = makechrootpkg.sh.ugly* *~
include ../../common.mk
+
+# Copy ###############################################################
+
+makechrootpkg.sh.in: %.sh.in: $(devtoolsdir)/%.in
+ cp $< $@
+
+archroot.in: $(devtoolsdir)/mkarchroot.in
+ cp $< $@
+
+# Build ##############################################################
+
+makechrootpkg.sh.ugly: %.ugly: %.in %.patch Makefile
+ @echo "GEN $@"
+ @cp $*.in $@
+ @patch $@ $*.patch || { rm -f -- '$@'; false; }
+
+makechrootpkg.sh: %: %.ugly Makefile
+ @echo "GEN $@"
+ @$(edit) <"$<" >"$@" || { rm -f -- '$@'; false; }
+ $(call indent,$@) || { rm -f -- '$@'; false; }
+
+archroot: %: %.in Makefile
+ @echo "GEN $@"
+ @$(edit) <"$<" >"$@" || { rm -f -- '$@'; false; }
+ @chmod 755 "$@" || { rm -f -- '$@'; false; }
diff --git a/src/devtools/lib/makechrootpkg.sh.patch b/src/chroot-tools/makechrootpkg.sh.patch
index 505b96a..505b96a 100644
--- a/src/devtools/lib/makechrootpkg.sh.patch
+++ b/src/chroot-tools/makechrootpkg.sh.patch
diff --git a/src/devtools/.gitignore b/src/devtools/.gitignore
index cce9a4c..097fcde 100644
--- a/src/devtools/.gitignore
+++ b/src/devtools/.gitignore
@@ -1,4 +1,3 @@
*
-!*/
!Makefile
!.gitignore
diff --git a/src/devtools/Makefile b/src/devtools/Makefile
index bca9780..6cae230 100644
--- a/src/devtools/Makefile
+++ b/src/devtools/Makefile
@@ -1,76 +1,16 @@
-topdir = ../..
-include ../../common-devtools.mk
+progs = checkpkg find-libdeps finddeps lddd
+copy_files = $(addsuffix .in,$(progs))
+install_files = $(DESTDIR)$(bindir)/find-libprovides
+include ../../common.mk
-######################################################################
-
-pkglibexecdir=$(libexecdir)/libretools
-
-######################################################################
-
-copy: \
- archroot.in \
- checkpkg.in \
- find-libdeps.in \
- finddeps.in \
- lddd.in \
- lib/makechrootpkg.sh.in
-
-archroot.in: $(devtoolsdir)/mkarchroot.in ; cp $< $@
-checkpkg.in: $(devtoolsdir)/checkpkg.in ; cp $< $@
-find-libdeps.in: $(devtoolsdir)/find-libdeps.in ; cp $< $@
-finddeps.in: $(devtoolsdir)/finddeps.in ; cp $< $@
-lddd.in: $(devtoolsdir)/lddd.in ; cp $< $@
-lib/makechrootpkg.sh.in: $(devtoolsdir)/makechrootpkg.in ; cp $< $@
-
-######################################################################
-
-build: \
- archroot \
- checkpkg \
- find-libdeps \
- finddeps \
- lddd \
- lib/makechrootpkg.sh
-
-indent = emacs --batch $1 \
- --eval '(setq sh-basic-offset 8)' \
- --eval '(indent-region (point-min) (point-max) nil)' \
- -f save-buffer &>/dev/null
+# Build ##############################################################
%: %.in Makefile
@echo "GEN $@"
- @$(edit) <"$<" >"$@"
- @chmod 755 "$@"
-
-lib/makechrootpkg.sh.ugly: %.ugly: %.in %.patch Makefile
- @echo "GEN $@"
- @cp $*.in $@
- @patch $@ $*.patch
-
-lib/makechrootpkg.sh: %: %.ugly Makefile
- @echo "GEN $@"
- @$(edit) <"$<" >"$@"
- $(call indent,$@)
-
-######################################################################
-
-install: \
- $(DESTDIR)$(sbindir)/archroot \
- $(DESTDIR)$(bindir)/checkpkg \
- $(DESTDIR)$(bindir)/find-libdeps \
- $(DESTDIR)$(bindir)/find-libprovides \
- $(DESTDIR)$(bindir)/finddeps \
- $(DESTDIR)$(bindir)/lddd \
- $(DESTDIR)$(pkglibexecdir)/makechrootpkg.sh
-
-$(DESTDIR)$(sbindir)/%: %
- install -Dm755 $< $@
-
-$(DESTDIR)$(bindir)/%: %
- install -Dm755 $< $@
+ @$(edit) <"$<" >"$@" || { rm -f -- '$@'; false; }
+ @chmod 755 "$@" || { rm -f -- '$@'; false; }
-$(DESTDIR)$(pkglibexecdir)/%: lib/%
- install -Dm644 $< $@
+# Install ############################################################
$(DESTDIR)$(bindir)/find-libprovides:
install -d $(@D)
diff --git a/src/devtools/lib/.gitignore b/src/devtools/lib/.gitignore
deleted file mode 100644
index 9e428f9..0000000
--- a/src/devtools/lib/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-!*.patch
-!*.top
diff --git a/src/fullpkg/Makefile b/src/fullpkg/Makefile
index 271cc5e..2c76089 100644
--- a/src/fullpkg/Makefile
+++ b/src/fullpkg/Makefile
@@ -1,3 +1 @@
-libre_execdir=$(bindir)
-libre_confdir=$(sysconfdir)/libretools.d
include ../../common.mk
diff --git a/src/lib/Makefile b/src/lib/Makefile
index e0067be..d7b4049 100644
--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -1,17 +1,12 @@
-include ../../common-devtools.mk
-
-pkglibexecdir=$(libexecdir)/libretools
-
-# Copy from devtools #################################################
-
-copy: common.sh.in
-
-common.sh.in: $(devtoolsdir)/lib/common.sh ; cp $< $@
+copy_files = common.sh.in
+libexecs = $(filter-out librelib,$(wildcard libre*))
+# include common.sh in libs explicitly, because it might not exist yet
+# when the wildcard is performed
+libs = $(sort $(wildcard *.sh) common.sh)
+include ../../common.mk
# Build ##############################################################
-build: common.sh
-
common.sh: %: %.in %.top Makefile
@echo "GEN $@"
@{ \
@@ -20,28 +15,3 @@ common.sh: %: %.in %.top Makefile
echo '_INCLUDE_COMMON_SH=true' && \
cat "$*.in" && \
echo 'fi'; } > "$@"
-
-# Install ############################################################
-
-libexecs = $(filter-out librelib,$(wildcard libre*))
-libs = $(wildcard *.sh)
-
-# relative path to `/` from $(bindir)
-rootdir=$(shell sed -r 's|^/||;s|[^/]+|..|g'<<<$(bindir))
-
-install: \
- $(addprefix $(DESTDIR)$(bindir)/,$(libexecs) librelib) \
- $(addprefix $(DESTDIR)$(pkglibexecdir)/,$(libexecs) $(libs))
-
-$(DESTDIR)$(bindir)/librelib: librelib
- install -Dm755 '$<' '$@'
-
-$(DESTDIR)$(bindir)/%: %
- install -d '$(@D)'
- ln -sf '$(rootdir)$(pkglibexecdir)/$(@F)' "$@"
-
-$(DESTDIR)$(pkglibexecdir)/libre%: libre%
- install -Dm755 '$<' '$@'
-
-$(DESTDIR)$(pkglibexecdir)/%.sh: %.sh
- install -Dm644 '$<' '$@'
diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile
index 271cc5e..2c76089 100644
--- a/src/librefetch/Makefile
+++ b/src/librefetch/Makefile
@@ -1,3 +1 @@
-libre_execdir=$(bindir)
-libre_confdir=$(sysconfdir)/libretools.d
include ../../common.mk
diff --git a/src/mips64el-tools/Makefile b/src/mips64el-tools/Makefile
index 271cc5e..2c76089 100644
--- a/src/mips64el-tools/Makefile
+++ b/src/mips64el-tools/Makefile
@@ -1,3 +1 @@
-libre_execdir=$(bindir)
-libre_confdir=$(sysconfdir)/libretools.d
include ../../common.mk
diff --git a/src/toru/Makefile b/src/toru/Makefile
index 271cc5e..2c76089 100644
--- a/src/toru/Makefile
+++ b/src/toru/Makefile
@@ -1,3 +1 @@
-libre_execdir=$(bindir)
-libre_confdir=$(sysconfdir)/libretools.d
include ../../common.mk