-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
112 lines (94 loc) · 3.11 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Required program
SHELL := /bin/bash
NMLC ?= nml/nmlc.exe
PYTHON ?= python3
# C compiler
CC ?= cc
CC_FLAGS ?= -C -E -nostdinc -x c-header
CP_FLAGS ?= $(shell [ "$(OSTYPE)" = "Darwin" ] && echo "-rfX" || echo "-rf")
CC_USER_FLAGS ?=
# Configurations
-include Makefile.config
# Disable default suffixes rule
.SUFFIXES:
.PHONY: all build clean download_page doc generated bundle bundle_tar
# File names
DIR_NAME ?= $(shell echo "$(REPO_NAME) $(VERSION)" | xargs | sed s/\ /_/g)
GRF_FILE ?= $(BASE_FILENAME).grf
NML_FILE ?= $(BASE_FILENAME).nml
NFO_FILE ?= $(BASE_FILENAME).nfo
PNML_FILE ?= $(BASE_FILENAME).pnml
TAG_FILE ?= custom_tags.txt
DOC_FILE ?= docs/readme.txt
GRF_GENERATE ?= $(BASE_FILENAME).grf
NML_GENERATE ?= $(BASE_FILENAME).nml
NFO_GENERATE ?= $(BASE_FILENAME).nfo
PNML_GENERATE ?= $(BASE_FILENAME).pnml
TAR_GENERATE ?= $(BASE_FILENAME).tar
TAG_GENERATE ?= custom_tags.txt
DOC_GENERATE ?= $(DOC_FILE)
BUNDLE_FILES ?= $(GRF_FILE) $(DOC_FILE)
# target 'all' must be first target
all: build
build: $(GRF_GENERATE) doc bundle_tar
@echo "... $(VERSION) has built"
# Generate *.txt from *.ptxt
%.txt: %.ptxt generated
@echo "[DOC] $@"
@cat $< | sed -e "s/{{\VERSION}}/$(VERSION)/" > ./generated/$(notdir $@)
clean::
@-rm -rf ./generated/readme.txt
# Documents
doc: generated $(GRF_GENERATE)
@cp $(CP_FLAGS) ./docs/changelog.md ./generated/changelog.txt
clean::
@echo "[CLEAN DOC]"
@-rm -rf ./generated/*.txt
@-rm -rf ./docs/readme.txt
# Make generated directory
generated:
@echo "[MKDIR generated]"
@if [ ! -e $@ ]; then mkdir $@; fi
clean::
@echo "[CLEAN generated]"
@-rm -rf ./generated
# Generate *.nml from *.pnml
$(NML_GENERATE): generated $(PNML_GENERATE)
@echo "[CPP] $@"
@ $(CC) -D VERSION=$(VERSION) $(CC_USER_FLAGS) $(CC_FLAGS) -o ./generated/$(NML_FILE) $(PNML_FILE)
clean::
@echo "[CLEAN NML]"
@-rm -rf $(NML_FILE)
# Generate custom_tags.txt
$(TAG_GENERATE): generated
@echo "[TAG] $@"
@echo "VERSION :$(VERSION)" > ./generated/$@
@echo "RECENT_UPDATED :$(RECENT_UPDATED)" >> ./generated/$@
@echo "AUTHOR_WEBSITE :$(AUTHOR_WEBSITE)" >> ./generated/$@
@echo "AUTHOR_EMAIL :$(AUTHOR_EMAIL)" >> ./generated/$@
clean::
@echo "[CLEAN TAG]"
@-rm -rf $(TAG_FILE)
# Generate *.grf
$(GRF_GENERATE): generated $(NML_GENERATE) $(TAG_GENERATE)
@echo "[NMLC] $@"
@ $(NMLC) -c --custom-tags="./generated/$(TAG_FILE)" --lang-dir="./lang/" "./generated/$(NML_FILE)" --grf="./generated/$(GRF_FILE)"
clean::
@echo "[CLEAN GRF]"
@-rm -rf $(GRF_FILE)
$(NFO_GENERATE):
clean::
@echo "[CLEAN NFO]"
@-rm -rf $(NFO_FILE)
# Make a bundle
bundle: bundle_tar
bundle_tar: $(BUNDLE_FILES)
@echo "[BUNDLE TAR]"
@ tar -cf generated/$(DIR_NAME).tar generated/changelog.txt generated/$(GRF_FILE) generated/readme.txt --transform s/generated/$(DIR_NAME)/
clean::
@echo "[CLEAN BUNDLE]"
@-rm -rf $(shell echo "$(REPO_NAME)*" | xargs | sed s/\ /_/g)
# Clean
clean::
@-rm -rf ./.nmlcache
@-rm -rf ./src/__pycache__