diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2930df8..1fb3e5c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -3,20 +3,43 @@ ## Makefile.dev targets ```text -clean remove build folder -build build project into build/forge -run run project with test args -demo run project with demo mode -valgrind valgrind analysis -full-clean remove build files and untracked files -test-release try to build release -release-% make full release of version % -release-arch make arch-linux release package +Usage: make --no-print-directory [target1] [target2] ... + +Commands/Targets: +help show this message +init init project +clean clean build artifacts +full-clean remove any unversioned file +build build project +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 -```shell +```bash # make full build make -f Makefile.dev release-1.0.0 # push release @@ -25,6 +48,7 @@ git push origin main --tags # attach .tar.gz to the github release make -f Makefile.dev release-arch # attach .pkg.tar.zst to the github release +make full-clean ``` ## Roadmap diff --git a/Makefile.dev b/Makefile.dev index f16cfa8..199d603 100644 --- a/Makefile.dev +++ b/Makefile.dev @@ -1,107 +1,177 @@ -TARGET ?= forge -INSTALL_DIR ?= $(HOME)/.local/bin -RUN_ARGS ?= --help +# ENV + +RUN_ARGS ?= + SHELL := /bin/bash +MAKE := $(MAKE) --no-print-directory -.PHONY: build -clean: - @rm -rf build +BUILD_DIR ?= build +TARGET ?= forge +VERSION ?= invar-$(shell grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' configure.ac) -build/$(TARGET): - @mkdir -p build - gcc \ - src/*.h src/*.c \ - -Iinclude \ - 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 +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 -.PHONY: build -build: build/$(TARGET) +CLANG_FORMAT ?= clang-format +VALGRIND ?= valgrind -.PHONY: build-no-video -build-no-video: - @mkdir -p build - gcc \ - src/*.h src/*.c \ - -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 +ACLOCAL ?= aclocal +AUTOCONF ?= autoconf +AUTOMAKE ?= automake +CONFIGURE ?= ./configure +MAKEPKG ?= makepkg -.PHONY: format -format: - clang-format -i src/* +INSTALL_DIR ?= $(HOME)/.local/bin -.PHONY: run -run: build/$(TARGET) - ./build/$(TARGET) $(RUN_ARGS) +# DOCS -.PHONY: sample -sample: build/$(TARGET) - ./build/$(TARGET) --project=sample $(RUN_ARGS) +.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: valgrind -valgrind: build/$(TARGET) - valgrind \ - --show-realloc-size-zero=no \ - --undef-value-errors=no \ - ./build/$(TARGET) $(RUN_ARGS) +.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: +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: test-release -test-release: clean full-clean - aclocal - autoconf - automake --add-missing - ./configure - make distcheck - mkdir -p build - cp $(TARGET)-steel-*.tar.gz build/ +.PHONY: clang-format +clang-format: ## clang-format -i src/* + clang-format -i src/* -.PHONY: release-% -release-%: clean full-clean +.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 - aclocal - autoconf - automake --add-missing - ./configure - make distcheck - mkdir -p build - cp "$(TARGET)-steel-$*.tar.gz" build/ + +.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: release-arch -release-arch: clean - mkdir -p build - cp PKGBUILD build - cd build && makepkg +.PHONY: makepkg +makepkg: ## makepkg + mkdir -p $(BUILD_DIR) + cp PKGBUILD $(BUILD_DIR) + cd $(BUILD_DIR) && $(MAKEPKG)