2020-12-02 12:40:21 +01:00
|
|
|
# =====CONFIG=====
|
|
|
|
SRC_DIR := src
|
|
|
|
BUILD_DIR := build
|
|
|
|
RELEASE_DIR := $(BUILD_DIR)/release
|
|
|
|
DEBUG_DIR := $(BUILD_DIR)/debug
|
|
|
|
MINSIZEREL_DIR := $(BUILD_DIR)/min_size_rel
|
|
|
|
BINARY := stj
|
|
|
|
CORES := $(shell nproc --all)
|
|
|
|
PREFIX := /usr/local
|
|
|
|
MANPREFIX := $(PREFIX)/share/man
|
|
|
|
|
2020-11-06 13:03:16 +01:00
|
|
|
|
|
|
|
all: debug
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
|
2020-12-02 12:40:21 +01:00
|
|
|
# =====INSTALL & UNINSTALL=====
|
2020-11-14 17:30:54 +01:00
|
|
|
install: release
|
2020-12-02 15:07:29 +01:00
|
|
|
@ mkdir -p '$(DESTDIR)$(PREFIX)/bin'
|
|
|
|
@ cp -f '$(RELEASE_DIR)/$(BINARY)' '$(DESTDIR)$(PREFIX)/bin'
|
|
|
|
@ chmod 755 '$(DESTDIR)$(PREFIX)/bin/$(BINARY)'
|
|
|
|
@ mkdir -p '$(DESTDIR)$(MANPREFIX)/man1'
|
|
|
|
@ sed "s/VERSION/$(VERSION)/g" < 'data/stj.1' > '$(DESTDIR)$(MANPREFIX)/man1/$(BINARY).1'
|
|
|
|
@ chmod 644 '$(DESTDIR)$(MANPREFIX)/man1/$(BINARY).1'
|
|
|
|
@ tic -sx 'data/stj.info'
|
|
|
|
@ cp -f 'data/$(BINARY).desktop' '$(DESTDIR)$(PREFIX)/share/applications'
|
2020-12-02 12:40:21 +01:00
|
|
|
.PHONY: install
|
2020-11-14 17:30:54 +01:00
|
|
|
|
|
|
|
uninstall:
|
2020-12-02 15:07:29 +01:00
|
|
|
@ rm -f '$(DESTDIR)$(PREFIX)/bin/$(BINARY)'
|
|
|
|
@ rm -f '$(DESTDIR)$(MANPREFIX)/man1/$(BINARY).1'
|
|
|
|
@ rm -f '$(DESTDIR)$(PREFIX)/share/applications/$(BINARY).desktop'
|
2020-12-02 12:40:21 +01:00
|
|
|
.PHONY: uninstall
|
2020-11-14 17:30:54 +01:00
|
|
|
|
|
|
|
|
2020-12-02 12:40:21 +01:00
|
|
|
# =====DEBUG=====
|
|
|
|
debug: $(DEBUG_DIR)/Makefile
|
|
|
|
@ make -C '$(DEBUG_DIR)' -j'$(CORES)' && \
|
|
|
|
ln -sf '$(DEBUG_DIR)/$(BINARY)' ./'$(BINARY)'
|
|
|
|
.PHONY: debug
|
2020-11-06 13:03:16 +01:00
|
|
|
|
2020-12-02 12:40:21 +01:00
|
|
|
$(DEBUG_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
|
|
|
|
@ cmake \
|
|
|
|
-H'$(SRC_DIR)' \
|
|
|
|
-B'$(DEBUG_DIR)' \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
2020-11-06 13:03:16 +01:00
|
|
|
|
|
|
|
|
2020-12-02 12:40:21 +01:00
|
|
|
# =====RELEASE=====
|
2020-11-06 13:03:16 +01:00
|
|
|
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 \
|
2020-11-06 13:03:16 +01:00
|
|
|
|
|
|
|
|
2020-12-02 12:40:21 +01:00
|
|
|
# =====MINIMUM SIZE RELEASE=====
|
|
|
|
minsizerel: $(MINSIZEREL_DIR)/Makefile
|
|
|
|
@ make -C '$(MINSIZEREL_DIR)' -j'$(CORES)' && \
|
|
|
|
ln -sf '$(MINSIZEREL_DIR)'/'$(BINARY)' ./'$(BINARY)'
|
|
|
|
.PHONY: minsizerel
|
2020-11-06 13:03:16 +01:00
|
|
|
|
2020-12-02 12:40:21 +01:00
|
|
|
$(MINSIZEREL_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
|
2020-11-07 15:29:13 +01:00
|
|
|
@ cmake \
|
|
|
|
-H'$(SRC_DIR)' \
|
2020-12-02 12:40:21 +01:00
|
|
|
-B'$(MINSIZEREL_DIR)' \
|
|
|
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
|
|
|
|
|
|
|
|
|
|
|
# =====CLEANING=====
|
|
|
|
clean:
|
|
|
|
@ [ ! -e '$(BINARY)' ] || rm '$(BINARY)'
|
|
|
|
@ rm -rf '$(BUILD_DIR)'
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean-release:
|
|
|
|
@ rm -rf '$(RELEASE_DIR)'
|
|
|
|
.PHONY: clean-release
|
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
|
2020-12-02 12:40:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
# =====FORMAT CODE=====
|
|
|
|
format:
|
|
|
|
@ clang-format -i --style=file src/**/*.c src/**/*.h
|