-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
89 lines (72 loc) · 3.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
VERSION = $(shell cat "VERSION")
PREFIX = MMFW
BIN = @MMFW
ZIP = MMFW
FLAGS = -i include -w redefinition-wo-undef -w unquoted-string
VERSION_FILES = readme.md mod.cpp
MAJOR = $(word 1, $(subst ., ,$(VERSION)))
MINOR = $(word 2, $(subst ., ,$(VERSION)))
PATCH = $(word 3, $(subst ., ,$(VERSION)))
BUILD = $(word 4, $(subst ., ,$(VERSION)))
VERSION_S = $(MAJOR).$(MINOR).$(PATCH)
GIT_HASH = $(shell git log -1 --pretty=format:"%H" | head -c 8)
ifeq ($(OS), Windows_NT)
ifeq ($(PROCESSOR_ARCHITEW6432), AMD64)
ARMAKE = ./tools/armake_w64.exe
else
ifeq ($(PROCESSOR_ARCHITECTURE), AMD64)
ARMAKE = ./tools/armake_w64.exe
else
ARMAKE = ./tools/armake_w32.exe
endif
endif
else
ARMAKE = armake
endif
$(BIN)/addons/$(PREFIX)_%.pbo: addons/%
@mkdir -p $(BIN)/addons
@echo " PBO $@"
@${ARMAKE} build ${FLAGS} -f -e "version=$(GIT_HASH)" $< $@
$(BIN)/optionals/$(PREFIX)_%.pbo: optionals/%
@mkdir -p $(BIN)/optionals
@echo " PBO $@"
@${ARMAKE} build ${FLAGS} -f -e "version=$(GIT_HASH)" $< $@
# Shortcut for building single addons (eg. "make <component>.pbo")
%.pbo:
"$(MAKE)" $(MAKEFLAGS) $(patsubst %, $(BIN)/addons/$(PREFIX)_%, $@)
all: $(patsubst addons/%, $(BIN)/addons/$(PREFIX)_%.pbo, $(wildcard addons/*))# \
# $(patsubst optionals/%, $(BIN)/optionals/$(PREFIX)_%.pbo, $(wildcard optionals/*))
filepatching:
"$(MAKE)" $(MAKEFLAGS) FLAGS="-w unquoted-string -p"
$(BIN)/keys/%.biprivatekey:
@mkdir -p $(BIN)/keys
@echo " KEY $@"
@${ARMAKE} keygen -f $(patsubst $(BIN)/keys/%.biprivatekey, $(BIN)/keys/%, $@)
$(BIN)/addons/$(PREFIX)_%.pbo.$(PREFIX)_$(VERSION)-$(GIT_HASH).bisign: $(BIN)/addons/$(PREFIX)_%.pbo $(BIN)/keys/$(PREFIX)_$(VERSION).biprivatekey
@echo " SIG $@"
@${ARMAKE} sign -f -s $@ $(BIN)/keys/$(PREFIX)_$(VERSION).biprivatekey $<
$(BIN)/optionals/$(PREFIX)_%.pbo.$(PREFIX)_$(VERSION)-$(GIT_HASH).bisign: $(BIN)/optionals/$(PREFIX)_%.pbo $(BIN)/keys/$(PREFIX)_$(VERSION).biprivatekey
@echo " SIG $@"
@${ARMAKE} sign -f -s $@ $(BIN)/keys/$(PREFIX)_$(VERSION).biprivatekey $<
signatures: $(patsubst addons/%, $(BIN)/addons/$(PREFIX)_%.pbo.$(PREFIX)_$(VERSION)-$(GIT_HASH).bisign, $(wildcard addons/*)) \
$(patsubst optionals/%, $(BIN)/optionals/$(PREFIX)_%.pbo.$(PREFIX)_$(VERSION)-$(GIT_HASH).bisign, $(wildcard optionals/*))
version:
@echo " VER $(VERSION)"
$(shell sed -i -r -s 's/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/$(VERSION)/g' $(VERSION_FILES))
$(shell sed -i -r -s 's/[0-9]+\.[0-9]+\.[0-9]+/$(VERSION_S)/g' $(VERSION_FILES))
@echo "#define MAJOR $(MAJOR)\n#define MINOR $(MINOR)\n#define PATCHLVL $(PATCH)\n#define BUILD $(BUILD)" > "addons/main/script_version.hpp"
commit:
@echo " GIT commit release preparation"
@git add -A
@git diff-index --quiet HEAD || git commit -am "Prepare release $(VERSION_S)" -q
push: commit
@echo " GIT push release preparation"
@git push -q
release: clean version commit
@"$(MAKE)" $(MAKEFLAGS) signatures
@echo " ZIP $(ZIP)_$(VERSION).zip"
@cp authors.txt license mod.cpp readme.md $(BIN)
@7z a -tzip $(ZIP)_$(VERSION).zip "./$(BIN)"
clean:
rm -rf $(BIN) $(ZIP)_*.zip
.PHONY: all filepatching signatures extensions-win64 version commit pushrelease clean