wf_akkoma/Makefile

85 lines
1.8 KiB
Makefile

# 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
.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 ] || \
[ ! -f $@ ] || \
git submodule status $(SUBMODULE_NAME) | grep -qE '^\+' ; then \
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) && \
$(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)/
# mix command proxies
.PHONY: build
build: patch
cd $(SUBMODULE_NAME) && \
mix deps.get && \
mix deps.compile && \
mix compile
.PHONY: compile
compile: patch
cd $(SUBMODULE_NAME) && \
mix compile
.PHONY: migrate
migrate: patch
cd $(SUBMODULE_NAME) && \
mix ecto.migrate
.PHONY: server
server: patch
cd $(SUBMODULE_NAME) && \
mix phx.server