178 lines
4.6 KiB
Makefile
178 lines
4.6 KiB
Makefile
# ENV
|
|
|
|
RUN_ARGS ?= --demo -nmr -is=480 --monitor-only
|
|
|
|
SHELL := /bin/bash
|
|
MAKE := $(MAKE) --no-print-directory
|
|
|
|
BUILD_DIR ?= build
|
|
TARGET ?= forge
|
|
VERSION ?= invar-$(shell grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' configure.ac)
|
|
|
|
CC ?= gcc
|
|
SOURCES ?= src/*.h src/*.c hashmap.c/hashmap.c log.c/src/log.c
|
|
CFLAGS ?= -Ofast -Ofast -march=native -flto -funroll-loops -fprefetch-loop-arrays -fno-exceptions -fopenmp -Iinclude -DGLFW_INCLUDE_NONE -DGLFW_EXPOSE_NATIVE_EGL -DGLFW_NATIVE_INCLUDE_NONE -DLOG_USE_COLOR -DVERSION=\"$(VERSION)\"
|
|
EXTRA_CFLAGS ?= -DEGL_DEBUG -DGL_DEBUG -DVIDEO_IN
|
|
LDLIBS ?= -lm -lGL -lglfw -lasound
|
|
|
|
CLANG_FORMAT ?= clang-format
|
|
VALGRIND ?= valgrind
|
|
|
|
ACLOCAL ?= aclocal
|
|
AUTOCONF ?= autoconf
|
|
AUTOMAKE ?= automake
|
|
CONFIGURE ?= ./configure
|
|
MAKEPKG ?= makepkg
|
|
|
|
INSTALL_DIR ?= $(HOME)/.local/bin
|
|
|
|
# DOCS
|
|
|
|
.PHONY: help
|
|
help: ## show this message
|
|
@echo "Usage: $(MAKE) [target1] [target2] ..."
|
|
@echo ""
|
|
@echo "Commands/Targets:"
|
|
@cat $(MAKEFILE_LIST) | grep -E '(^[a-zA-Z0-9_%-]+:.*?##.*$$)|(^##)' | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-20s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
|
|
@echo ""
|
|
@echo "Environment:"
|
|
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z0-9_-]+\s*\??=.*$$' | grep -Eo '^[a-zA-Z0-9_-]+' | xargs -I {} $(MAKE) -s print-{} 2> /dev/null
|
|
|
|
.PHONY: print-%
|
|
print-%:
|
|
@echo -e '\033[32m$*\033[0m = $($*)'
|
|
|
|
# FILES
|
|
|
|
$(BUILD_DIR)/$(TARGET):
|
|
mkdir -p $(BUILD_DIR)
|
|
$(CC) $(SOURCES) $(CFLAGS) $(EXTRA_CFLAGS) $(LDLIBS) -o $(BUILD_DIR)/$(TARGET)
|
|
|
|
# ACTIONS
|
|
|
|
.PHONY: init
|
|
init: git-submodule-update ## init project
|
|
|
|
.PHONY: clean
|
|
clean: rm-build ## clean build artifacts
|
|
|
|
.PHONY: full-clean
|
|
full-clean: rm-build git-clean rm-deps ## remove any residual files
|
|
|
|
.PHONY: build
|
|
build: $(BUILD_DIR)/$(TARGET) ## build project
|
|
|
|
.PHONY: build-no-video
|
|
build-no-video: ## build project no video in
|
|
EXTRA_CFLAGS= $(MAKE) build
|
|
|
|
.PHONY: run
|
|
run: exec-build ## run project with $RUN_ARGS
|
|
|
|
.PHONY: run-%
|
|
run-%: ## run {project} with $RUN_ARGS
|
|
$(MAKE) exec-build-$*
|
|
|
|
.PHONY: format
|
|
format: clang-format ## format project
|
|
|
|
.PHONY: release-test
|
|
release-test: full-clean aclocal autoconf automake start-configure make-distcheck cp-release ## test release
|
|
|
|
.PHONY: release-arch
|
|
release-arch: clean makepkg
|
|
|
|
.PHONY: release-%
|
|
release-%: ## build release {version}
|
|
$(MAKE) full-clean git-pull prepare-configure-$* aclocal autoconf automake start-configure make-distcheck cp-release prepare-pkgbuild-$* git-commit-release
|
|
|
|
# TOOLS
|
|
|
|
.PHONY: rm-build
|
|
rm-build: ## rm -rf build
|
|
rm -rf $(BUILD_DIR)
|
|
|
|
.PHONY: git-clean
|
|
git-clean: ## git clean -f -x
|
|
git clean -f -x
|
|
|
|
.PHONY: rm-deps
|
|
rm-deps: ## rm -rf */.deps
|
|
rm -rf */*/.deps
|
|
rm -rf */.deps
|
|
|
|
.PHONY: clang-format
|
|
clang-format: ## clang-format -i src/*
|
|
clang-format -i src/*
|
|
|
|
.PHONY: exec-build
|
|
exec-build: $(BUILD_DIR)/$(TARGET) ## ./build/forge $RUN_ARGS
|
|
./$(BUILD_DIR)/$(TARGET) $(RUN_ARGS)
|
|
|
|
.PHONY: exec-build-%
|
|
exec-build-%: $(BUILD_DIR)/$(TARGET) ## ./build/forge --project={project} $RUN_ARGS
|
|
./$(BUILD_DIR)/$(TARGET) --project=$* $(RUN_ARGS)
|
|
|
|
.PHONY: valgrind
|
|
valgrind: build/$(TARGET)
|
|
$(VALGRIND) \
|
|
--show-realloc-size-zero=no \
|
|
--undef-value-errors=no \
|
|
./$(BUILD_DIR)/$(TARGET) $(RUN_ARGS)
|
|
|
|
.PHONY: aclocal
|
|
aclocal: ## aclocal
|
|
$(ACLOCAL)
|
|
|
|
.PHONY: autoconf
|
|
autoconf: ## autoconf
|
|
$(AUTOCONF)
|
|
|
|
.PHONY: automake
|
|
automake: ## automake --add-missing
|
|
$(AUTOMAKE) --add-missing
|
|
|
|
.PHONY: start-configure
|
|
start-configure: ## ./configure
|
|
$(CONFIGURE)
|
|
|
|
.PHONY: make-%
|
|
make-%: ## make {target}
|
|
$(MAKE) $*
|
|
|
|
.PHONY: cp-release
|
|
cp-release: ## cp forge-steel-xxx.tar.gz build/
|
|
mkdir -p $(BUILD_DIR)
|
|
cp $(TARGET)-steel-*.tar.gz $(BUILD_DIR)/
|
|
|
|
.PHONY: git-submodule-update
|
|
git-submodule-update: ## git submodule update --init --recursive
|
|
git submodule update --init --recursive
|
|
|
|
.PHONY: git-pull
|
|
git-pull: ## git pull origin main
|
|
git pull origin main
|
|
|
|
.PHONY: prepare-configure-%
|
|
prepare-configure-%: ## sed -i {version} configure.ac
|
|
sed -i -E "s/[0-9]+\\.[0-9]+\\.[0-9]+/$*/g" configure.ac
|
|
|
|
.PHONY: prepare-pkgbuild-%
|
|
prepare-pkgbuild-%: ## sed -i {version} PKGBUILD
|
|
sed -i -E "s/pkgver=[0-9]+\\.[0-9]+\\.[0-9]+/pkgver=$*/g" PKGBUILD
|
|
sha256sum build/forge-steel-$*.tar.gz | cut -d' ' -f1 | xargs -I{} sed -i -E "s/sha256sums=\\('.*'\\)/sha256sums=\\('{}'\\)/g" PKGBUILD
|
|
|
|
.PHONY: git-commit-release
|
|
git-commit-release: ## git commit -am "forge (steel) v{version}"
|
|
git add configure.ac PKGBUILD
|
|
git commit -am "forge (steel) v$*"
|
|
git tag v$* -m "FORGE steel-$*"
|
|
@echo "Push release: git push origin main --tags"
|
|
@echo "Rollback release: git reset HEAD~1 --hard && git tag -d v$*"
|
|
|
|
.PHONY: makepkg
|
|
makepkg: ## makepkg
|
|
mkdir -p $(BUILD_DIR)
|
|
cp PKGBUILD $(BUILD_DIR)
|
|
cd $(BUILD_DIR) && $(MAKEPKG)
|