-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.win32
165 lines (116 loc) · 3.96 KB
/
Makefile.win32
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
# vi:syntax=make
ifneq ($(CALLER),MASTER)
include Makefile.inc
endif
# 1. Directories
OBJDIR_WIN32 := $(OBJDIR)/win32
DEPDIR_WIN32 := $(DEPDIR)/win32
GENDIR_WIN32 := $(GENDIR)/win32
CONVERT_OBJDIR_WIN32 := $(OBJDIR)/convert/win32
MAP2ASN_OBJDIR_WIN32 := $(OBJDIR)/map2asn/win32
# 2. Files
BIN_WIN32 := $(BINDIR)/$(DSEKAI)32.exe
DSEKAI_C_FILES_WIN32_ONLY := \
src/main.c \
src/pov.c \
src/scparse.c \
unilayer/src/animate.c \
unilayer/src/input/wini.c \
unilayer/src/memory/winm.c \
unilayer/src/graphics/wing.c \
unilayer/src/save/file.c
ifeq ($(RESOURCE),DEFAULT)
DSEKAI_C_FILES_WIN32_ONLY += unilayer/src/resource/winr.c
else
DSEKAI_C_FILES_WIN32_ONLY += $(DSEKAI_C_FILES_RES)
endif
DSEKAI_O_FILES_WIN32 := \
$(addprefix $(OBJDIR_WIN32)/,$(subst .c,.o,$(DSEKAI_C_FILES))) \
$(addprefix $(OBJDIR_WIN32)/,$(subst .c,.o,$(DSEKAI_C_FILES_WIN32_ONLY)))
WIN32_RES_FILES := src/winstat.rc
ifeq ($(RESOURCE),DEFAULT)
WIN32_RES_FILES += $(GENDIR_WIN32)/win.rc
endif
WIN32_RES_FILES += $(ASSETDIR)/$(DSEKAI).ico
# 2b. Utilities
# Rough hack: replace "fake" with "win" to use the correct memory module.
CONVERT_O_FILES_WIN32 := \
$(addprefix $(CONVERT_OBJDIR_WIN32)/,$(subst .c,.o,$(subst fake,win,$(CONVERT_C_FILES))))
MAP2ASN_O_FILES_WIN32 := \
$(addprefix $(MAP2ASN_OBJDIR_WIN32)/,$(subst .c,.o,$(subst fake,win,$(MAP2ASN_C_FILES))))
# 1a. Packaging Manifest
WIN32_MANIFEST :=
ifeq ($(RESOURCE),FILE)
WIN32_MANIFEST += $(DSEKAI_ASSETS_BITMAPS)
endif
ifeq ($(FMT_ASN),TRUE)
WIN32_MANIFEST += $(subst .json,.asn,$(DSEKAI_ASSETS_MAPS_JSON))
endif
ifeq ($(FMT_JSON),TRUE)
WIN32_MANIFEST += \
$(DSEKAI_ASSETS_MAPS_JSON) \
$(DSEKAI_ASSETS_TILESETS_JSON)
endif
RESEXT_H_WIN32 := $(GENDIR_WIN32)/resext.h
# 3. Programs
CC_WIN32 := wcc386
LD_WIN32 := wcl386
RC_WIN32 := wrc
# 4. Arguments
DEFINES_WIN32 := \
$(DEFINES_DSEKAI) \
$(DEFINES_DEPTH) \
-DPLATFORM_WIN32
INCLUDES_WIN32 := \
$(subst -I ,-i=,$(INCLUDES_UNILAYER)) \
-i=$(GENDIR_WIN32) \
-i=$(INCLUDE)/nt
CFLAGS_WIN32_BASIC := -bt=nt -3 -zp=1
CFLAGS_WIN32 := $(CFLAGS_WIN32_BASIC) $(CFLAGS_OWC_GENERIC) $(DEFINES_WIN32) $(INCLUDES_WIN32)
ifneq ($(RESOURCE),DEFAULT)
CFLAGS_WIN32 += $(subst -I ,-I=,$(DEFINES_RESOURCE))
endif
ifneq ($(BUILD),RELEASE)
CFLAGS_WIN16 += -DLOG_TO_FILE
endif
LDFLAGS_WIN32 := -bcl=nt_win -zp=1 $(LDFLAGS_OWC_GENERIC)
RCFLAGS_WIN32 := -r $(DEFINES_WIN32) -i=$(INCLUDE)win -bt=nt
ifeq ($(RESOURCE),DEFAULT)
RCFLAGS_WIN32 += -DRESOURCE_WIN
endif
# 4b. Utilities
CFLAGS_UTILITY_WIN32 := $(CFLAGS_WIN32_BASIC) $(DEFINES_MAP2ASN) $(INCLUDES_WIN32) -DPLATFORM_WIN32
# 5. Targets
platform := win32
platform_upper := WIN32
res_gfx := $(DSEKAI_ASSETS_BITMAPS)
$(eval $(RESEXT_H_RULE))
pkg_bin := $(BIN_WIN32) $(BINDIR)/conv32.exe $(BINDIR)/mapasn32.exe
pkg_strip := echo
pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH)
pkg_reqs := $(WIN32_MANIFEST)
$(eval $(PKG_RULE))
$(BIN_WIN32): \
$(DSEKAI_O_FILES_WIN32) $(OBJDIR_WIN32)/win.res | $(BINDIR)/$(STAMPFILE)
$(LD_WIN32) $(LDFLAGS_WIN32) -fe=$@ $^
$(OBJDIR_WIN32)/win.res: $(WIN32_RES_FILES) | $(OBJDIR_WIN32)/$(STAMPFILE)
$(RC_WIN32) $(RCFLAGS_WIN32) $< -fo=$@
$(OBJDIR_WIN32)/%.o: %.c $(OBJDIR_WIN32)/win.res $(RESEXT_H_WIN32)
$(MD) $(dir $@)
$(CC_WIN32) $(CFLAGS_WIN32) -fo=$@ $(<:%.c=%)
#$(DEPDIR_WIN32)/%.d: %.c $(RESEXT_H_WIN32)
# $(MD) $(dir $@)
# $(HOST_CC) $(subst -i=,-I ,$(INCLUDES_WIN32)) $(DEFINES_WIN32) -MM $< \
# -MT $(subst .c,.o,$(addprefix $(DEPDIR_WIN32)/,$<)) -MF $@
#include $(subst $(OBJDIR)/,$(DEPDIR)/,$(DSEKAI_O_FILES_WIN32:.o=.d))
# 5b. Windows Utilities
$(CONVERT_OBJDIR_WIN32)/%.o: %.c
$(MD) $(dir $@)
$(CC_WIN32) $(CFLAGS_UTILITY_WIN32) -fo=$@ $(<:%.c=%)
$(BINDIR)/conv32.exe: $(CONVERT_O_FILES_WIN32)
$(LD_WIN32) $(LDFLAGS_WIN32) -fe=$@ $^
$(MAP2ASN_OBJDIR_WIN32)/%.o: %.c
$(MD) $(dir $@)
$(CC_WIN32) $(CFLAGS_UTILITY_WIN32) -fo=$@ $(<:%.c=%)
$(BINDIR)/mapasn32.exe: $(MAP2ASN_O_FILES_WIN32) | $(BINDIR)/$(STAMPFILE)
$(LD_WIN32) $(LDFLAGS_WIN32) -fe=$@ $^