forked from XboxDev/nxdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
192 lines (155 loc) · 4.32 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
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
ifeq ($(NXDK_DIR),)
NXDK_DIR = $(shell pwd)
endif
ifeq ($(XBE_TITLE),)
XBE_TITLE = nxdk_app
endif
ifeq ($(OUTPUT_DIR),)
OUTPUT_DIR = bin
endif
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
LD = nxdk-link
LIB = nxdk-lib
AS = nxdk-as
CC = nxdk-cc
CXX = nxdk-cxx
ifeq ($(UNAME_S),Linux)
ifneq ($(UNAME_M),x86_64)
CGC = $(NXDK_DIR)/tools/cg/linux/cgc.i386
else
CGC = $(NXDK_DIR)/tools/cg/linux/cgc
endif #UNAME_M != x86_64
endif
ifeq ($(UNAME_S),Darwin)
CGC = $(NXDK_DIR)/tools/cg/mac/cgc
endif
ifneq (,$(findstring MSYS_NT,$(UNAME_S)))
$(error Please use a MinGW64 shell)
endif
ifneq (,$(findstring MINGW,$(UNAME_S)))
CGC = $(NXDK_DIR)/tools/cg/win/cgc
endif
TARGET = $(OUTPUT_DIR)/default.xbe
CXBE = $(NXDK_DIR)/tools/cxbe/cxbe
VP20COMPILER = $(NXDK_DIR)/tools/vp20compiler/vp20compiler
FP20COMPILER = $(NXDK_DIR)/tools/fp20compiler/fp20compiler
EXTRACT_XISO = $(NXDK_DIR)/tools/extract-xiso/build/extract-xiso
TOOLS = cxbe vp20compiler fp20compiler extract-xiso
ifeq ($(DEBUG),y)
NXDK_ASFLAGS += -g -gdwarf-4
NXDK_CFLAGS += -g -gdwarf-4
NXDK_CXXFLAGS += -g -gdwarf-4
NXDK_LDFLAGS += -debug
endif
ifeq ($(LTO),y)
NXDK_ASFLAGS += -flto
NXDK_CFLAGS += -flto
NXDK_CXXFLAGS += -flto
endif
ifneq ($(GEN_XISO),)
TARGET += $(GEN_XISO)
endif
ifneq ($(NXDK_ONLY),)
NXDK_CXX = y
NXDK_SDL = y
TARGET = main.exe
endif
all: $(TARGET)
include $(NXDK_DIR)/lib/Makefile
OBJS = $(addsuffix .obj, $(basename $(SRCS)))
ifneq ($(NXDK_CXX),)
include $(NXDK_DIR)/lib/libcxx/Makefile.nxdk
endif
include $(NXDK_DIR)/lib/net/Makefile
ifneq ($(NXDK_SDL),)
include $(NXDK_DIR)/lib/sdl/SDL2/Makefile.xbox
include $(NXDK_DIR)/lib/sdl/Makefile
endif
V = 0
VE_0 := @
VE_1 :=
VE = $(VE_$(V))
ifeq ($(V),1)
QUIET=
else
QUIET=>/dev/null
endif
DEPS := $(filter %.c.d, $(SRCS:.c=.c.d))
DEPS += $(filter %.cpp.d, $(SRCS:.cpp=.cpp.d))
$(OUTPUT_DIR)/default.xbe: main.exe $(OUTPUT_DIR) $(CXBE)
@echo "[ CXBE ] $@"
$(VE)$(CXBE) -OUT:$@ -TITLE:$(XBE_TITLE) $< $(QUIET)
$(OUTPUT_DIR):
@mkdir -p $(OUTPUT_DIR);
ifneq ($(GEN_XISO),)
$(GEN_XISO): $(OUTPUT_DIR)/default.xbe $(EXTRACT_XISO)
@echo "[ XISO ] $@"
$(VE) $(EXTRACT_XISO) -c $(OUTPUT_DIR) $(XISO_FLAGS) "$@" $(QUIET)
endif
$(SRCS): $(SHADER_OBJS)
ifneq ($(NXDK_ONLY),)
.PHONY: main.exe
main.exe: $(OBJS)
else
main.exe: $(OBJS) $(NXDK_DIR)/lib/xboxkrnl/libxboxkrnl.lib
@echo "[ LD ] $@"
$(VE) $(LD) $(NXDK_LDFLAGS) $(LDFLAGS) -out:'$@' $^
endif
%.lib:
@echo "[ LIB ] $@"
$(VE) $(LIB) -out:'$@' $^
%.obj: %.cpp
@echo "[ CXX ] $@"
$(VE) $(CXX) $(NXDK_CXXFLAGS) $(CXXFLAGS) -MD -MP -MT '$@' -MF '$(patsubst %.obj,%.cpp.d,$@)' -c -o '$@' '$<'
%.obj: %.c
@echo "[ CC ] $@"
$(VE) $(CC) $(NXDK_CFLAGS) $(CFLAGS) -MD -MP -MT '$@' -MF '$(patsubst %.obj,%.c.d,$@)' -c -o '$@' '$<'
%.obj: %.s
@echo "[ AS ] $@"
$(VE) $(AS) $(NXDK_ASFLAGS) $(ASFLAGS) -c -o '$@' '$<'
%.inl: %.vs.cg $(VP20COMPILER)
@echo "[ CG ] $@"
$(VE) $(CGC) -profile vp20 -o $@.$$$$ $< $(QUIET) && \
$(VP20COMPILER) $@.$$$$ > $@ && \
rm -rf $@.$$$$
%.inl: %.ps.cg $(FP20COMPILER)
@echo "[ CG ] $@"
$(VE) $(CGC) -profile fp20 -o $@.$$$$ $< $(QUIET) && \
$(FP20COMPILER) $@.$$$$ > $@ && \
rm -rf $@.$$$$
tools: $(TOOLS)
.PHONY: tools $(TOOLS)
cxbe: $(CXBE)
$(CXBE):
@echo "[ BUILD ] $@"
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/cxbe $(QUIET)
vp20compiler: $(VP20COMPILER)
$(VP20COMPILER):
@echo "[ BUILD ] $@"
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/vp20compiler $(QUIET)
fp20compiler: $(FP20COMPILER)
$(FP20COMPILER):
@echo "[ BUILD ] $@"
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/fp20compiler $(QUIET)
extract-xiso: $(EXTRACT_XISO)
$(EXTRACT_XISO):
@echo "[ BUILD ] $@"
$(VE)(mkdir $(NXDK_DIR)/tools/extract-xiso/build; \
cd $(NXDK_DIR)/tools/extract-xiso/build && \
cmake -G "Unix Makefiles" .. $(QUIET) && \
$(MAKE) $(QUIET))
.PHONY: clean
clean: $(CLEANRULES)
$(VE)rm -f $(TARGET) \
main.exe main.exe.manifest main.lib \
$(OBJS) $(SHADER_OBJS) $(DEPS) \
$(GEN_XISO)
.PHONY: distclean
distclean: clean
$(VE)rm -rf $(NXDK_DIR)/tools/extract-xiso/build
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/fp20compiler distclean $(QUIET)
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/vp20compiler distclean $(QUIET)
$(VE)$(MAKE) -C $(NXDK_DIR)/tools/cxbe clean $(QUIET)
$(VE)bash -c "if [ -d $(OUTPUT_DIR) ]; then rmdir $(OUTPUT_DIR); fi"
-include $(DEPS)