summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile68
1 files changed, 68 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..802117a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,68 @@
+# Configuration
+DESTDIR=
+
+#prefix=/usr/local
+prefix=/usr
+exec_prefix=$(prefix)
+datarootdir=$(prefix)/share
+
+bindir=$(exec_prefix)/bin
+sbindir=$(exec_prefix)/sbin
+#sysconfdir=$(prefix)/etc
+sysconfdir=/etc
+datadir=$(datarootdir)
+docdir=$(datarootdir)/doc
+
+################################################################################
+
+pseudo-packages=abslibre-tools chroot-tools fullpkg mips64el-tools pr-tools toru
+packages=libretools libretools-pr libretools-mips64el
+
+libretools=abslibre-tools chroot-tools fullpkg toru misc
+libretools-pr=pr-tools
+libretools-mips64el=mips64el-tools
+
+################################################################################
+
+all: PHONY libretools
+install: PHONY install-libretools install-doc
+
+install-doc: $(patsubst doc/%,$(DESTDIR)$(docdir)/libretools/%,$(wildcard doc/*))
+
+$(DESTDIR)$(docdir)/libretools/%: doc/%
+ install -Dm644 '$<' '$@'
+
+$(DESTDIR)$(sysconfdir)/libretools.conf: src/libretools.conf
+ install -Dm644 '$<' '$@'
+
+$(foreach pkg,$(pseudo-packages) ., \
+$(eval \
+$(DESTDIR)$(bindir)/%: src/$(pkg)/%; \
+ install -Dm755 '$$<' '$$@' \
+) \
+$(eval \
+$(DESTDIR)$(sysconfdir)/libretools.d/%: src/$(pkg)/%; \
+ install -Dm644 '$$<' '$$@' \
+))
+
+################################################################################
+
+progs = $(shell find src/$1 -maxdepth 1 -type f -executable -printf '%f\n')
+confs = $(shell find src/$1 -maxdepth 1 -type f -not -executable -printf '%f\n')
+files = $(addprefix $(DESTDIR)$2/,$(call progs,$1)) \
+ $(addprefix $(DESTDIR)$3/,$(call confs,$1))
+
+.SECONDEXPANSION:
+$(packages): %: PHONY $$($$*)
+$(addprefix install-,$(packages)): install-%: PHONY $$(addprefix install-,$$($$*))
+
+$(pseudo-packages) misc: %: PHONY
+$(addprefix install-,$(pseudo-packages)): install-%: PHONY $$(call files,$$*,$(bindir),$(sysconfdir)/libretools.d)
+# special cases
+install-misc: PHONY $(call files,.,$(bindir),$(sysconfdir))
+
+################################################################################
+
+FORCE: PHONY
+PHONY:
+.PHONY: FORCE PHONY