Improve installation of symlinks

This commit is contained in:
Bob Polis 2024-12-26 08:51:28 +01:00
parent 546a7deb42
commit fc966fb62f

View File

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