-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
100 lines (79 loc) · 2.91 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
# general
-include Makefile.config
# tools, sprites, lang, code entries need to be specified in Makefile.config
# though the Makefile itself provides default values that can be used if
# following the build instructions in README.md (using scoop to install the tools)
#
# You can override the default values by specifying them in Makefile.config
# this would be useful if e.g. you manually compiled gorender and it's not in your PATH
# tools
PYTHON ?= python3
# sprites
# this default value assumes you have renderobject in your PATH
GORENDER ?= renderobject --palette "ttd_palette.json" -overwrite
VOX_DIR ?= gfx/*
PALETTE ?= ttd_palette.json
MANIFEST ?= manifest.json
# lang
LANG_SCRIPT ?= ./str-csv.py
LANG_SRC ?= docs/str.csv
# code
NMLC ?= nmlc -c
GCC ?= gcc
PROJECT ?= chinasettrains
DOC_FILES ?= license.txt readme.txt changelog.txt
INDEX_FILE ?= chinaset-mtraddon.pnml
OUTPUT_NML ?= chinaset-mtraddon.nml
OUTPUT_GRF ?= chinaset-mtraddon.grf
CUSTOM_TAG_FILE ?= custom_tags.txt
# version
-include Makefile.dist
REPO_REVISION ?= 1 # specify in Makefile.dist
REPO_VERSION_STRING ?= 0.0.1.1 # specify in Makefile.dist
.PHONY: all sprites custom_tags code clean clean_grf clean_png bundle FORCE
# default rule
all: sprites lang code
# voxel paths
VOX_FILES = $(wildcard $(VOX_DIR)/*.vox wildcard $(VOX_DIR)/*/*.vox)
VOX_8BPP_FILES = $(addsuffix _8bpp.png, $(basename $(VOX_FILES)))
VOX_32BPP_FILES = $(addsuffix _32bpp.png, $(basename $(VOX_FILES)))
VOX_MASK_FILES = $(addsuffix _mask.png, $(basename $(VOX_FILES)))
VOX_GENREATED_FILES = $(VOX_8BPP_FILES) $(VOX_32BPP_FILES) $(VOX_MASK_FILES)
%_8bpp.png %_32bpp.png %_mask.png: %.vox
@echo "Rendering, manifest = $(dir $<)/$(MANIFEST), palette = $(dir $<)/$(PALETTE), $<"
@$(GORENDER) -m $(dir $<)/$(MANIFEST) --palette $(dir $<)/$(PALETTE) $<
# sprites
sprites: $(VOX_GENREATED_FILES)
# lang
lang: FORCE
@echo "Generating lang files"
@$(PYTHON) $(LANG_SCRIPT) $(LANG_SRC)
# code
custom_tags: FORCE
@echo "Generating custom tags"
@echo "VERSION_STRING :$(REPO_VERSION_STRING)" > $(CUSTOM_TAG_FILE)
code: custom_tags lang $(VOX_GENERATED_FILES) FORCE
@echo "Preprocessing"
@$(GCC) -E -x c -D REPO_REVISION=$(REPO_REVISION) -D VERSION_STRING=$(REPO_VERSION_STRING) $(INDEX_FILE) > $(OUTPUT_NML)
@echo "Compiling"
@$(NMLC) $(OUTPUT_NML) -o $(OUTPUT_GRF)
# clean
clean: clean_grf clean_png
clean_grf:
@echo "Cleaning GRF and NML files"
@echo "Warning: clean grf won't work when using powershell, please use bash instead."
@rm -f *.grf
@rm -f *.nml
@rm -f $(CUSTOM_TAG_FILE)
clean_png:
@echo "Cleaning PNG files"
@echo "Warning: clean png won't work when using powershell, please use bash instead."
@find $(VOX_DIR)/ -name '*.png' -type f -delete
bundle: code FORCE
@echo "Bundling"
cd docs
cp $(OUTPUT_GRF) docs/
cd docs; tar -cf ../$(PROJECT)-$(REPO_VERSION_STRING).tar $(DOC_FILES) $(OUTPUT_GRF)
rm docs/$(OUTPUT_GRF)
# dummy rule for force rebuilding
FORCE: ;