-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
75 lines (55 loc) · 2.04 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
# dependencies
GORENDER := ./gopath/bin/gorender --palette "vox/ttd_palette.json" -s 4 -overwrite
NMLC := nml/nmlc
GCC := gcc
MANIFEST := manifest.json
TIME := $(shell date -u +%Y/%m/%d\ %H:%M:%S\ UTC)
# utilities
GIT_NUMBER := $(shell git rev-list --count HEAD)
.PHONY: all sprites code clean clean_grf clean_png copy
# default rule
all: sprites code
# voxel paths
VOX_DIR = vox
VOX_FILES = $(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), $<"
@$(GORENDER) -m "$(dir $<)/$(MANIFEST)" $<
# sprites
sprites: $(VOX_GENREATED_FILES)
# code
NML_FILE = cns.nml
CODE_FILES = $(shell find . \( -name '*.pnml' -o -name '*.lng' \)) $(INDEX_FILE)
INDEX_FILE = indexes.pnml
GRF_FILE = cns.grf
TAGS = tags.txt
CUSTOM_TAGS = custom_tags.txt
# Rule to run nmlc when the NML file changes
# The GRF file is rebuilt every time the PNML files or the graphics files are changed
$(CUSTOM_TAGS): $(TAGS)
$(GCC) -E -x c -D 'GIT_NUMBER=$(GIT_NUMBER)' -D 'CURRENT_TIME=$(TIME)' -o $@ $<
$(NML_FILE): $(CODE_FILES) $(VOX_GENREATED_FILES) $(CUSTOM_TAGS)
$(GCC) -E -x c -D 'GIT_NUMBER=$(GIT_NUMBER)' -o $@ $(INDEX_FILE)
$(GRF_FILE): $(NML_FILE)
$(NMLC) $<
# Rule to run nmlc when the NML file changes
code: $(GRF_FILE)
# clean
clean: clean_grf clean_png
clean_grf:
@echo "Cleaning GRF and NML files"
@rm -f *.grf
@rm -f *.nml
@rm -f $(CUSTOM_TAGS)
clean_png:
@echo "Cleaning PNG files"
@find $(VOX_DIR) -name '*.png' -type f -delete
# this is only for debug purpose, you could modify it to copy the GRF to the OpenTTD data directory
# it should be something like /mnt/c/users/<username>/documents/openttd/newgrf on wsl
copy:
@echo "Copying GRF files to OpenTTD data directory"
@cp $(GRF_FILE) ~/.local/share/openttd/newgrf/$(GRF_FILE)