tools(make): much better Makefile.dev

This commit is contained in:
2026-11-08 13:03:04 +01:00
parent 01cba36eaa
commit 06613fe647
2 changed files with 185 additions and 91 deletions
+34 -10
View File
@@ -3,20 +3,43 @@
## Makefile.dev targets ## Makefile.dev targets
```text ```text
clean remove build folder Usage: make --no-print-directory [target1] [target2] ...
build build project into build/forge
run run project with test args Commands/Targets:
demo run project with demo mode help show this message
valgrind valgrind analysis init init project
full-clean remove build files and untracked files clean clean build artifacts
test-release try to build release full-clean remove any unversioned file
release-% make full release of version % build build project
release-arch make arch-linux release package build-no-video build project no video in
run run project with $RUN_ARGS
run-% run {project} with $RUN_ARGS
format format project
release-test test release
release-% build release {version}
rm-build rm -rf build
git-clean git clean -f -x
rm-deps rm -rf */.deps
clang-format clang-format -i src/*
exec-build ./build/forge $RUN_ARGS
exec-build-% ./build/forge --project={project} $RUN_ARGS
aclocal aclocal
autoconf autoconf
automake automake --add-missing
start-configure ./configure
make-% make {target}
cp-release cp forge-steel-xxx.tar.gz build/
git-submodule-update git submodule update --init --recursive
git-pull git pull origin main
prepare-configure-% sed -i {version} configure.ac
prepare-pkgbuild-% sed -i {version} PKGBUILD
git-commit-release git commit -am "forge (steel) v{version}"
makepkg makepkg
``` ```
## Release guide ## Release guide
```shell ```bash
# make full build # make full build
make -f Makefile.dev release-1.0.0 make -f Makefile.dev release-1.0.0
# push release # push release
@@ -25,6 +48,7 @@ git push origin main --tags
# attach .tar.gz to the github release # attach .tar.gz to the github release
make -f Makefile.dev release-arch make -f Makefile.dev release-arch
# attach .pkg.tar.zst to the github release # attach .pkg.tar.zst to the github release
make full-clean
``` ```
## Roadmap ## Roadmap
+151 -81
View File
@@ -1,107 +1,177 @@
TARGET ?= forge # ENV
INSTALL_DIR ?= $(HOME)/.local/bin
RUN_ARGS ?= --help RUN_ARGS ?=
SHELL := /bin/bash SHELL := /bin/bash
MAKE := $(MAKE) --no-print-directory
.PHONY: build BUILD_DIR ?= build
clean: TARGET ?= forge
@rm -rf build VERSION ?= invar-$(shell grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' configure.ac)
build/$(TARGET): CC ?= gcc
@mkdir -p build SOURCES ?= src/*.h src/*.c hashmap.c/hashmap.c log.c/src/log.c
gcc \ 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)\"
src/*.h src/*.c \ EXTRA_CFLAGS ?= -DEGL_DEBUG -DGL_DEBUG -DVIDEO_IN
-Iinclude \ LDLIBS ?= -lm -lGL -lglfw -lasound
hashmap.c/hashmap.c \
log.c/src/log.c \
-lm -lGL -lglfw -lasound \
-Wall -Wextra \
-Wno-format-truncation \
-DGLFW_INCLUDE_NONE \
-DGLFW_EXPOSE_NATIVE_EGL \
-DGLFW_NATIVE_INCLUDE_NONE \
-DLOG_USE_COLOR \
-DVIDEO_IN \
-o build/$(TARGET) \
-g -Og
.PHONY: build CLANG_FORMAT ?= clang-format
build: build/$(TARGET) VALGRIND ?= valgrind
.PHONY: build-no-video ACLOCAL ?= aclocal
build-no-video: AUTOCONF ?= autoconf
@mkdir -p build AUTOMAKE ?= automake
gcc \ CONFIGURE ?= ./configure
src/*.h src/*.c \ MAKEPKG ?= makepkg
-Iinclude \
hashmap.c/hashmap.c \
log.c/src/log.c \
-lm -lGL -lglfw -lasound \
-Wall -Wextra \
-Wno-format-truncation \
-DGLFW_INCLUDE_NONE \
-DGLFW_NATIVE_INCLUDE_NONE \
-DLOG_USE_COLOR \
-o build/$(TARGET) \
-g -Og
.PHONY: format INSTALL_DIR ?= $(HOME)/.local/bin
format:
clang-format -i src/*
.PHONY: run # DOCS
run: build/$(TARGET)
./build/$(TARGET) $(RUN_ARGS)
.PHONY: sample .PHONY: help
sample: build/$(TARGET) help: ## show this message
./build/$(TARGET) --project=sample $(RUN_ARGS) @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: valgrind .PHONY: print-%
valgrind: build/$(TARGET) print-%:
valgrind \ @echo -e '\033[32m$*\033[0m = $($*)'
--show-realloc-size-zero=no \
--undef-value-errors=no \ # FILES
./build/$(TARGET) $(RUN_ARGS)
$(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 .PHONY: full-clean
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 git clean -f -x
.PHONY: rm-deps
rm-deps: ## rm -rf */.deps
rm -rf */*/.deps rm -rf */*/.deps
rm -rf */.deps rm -rf */.deps
.PHONY: test-release .PHONY: clang-format
test-release: clean full-clean clang-format: ## clang-format -i src/*
aclocal clang-format -i src/*
autoconf
automake --add-missing
./configure
make distcheck
mkdir -p build
cp $(TARGET)-steel-*.tar.gz build/
.PHONY: release-% .PHONY: exec-build
release-%: clean full-clean 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 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 sed -i -E "s/[0-9]+\\.[0-9]+\\.[0-9]+/$*/g" configure.ac
aclocal
autoconf .PHONY: prepare-pkgbuild-%
automake --add-missing prepare-pkgbuild-%: ## sed -i {version} PKGBUILD
./configure
make distcheck
mkdir -p build
cp "$(TARGET)-steel-$*.tar.gz" build/
sed -i -E "s/pkgver=[0-9]+\\.[0-9]+\\.[0-9]+/pkgver=$*/g" 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 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 add configure.ac PKGBUILD
git commit -am "forge (steel) v$*" git commit -am "forge (steel) v$*"
git tag v$* -m "FORGE steel-$*" git tag v$* -m "FORGE steel-$*"
@echo "Push release: git push origin main --tags" @echo "Push release: git push origin main --tags"
@echo "Rollback release: git reset HEAD~1 --hard && git tag -d v$*" @echo "Rollback release: git reset HEAD~1 --hard && git tag -d v$*"
.PHONY: makepkg
.PHONY: release-arch makepkg: ## makepkg
release-arch: clean mkdir -p $(BUILD_DIR)
mkdir -p build cp PKGBUILD $(BUILD_DIR)
cp PKGBUILD build cd $(BUILD_DIR) && $(MAKEPKG)
cd build && makepkg