wf_akkoma/Makefile

86 lines
1.8 KiB
Makefile
Raw Normal View History

2024-10-02 14:50:51 +00:00
# Requires GNU Make
export LC_ALL = C.UTF-8
export PLEROMA_BUILD_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
QUILT ::= quilt --quiltrc ../quiltrc
SUBMODULE_NAME ::= akkoma
2024-10-02 14:50:51 +00:00
.PHONY: patch
patch: patch.stamp
GIT_HASH ::= $(shell git rev-parse --short=8 HEAD)
GIT_HASH_OLD ::= $(shell cat git.stamp 2>/dev/null || :)
ifneq ($(GIT_HASH), $(GIT_HASH_OLD))
.PHONY: git.stamp
endif
git.stamp:
@echo "Collecting buld info"
@echo $(GIT_HASH) > $@
patches/000_plant-a-forest.patch: patches/000_plant-a-forest.patch.in git.stamp
@echo "Encoding build info"
@number="$$(git rev-list --count HEAD)" && \
hash="$$(git rev-parse --short=8 HEAD)" && \
sed -e 's/%COMMIT_NUMBER%/'"$$number"'/g' \
-e 's/%COMMIT_HASH%/'"$$hash"'/g' \
$< > $@
submodule.stamp:
@echo "Ensure submodule is up-to-date"
@if [ ! -f $(SUBMODULE_NAME)/.git ] || \
2024-10-02 14:50:51 +00:00
[ ! -f $@ ] || \
git submodule status $(SUBMODULE_NAME) | grep -qE '^\+' ; then \
2024-10-02 14:50:51 +00:00
git submodule sync && \
git submodule update --init && \
touch $@ ; \
fi
patch.stamp: submodule.stamp patches/series patches/000_plant-a-forest.patch $(wildcard patches/*.patch)
@echo "Applying patches"
@# `pop -a` return 2 if currently no patches applied, thus ignore exit code
@cd $(SUBMODULE_NAME) && \
2024-10-02 14:50:51 +00:00
$(QUILT) pop -qfa; \
$(QUILT) push -a
@touch $@
# cleaning
.PHONY: clean
clean:
rm -f *.stamp
rm -f patches/000_plant-a-forest.patch
.PHONY: reset
reset: clean
git -C $(SUBMODULE_NAME) reset --hard
.PHONY: reset-harder
reset-harder: clean
rm -fr $(SUBMODULE_NAME)/
2024-10-02 14:50:51 +00:00
# mix command proxies
.PHONY: build
build: patch
cd $(SUBMODULE_NAME) && \
2024-10-02 14:50:51 +00:00
mix deps.get && \
mix deps.compile && \
mix compile
.PHONY: compile
compile: patch
cd $(SUBMODULE_NAME) && \
2024-10-02 14:50:51 +00:00
mix compile
.PHONY: migrate
migrate: patch
cd $(SUBMODULE_NAME) && \
2024-10-02 14:50:51 +00:00
mix ecto.migrate
.PHONY: server
server: patch
cd $(SUBMODULE_NAME) && \
2024-10-02 14:50:51 +00:00
mix phx.server