mkproj/Makefile

73 lines
1.4 KiB
Makefile
Raw Normal View History

2024-12-26 08:51:28 +01:00
# Override PREFIX for another root installation directory
2024-12-24 11:04:48 +01:00
PREFIX ?= $(HOME)/.local
BINDIR := $(PREFIX)/bin
MANDIR := $(PREFIX)/man/man1
DATADIR := $(PREFIX)/share/mkproj
TESTSDIR := $(DATADIR)/tests
TESTSSRCDIR := $(TESTSDIR)/src
TPLS := $(addprefix $(DATADIR)/, $(notdir $(wildcard tpl/*)))
TESTFILES := $(addprefix $(TESTSDIR)/, $(notdir $(wildcard tpl/tests/*)))
TESTSRCFILES := $(addprefix $(TESTSSRCDIR)/, $(notdir $(wildcard tpl/tests/src/*)))
2024-12-26 08:51:28 +01:00
# Pattern rules
$(DATADIR)/%: tpl/%
install -m 0644 $< $@
$(TESTSDIR)/%: tpl/tests/%
install -m 0644 $< $@
$(TESTSSRCDIR)/%: tpl/tests/src/%
install -m 0644 $< $@
# Targets
2024-12-24 11:04:48 +01:00
.PHONY: all
all: \
$(BINDIR) \
$(MANDIR) \
$(DATADIR) \
$(TESTSDIR) \
$(TESTSSRCDIR) \
$(BINDIR)/mkproj \
$(MANDIR)/mkproj.1 \
$(TPLS) \
$(TESTFILES) \
2024-12-26 08:51:28 +01:00
$(TESTSDIR)/Makefile \
2024-12-24 11:04:48 +01:00
$(TESTSRCFILES) \
2024-12-26 08:51:28 +01:00
$(TESTSSRCDIR)/src/precomp.hpp \
2024-12-24 11:04:48 +01:00
$(HOME)/.config/mkprojrc
$(BINDIR):
mkdir -p $@
@printf "\e[m33%s\n\e[m" "Please make sure that $(BINDIR) is in your path."
$(BINDIR)/mkproj: mkproj.sh
install -m 0755 $< $@
$(MANDIR):
mkdir -p $@
$(MANDIR)/mkproj.1: mkproj.1
install -m 0644 $< $@
$(DATADIR):
mkdir -p $@
$(TESTSDIR):
mkdir -p $@
2024-12-26 08:51:28 +01:00
$(TESTSDIR)/Makefile:
cd $(TESTSDIR) && ln -fs ../Makefile Makefile
2024-12-24 11:04:48 +01:00
$(TESTSSRCDIR):
mkdir -p $@
2024-12-26 08:51:28 +01:00
$(TESTSSRCDIR)/src/precomp.hpp:
cd $(TESTSSRCDIR) && ln -fs ../../src/precomp.hpp precomp.hpp
2024-12-24 11:04:48 +01:00
$(HOME)/.config/mkprojrc:
2024-12-26 10:03:12 +01:00
echo "tplroot=$(DATADIR)" > $@