@@ -10,6 +10,12 @@ BIN_DIR := ../../bin
10
10
11
11
UZEM_RUN_OPTS := -f
12
12
13
+ # This is a smart option that will determine what to do based on file type:
14
+ # - *.png: run the Python tile generator
15
+ # - *.s: use an assembly font file (eg, data/font.s)
16
+ # - (blank): don't do anything special for fonts
17
+ FONT_FILE := $(DATA_DIR ) /font.png
18
+
13
19
AUX_TARGETS := $(GAME ) .hex # $(GAME).uze $(GAME).lss $(GAME).eep
14
20
AUX_DEPS := Makefile $(wildcard $(DATA_DIR ) /* )
15
21
@@ -27,15 +33,21 @@ FILES_H := $(shell find . -type f -iname '*.h')
27
33
FILE_S_VMODE_ASM_SOURCE := video.s # the file included into uzeboxVideoEngineCore.s as VMODE_ASM_SOURCE
28
34
FILES_S := library.s tiles.s # any other assembly files to be linked in
29
35
30
- FONT_PNG := font.png
31
-
32
- # --------------------------------
36
+ # -------------------------------- option processing
33
37
FILES_C := $(patsubst ./% ,% ,$(FILES_C ) )
34
38
FILES_S := $(patsubst ./% ,% ,$(FILES_S ) )
35
39
AUX_TARGETS := $(patsubst % ,$(BUILD_DIR ) /% ,$(AUX_TARGETS ) )
36
40
DEP_DIR := $(BUILD_DIR ) /dep
37
41
38
- FONT_S := $(GEN_DIR ) /$(patsubst % .png,% .s,$(FONT_PNG ) )
42
+ ifeq ($(suffix $(FONT_FILE ) ) ,.png)
43
+ FONT_PNG := $(FONT_FILE )
44
+ FONT_S := $(GEN_DIR ) /$(patsubst % .png,% .s,$(notdir $(FONT_PNG ) ) )
45
+ else ifeq ($(suffix $(FONT_FILE)),.s)
46
+ FONT_S := $(FONT_FILE )
47
+ else ifneq ($(FONT_FILE),)
48
+ $(error Unrecognized font file type)
49
+ endif
50
+
39
51
FONT_O := $(subst /,_,$(FONT_S ) )
40
52
FONT_O := $(patsubst % .s,% .o,$(FONT_O ) )
41
53
@@ -89,7 +101,7 @@ FILES_KERNEL := $(patsubst %,$(KERNEL)/%,$(FILES_KERNEL))
89
101
OBJECTS := $(notdir $(FILES_KERNEL ) ) $(FILES_C ) $(FILES_S )
90
102
OBJECTS := $(patsubst % .c,% .o,$(OBJECTS ) )
91
103
OBJECTS := $(patsubst % .s,% .o,$(OBJECTS ) )
92
- ifneq ($(FONT_PNG ) ,)
104
+ ifneq ($(FONT_FILE ) ,)
93
105
OBJECTS += $(FONT_O )
94
106
endif
95
107
OBJECTS := $(patsubst % ,$(BUILD_DIR ) /% ,$(OBJECTS ) )
@@ -103,7 +115,7 @@ all: $(TARGET) $(AUX_TARGETS)
103
115
$(BUILD_DIR ) :
104
116
mkdir $(BUILD_DIR )
105
117
mkdir $(DEP_DIR )
106
- mkdir $(GEN_DIR )
118
+ mkdir -p $(GEN_DIR )
107
119
108
120
# order-only prerequisite; OBJECTS don't depend on modification date anymore
109
121
$(OBJECTS ) : $(AUX_DEPS ) | $(BUILD_DIR )
@@ -140,26 +152,12 @@ $(BUILD_DIR)/$(FONT_O): $(FONT_S)
140
152
$(BUILD_DIR ) /uzeboxVideoEngineCore.o : $(FILE_S_VMODE_ASM_SOURCE ) $(FILES_H )
141
153
142
154
ifneq ($(FONT_PNG ) ,)
143
- $(FONT_S ) : $(DATA_DIR ) / $( FONT_PNG )
155
+ $(FONT_S ) : $(FONT_PNG )
144
156
python3 tile_generator.py $< $(GEN_DIR )
145
157
endif
146
158
147
- # # TODO: figure out how to get just the C files that actually depend on the inc/h files to have rules
148
- # # depending on them
149
- # $(GEN_DIR): $(patsubst $(DATA_DIR)/%.png,$(GEN_DIR)/%.inc, \
150
- # $(shell find $(DATA_DIR) -type f -iname '*.png'))
151
159
$(GEN_DIR ) : $(FONT_S )
152
160
153
- # # $(DATA_DIR)/%.png: $(DATA_DIR)/%.map.json
154
- # # $(GEN_DIR)/%.inc $(GEN_DIR)/%.h: $(DATA_DIR)/%.png # $(DATA_DIR)/%.map.json
155
- # # $(BIN_DIR)/tile_converter.py $< $(GEN_DIR)
156
- # $(GEN_DIR)/%.inc: $(DATA_DIR)/%.png
157
- # gconvert $(DATA_DIR)/font.gconvert.xml
158
- # @echo "*** Gconvert finished ***"
159
- # # remove warning about only using video mode 9
160
- # @sed -ni '/^#if/,/^#endif/ d; p' $@
161
- # @echo
162
-
163
161
# -------------------------------- final targets
164
162
$(TARGET ) : $(OBJECTS )
165
163
@echo " LINK"
0 commit comments