diff --git a/Makefile b/Makefile index 3ed586f..7786f79 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +# Override PREFIX for another root installation directory PREFIX ?= $(HOME)/.local BINDIR := $(PREFIX)/bin MANDIR := $(PREFIX)/man/man1 @@ -9,6 +10,19 @@ TPLS := $(addprefix $(DATADIR)/, $(notdir $(wildcard tpl/*))) TESTFILES := $(addprefix $(TESTSDIR)/, $(notdir $(wildcard tpl/tests/*))) TESTSRCFILES := $(addprefix $(TESTSSRCDIR)/, $(notdir $(wildcard tpl/tests/src/*))) +# Pattern rules + +$(DATADIR)/%: tpl/% + install -m 0644 $< $@ + +$(TESTSDIR)/%: tpl/tests/% + install -m 0644 $< $@ + +$(TESTSSRCDIR)/%: tpl/tests/src/% + install -m 0644 $< $@ + +# Targets + .PHONY: all all: \ @@ -21,7 +35,9 @@ $(BINDIR)/mkproj \ $(MANDIR)/mkproj.1 \ $(TPLS) \ $(TESTFILES) \ +$(TESTSDIR)/Makefile \ $(TESTSRCFILES) \ +$(TESTSSRCDIR)/src/precomp.hpp \ $(HOME)/.config/mkprojrc $(BINDIR): @@ -40,22 +56,17 @@ $(MANDIR)/mkproj.1: mkproj.1 $(DATADIR): mkdir -p $@ -$(DATADIR)/%: tpl/% - install -m 0644 $< $@ - $(TESTSDIR): mkdir -p $@ - cd $(TESTSDIR) && ln -s ../Makefile Makefile + +$(TESTSDIR)/Makefile: + cd $(TESTSDIR) && ln -fs ../Makefile Makefile $(TESTSSRCDIR): mkdir -p $@ - cd $(TESTSSRCDIR) && ln -s ../../src/precomp.hpp precomp.hpp -$(TESTSDIR)/%: tpl/tests/% - install -m 0644 $< $@ - -$(TESTSSRCDIR)/%: tpl/tests/src/% - install -m 0644 $< $@ +$(TESTSSRCDIR)/src/precomp.hpp: + cd $(TESTSSRCDIR) && ln -fs ../../src/precomp.hpp precomp.hpp $(HOME)/.config/mkprojrc: echo "$(DATADIR)" > $@