-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin_base.mk
131 lines (94 loc) · 4.03 KB
/
win_base.mk
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
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
DEFINES := $(ENGINE_DEFINES) $(GAME_DEFINES)
ENGINEDIR := $(GAMEDIR)/MinimalismEngine
ENGINESRC := src src/util windows
ifneq ($(strip $(USE_SDL)),)
ENGINESRC += sdl
endif
CC := gcc
CXX := g++
CFLAGS := -s -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -O2 \
-fomit-frame-pointer -ffunction-sections \
-mwindows -D_WINDOWS -DAPP_TITLE='"$(APP_TITLE)"' \
$(DEFINES)
CXXFLAGS := $(CFLAGS) $(INCLUDE) -fno-rtti -fno-exceptions -std=gnu++11 -static-libstdc++ -static-libgcc
LIBS := $(EXTRA_LIBS) -lmingw32
ifneq ($(strip $(USE_SDL)),)
CXXFLAGS += -D_USE_SDL
LIBS += $(SDL_LIBS)
endif
LIBDIRS :=
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(GAMEDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(OUTDIR)/$(TARGET)
export TOPDIR := $(GAMEDIR)
export VPATH := $(foreach dir,$(SOURCES),$(GAMEDIR)/$(dir)) \
$(foreach dir,$(DATA),$(GAMEDIR)/$(dir)) \
$(foreach dir,$(ENGINESRC),$(ENGINEDIR)/$(dir))
export DEPSDIR := $(GAMEDIR)/$(BUILD)
export CFILES := $(foreach dir,$(SOURCES),$(wildcard $(GAMEDIR)/$(dir)/*.c)) \
$(foreach dir,$(ENGINESRC),$(wildcard $(ENGINEDIR)/$(dir)/*.c))
export CPPFILES := $(foreach dir,$(SOURCES),$(wildcard $(GAMEDIR)/$(dir)/*.cpp)) \
$(foreach dir,$(ENGINESRC),$(wildcard $(ENGINEDIR)/$(dir)/*.cpp))
export RESFILES := $(foreach dir,$(META),$(wildcard $(GAMEDIR)/$(dir)/*.res))
export BINFILES := $(foreach dir,$(DATA),$(wildcard $(GAMEDIR)/$(dir)/*.*))
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
#export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
#export OFILES_BIN := $(addsuffix .o,$(BINFILES))
#export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
#export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(GAMEDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(ENGINESRC),-I$(ENGINEDIR)/$(dir)) \
-I$(GAMEDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifneq ($(strip $(RES_SCRIPT)),)
export APP_RES := $(GAMEDIR)/$(META)/$(RES_SCRIPT)
else
export APP_RES :=
endif
.PHONY: $(BUILD) all clean clean_output
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@mkdir -p $(BUILD) $(OUTDIR)
@windres $(APP_RES) -O coff -o $(APP_RES).res
@$(MAKE) --no-print-directory -C $(BUILD) -f $(ENGINEDIR)/win_base.mk
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTDIR)
clean_output:
@rm -fr $(OUTPUT).exe
#---------------------------------------------------------------------------------
else
.PHONY: all
all: $(OUTPUT).exe
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).exe :
$(LD) $(CXXFLAGS) $(CFILES) $(CPPFILES) $(RESFILES) $(LIBPATHS) $(LIBS) -o $(OUTPUT).exe
#$(OFILES_SRC) : $(HFILES)
#$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.res : %.rc
#---------------------------------------------------------------------------------
@windres $< -O coff -o $*.res
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------