2020-11-07 14:49:29 +01:00
|
|
|
SRC_DIR := src
|
|
|
|
BUILD_DIR := build
|
|
|
|
RELEASE_DIR := $(BUILD_DIR)/release
|
|
|
|
DEBUG_DIR := $(BUILD_DIR)/debug
|
|
|
|
BINARY := stj
|
|
|
|
CORES := $(shell nproc --all)
|
2020-11-14 17:30:54 +01:00
|
|
|
PREFIX := /usr/local
|
|
|
|
MANPREFIX := $(PREFIX)/share/man
|
2020-11-06 13:03:16 +01:00
|
|
|
|
|
|
|
all: debug
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
|
2020-11-14 17:30:54 +01:00
|
|
|
# Installation & removal
|
|
|
|
install: release
|
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
|
|
|
cp -f build/release/stj $(DESTDIR)$(PREFIX)/bin
|
|
|
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/stj
|
|
|
|
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
|
|
|
sed "s/VERSION/$(VERSION)/g" < data/stj.1 > $(DESTDIR)$(MANPREFIX)/man1/stj.1
|
|
|
|
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/stj.1
|
|
|
|
tic -sx data/stj.info
|
|
|
|
cp -f data/stj.desktop $(DESTDIR)$(PREFIX)/share/applications
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/stj
|
|
|
|
rm -f $(DESTDIR)$(MANPREFIX)/man1/stj.1
|
|
|
|
rm -f $(DESTDIR)$(PREFIX)/share/applications/stj.desktop
|
|
|
|
|
|
|
|
|
|
|
|
# Full clean
|
2020-11-06 13:03:16 +01:00
|
|
|
clean:
|
2020-11-07 15:29:13 +01:00
|
|
|
@ [ ! -e '$(BINARY)' ] || rm '$(BINARY)'
|
|
|
|
@ rm -rf '$(BUILD_DIR)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
|
|
|
|
# Release
|
|
|
|
run-release: release
|
2020-11-07 15:29:13 +01:00
|
|
|
@ ./'$(RELEASE_DIR)/$(BINARY)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: run-release
|
|
|
|
|
|
|
|
release: $(RELEASE_DIR)/Makefile
|
2020-11-07 15:29:13 +01:00
|
|
|
@ make -C '$(RELEASE_DIR)' -j'$(CORES)' && \
|
|
|
|
ln -sf '$(RELEASE_DIR)'/'$(BINARY)' ./'$(BINARY)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: release
|
|
|
|
|
|
|
|
$(RELEASE_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
|
2020-11-07 15:29:13 +01:00
|
|
|
@ cmake \
|
|
|
|
-H'$(SRC_DIR)' \
|
|
|
|
-B'$(RELEASE_DIR)' \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
2020-11-06 13:03:16 +01:00
|
|
|
|
|
|
|
clean-release:
|
2020-11-07 15:29:13 +01:00
|
|
|
@ rm -rf '$(RELEASE_DIR)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: clean-release
|
|
|
|
|
|
|
|
|
|
|
|
# Debug
|
|
|
|
run-debug: debug
|
2020-11-07 15:29:13 +01:00
|
|
|
@ ./'$(DEBUG_DIR)/$(BINARY)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: run-debug
|
|
|
|
|
|
|
|
debug: $(DEBUG_DIR)/Makefile
|
2020-11-07 15:29:13 +01:00
|
|
|
@ make -C '$(DEBUG_DIR)' -j'$(CORES)' && \
|
|
|
|
ln -sf '$(DEBUG_DIR)/$(BINARY)' ./'$(BINARY)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: debug
|
|
|
|
|
|
|
|
$(DEBUG_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
|
2020-11-07 15:29:13 +01:00
|
|
|
@ cmake \
|
|
|
|
-H'$(SRC_DIR)' \
|
|
|
|
-B'$(DEBUG_DIR)' \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
2020-11-06 13:03:16 +01:00
|
|
|
|
|
|
|
clean-debug:
|
2020-11-07 15:29:13 +01:00
|
|
|
@ rm -rf '$(DEBUG_DIR)'
|
2020-11-06 13:03:16 +01:00
|
|
|
.PHONY: clean-debug
|