-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.dos
225 lines (171 loc) · 6.39 KB
/
Makefile.dos
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# vi:syntax=make
ifneq ($(CALLER),MASTER)
include Makefile.inc
endif
# 1. Directories
OBJDIR_DOS := $(OBJDIR)/dos
DEPDIR_DOS := $(DEPDIR)/dos
GENDIR_DOS := $(GENDIR)/dos
CONVERT_OBJDIR_DOS := $(OBJDIR)/convert/dos
MAP2ASN_OBJDIR_DOS := $(OBJDIR)/map2asn/dos
# 2. Files
BIN_DOS := $(BINDIR)/$(DSEKAI).exe
DSEKAI_C_FILES_DOS_ONLY := \
src/main.c \
unilayer/src/input/dosi.c \
unilayer/src/graphics/dosg.c \
unilayer/src/memory/dosm.c \
unilayer/src/save/file.c
# This includes ALL object files, including engines and unilayer.
# These are further subdivided in the rule to generate the .lnk script, below.
DSEKAI_O_FILES_DOS := \
$(addprefix $(OBJDIR_DOS)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \
$(addprefix $(OBJDIR_DOS)/,$(subst .c,.o,$(DSEKAI_C_FILES_DOS_ONLY))) \
$(addprefix $(OBJDIR_DOS)/,$(subst .c,.o,$(DSEKAI_C_FILES_RES)))
DSEKAI_OVERLAYS_DOS := $(foreach f,$(DSEKAI_C_FILES_ENGINES),$(subst src/,$(BINDIR)/,$(subst .c,.ovl,$f)))
# 2b. Utilities
CONVERT_O_FILES_DOS := \
$(addprefix $(CONVERT_OBJDIR_DOS)/,$(subst .c,.o,$(CONVERT_C_FILES)))
MAP2ASN_O_FILES_DOS := \
$(addprefix $(MAP2ASN_OBJDIR_DOS)/,$(subst .c,.o,$(MAP2ASN_C_FILES)))
# 2c. Packaging Manifest
DOS_MANIFEST :=
ifeq ($(RESOURCE),FILE)
ifeq ($(DEPTH),VGA)
DOS_MANIFEST += $(subst .bmp,.vga,$(DSEKAI_ASSETS_BITMAPS))
else
# Assume CGA by default.
DOS_MANIFEST += $(subst .bmp,.cga,$(DSEKAI_ASSETS_BITMAPS))
endif
endif
ifeq ($(FMT_ASN),TRUE)
DOS_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON))
endif
ifeq ($(FMT_JSON),TRUE)
DOS_MANIFEST += $(DSEKAI_ASSETS_MAPS_JSON)
endif
RESEXT_H_DOS := $(GENDIR_DOS)/resext.h
# 3. Programs
CC_DOS := wcc
LD_DOS := wcl
WLINK := wlink
# 4. Arguments
ifeq ($(BUILD),RELEASE)
DEFINES_DEBUG :=
else
# Assume debug build.
DEFINES_DEBUG := -DDSEKAI_PROFILER
endif
DEFINES_SDL := \
$(DEFINES_DSEKAI) \
DEFINES_DOS := \
$(DEFINES_DSEKAI) \
$(DEFINES_DEPTH) \
$(DEFINES_RESOURCE) \
$(DEFINES_DEBUG) \
-DNO_ENGINE_POV \
-DNO_TRANSITIONS \
-DNO_ANIMATE \
-DNO_DRAW_ENGINE_BEHIND_MENU \
-DPLATFORM_DOS \
-DUSE_SOFTWARE_TEXT \
-DUSE_SOFTWARE_LINES \
-DDISABLE_WEATHER_EFFECTS \
-DGRAPHICS_CACHE_INITIAL_SZ=25 \
-DRESOURCE_PATH_MAX=28 \
-DNO_SCRIPT_COMPILER \
-DUSE_LOOKUPS
INCLUDES_DOS := \
$(subst -I ,-i=,$(INCLUDES_UNILAYER)) \
-i=$(GENDIR_DOS)
CFLAGS_DOS_BASIC := -os -hw -d0 -0 $(CFLAGS_OWC_GENERIC) -wo -we
# If we don't use the large memory model, we can't load assets reliably.
CFLAGS_DOS := -ml -DMEMORY_LARGE $(CFLAGS_DOS_BASIC) $(DEFINES_DOS) $(INCLUDES_DOS)
ifneq ($(BUILD),RELEASE)
CFLAGS_DOS += -DLOG_TO_FILE
endif
LDFLAGS_DOS := $(LDFLAGS_OWC_GENERIC)
# 4b. Utilities
CFLAGS_UTILITY_DOS := -mh $(CFLAGS_DOS_BASIC) $(DEFINES_MAP2ASN) $(INCLUDES_DOS) -DPLATFORM_DOS
LDFLAGS_UTILITY_DOS := $(LDFLAGS_OWC_GENERIC) -k8192
# 5. Targets
platform := dos
platform_upper := DOS
ifeq ($(DEPTH),VGA)
res_gfx := $(subst .bmp,.vga,$(subst $(ASSETDIR)/,$(GENDIR_DOS)/,$(DSEKAI_ASSETS_BITMAPS)))
else
# Assume CGA by default.
res_gfx := $(subst .bmp,.cga,$(subst $(ASSETDIR)/,$(GENDIR_DOS)/,$(DSEKAI_ASSETS_BITMAPS)))
endif
$(eval $(RESEXT_H_RULE))
# DOS utilities give stack overflow right now.
pkg_bin := $(BIN_DOS) $(DSEKAI_OVERLAYS_DOS) $(BINDIR)/convert.exe $(BINDIR)/map2asn.exe
#pkg_bin := $(BIN_DOS)
pkg_strip := echo
pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH)
pkg_reqs := $(DOS_MANIFEST)
$(eval $(PKG_RULE))
#$(BINDIR)/doscga.drc: res_doscga_drc
#res_doscga_drc: $(DRCPACK) $(DSEKAI_ASSETS_DOS_CGA)
# rm $(BINDIR)/doscga.drc || true
# $(DRCPACK) -c -a -af $(BINDIR)/doscga.drc -i 5001 \
# -if $(GENDIR_DOS)/*.cga $(DSEKAI_ASSETS_MAPS) -lh $(GENDIR_DOS)/resext.h
# TODO: Should these ASSETDIR rules be removed?
#$(ASSETDIR)/%.cga: $(ASSETDIR)/%.bmp | $(CONVERT)
# $(CONVERT) -ic bmp -oc cga -ob 2 -if $< -of $@ -og
#
#$(ASSETDIR)/%.vga: $(ASSETDIR)/%.bmp | $(CONVERT)
# $(CONVERT) -ic bmp -oc cga -ob 8 -if $< -of $@ -og
$(BINDIR)/assets/%.cga: $(ASSETDIR)/%.bmp $(CONVERT) | \
$(BINDIR)/assets/$(STAMPFILE)
$(MD) $(dir $@)
$(CONVERT) -ic bmp -oc cga -ob 2 -if $< -of $@ -og
$(BINDIR)/assets/%.vga: $(ASSETDIR)/%.bmp $(CONVERT) | \
$(BINDIR)/assets/$(STAMPFILE)
$(MD) $(dir $@)
$(CONVERT) -ic bmp -oc cga -ob 4 -if $< -of $@ -og
$(GENDIR_DOS)/%.cga: $(ASSETDIR)/%.bmp | $(CONVERT) $(GENDIR_DOS)/$(STAMPFILE)
$(MD) $(dir $@)
$(CONVERT) -ic bmp -oc cga -ob 2 -if $< -of $@ -og
$(GENDIR_DOS)/%.vga: $(ASSETDIR)/%.bmp | $(CONVERT) $(GENDIR_DOS)/$(STAMPFILE)
$(MD) $(dir $@)
$(CONVERT) -ic bmp -oc cga -ob 4 -if $< -of $@ -og
$(BIN_DOS) $(DSEKAI_OVERLAYS_DOS): $(DSEKAI_O_FILES_DOS) | $(OBJDIR_DOS)/dsekai.lnk $(BINDIR)/$(STAMPFILE)
#$(LD_DOS) $(LDFLAGS_DOS) -fe=$@ $^
cd $(OBJDIR_DOS) && $(WLINK) $(LDFLAGS_DOS) @dsekai && cp -v dsekai.exe *.ovl ../../$(BINDIR)
# Create a linker script to handle overlays and other tricks.
$(OBJDIR_DOS)/dsekai.lnk: $(DSEKAI_O_FILES_DOS)
echo system dos > $@
echo option map >> $@
echo name dsekai >> $@
echo $(foreach f,$(DSEKAI_C_FILES_SUPPORT),file $(subst .c,,$f)\\n) >> $@
echo $(foreach f,$(DSEKAI_C_FILES_DOS_ONLY),file $(subst .c,,$f)\\n) >> $@
echo $(foreach f,$(DSEKAI_C_FILES_RES),file $(subst .c,,$f)\\n) >> $@
# Begin the engine overlay area.
echo begin >> $@
# New engine overlays go here. e.g. if the new engine is src/topdown.c, it
# should be added without extension below as src/topdown. The "into x" part
# creates a new overlay "library" for it to be inserted into (e.g. ovltopdn
# creates ovltopdn.ovl next to dsekai.exe that must be kept with it!)
echo $(foreach f,$(DSEKAI_C_FILES_ENGINES),section into $(subst src/,,$(subst .c,,$f)) file $(subst .c,,$f)\\n) >> $@
echo end >> $@
$(OBJDIR_DOS)/%.o: %.c $(RESEXT_H_DOS)
$(MD) $(dir $@)
$(CC_DOS) $(CFLAGS_DOS) -fo=$@ $(<:%.c=%)
#$(DEPDIR_DOS)/%.d: %.c $(RESEXT_H_DOS)
# $(MD) $(dir $@)
# $(HOST_CC) $(subst -i=,-I ,$(INCLUDES_DOS)) $(DEFINES_DOS) -MM $< \
# -MT $(subst .c,.o,$(addprefix $(DEPDIR_DOS)/,$<)) -MF $@
#
#include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_DOS:.o=.d))
# 5b. DOS Utilities
$(CONVERT_OBJDIR_DOS)/%.o: %.c
$(MD) $(dir $@)
$(CC_DOS) $(CFLAGS_UTILITY_DOS) -fo=$@ $(<:%.c=%)
$(BINDIR)/convert.exe: $(CONVERT_O_FILES_DOS)
$(LD_DOS) $(LDFLAGS_DOS) -fe=$@ $^
$(MAP2ASN_OBJDIR_DOS)/%.o: %.c
$(MD) $(dir $@)
$(CC_DOS) $(CFLAGS_UTILITY_DOS) -fo=$@ $(<:%.c=%)
$(BINDIR)/map2asn.exe: $(MAP2ASN_O_FILES_DOS) | $(BINDIR)/$(STAMPFILE)
$(LD_DOS) $(LDFLAGS_DOS) -fe=$@ $^