-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·169 lines (127 loc) · 4.24 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
CC = gcc
CCX = g++
ifndef UNAME
UNAME = $(shell uname)
MA_AUDIO_ARGS = -ldl -lm
PIXEL_GAME_ENGINE_ARGS = -lX11 -lGL -lpthread -lstdc++fs -std=c++17 -lpng
CC_ARGS = -fno-stack-protector -finline-small-functions -flto -faggressive-loop-optimizations -funsafe-math-optimizations -fno-signed-zeros -fsingle-precision-constant -fcf-protection=none -fvtable-verify=none -march=native -fomit-frame-pointer -Wno-unused-result -Wno-unknown-pragmas -Wno-incompatible-pointer-types $(MA_AUDIO_ARGS)
CCX_ARGS = -Wno-unused-result -Wno-unknown-pragmas $(PIXEL_GAME_ENGINE_ARGS) -ldl -lm
DEFINES_DEF = DATE="\"`date`\"" VER="\"$(VERSION)\"" PROG_NAME="\"$(BUILD)\"" OS_CLEAR="\"$(OS_CLEAR)\"" FORCE_EXPERIMENTAL_FS
else
PIXEL_GAME_ENGINE_ARGS = -lpthread -luser32 -lgdi32 -lopengl32 -lgdiplus -ldwmapi -lstdc++fs -std=c++17
CC_ARGS = -std=c++17 -static $(PIXEL_GAME_ENGINE_ARGS)
DEFINES_DEF = DATE="\"`date`\"" VER="\"$(VERSION)\"" PROG_NAME="\"$(BUILD)\"" OS_CLEAR="\"$(OS_CLEAR)\""
endif
ODIR := build
ROOT_DIRECTORY=.
SOURCES := ${shell find ${ROOT_DIRECTORY} -type d -print}
INCLUDE := ./include
C_FILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c) )
C_FILES := $(filter-out ./include/sound/stb_vorbis.c,$(C_FILES))
CPP_FILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp) ) #$(wildcard *.cpp)
H_FILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.h) ) $(wildcard *.h)
ASM_FILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.asm) ) $(wildcard *.asm)
S_FILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.s) ) $(wildcard *.s)
O_FILES = $(abspath $(addprefix $(ODIR)/, $(CPP_FILES:.cpp=.o))) $(abspath $(addprefix $(ODIR)/, $(C_FILES:.c=.o)))
VERSION := 0.0
ifeq ($(UNAME), Linux)
BUILD := ppc
DEFINE_PREFIX = -
OS_CLEAR = clear
else
BUILD := ppc.exe
DEFINE_PREFIX = -
OS_CLEAR = cls
endif
FORCE_EXPERIMENTAL_FS=true
ifndef $(DEBUG)
DEBUG = false
endif
ifeq ($(DEBUG), true)
DEFINES_DEF += DEBUG=$(DEBUG)
CC_ARGS += -g
CCX_ARGS += -g
CC_ARGS += -Wall
CCX_ARGS += -Wall
else
CC_ARGS += -Ofast
#CCX_ARGS += -Ofast
endif
DEFINES = $(foreach def,$(DEFINES_DEF), $(DEFINE_PREFIX)D$(def))
ifeq ($(UNAME), Windows)
DEFINES =
endif
$(ODIR)/./%.o : %.cpp
@echo $(notdir $(basename $*)).cpp
@mkdir -p $(dir $@)
@$(CCX) -c $*.cpp -o $@ -I $(INCLUDE) $(CCX_ARGS) $(DEFINES)
$(ODIR)/./%.o : %.c
@echo $(notdir $(basename $*)).c
@mkdir -p $(dir $@)
@$(CC) -c $*.c -o $@ -I $(INCLUDE) $(CC_ARGS) $(DEFINES)
.PHONY: all
.PHONY: message
.PHONY: compile
.PHONY: wine_release
.PHONY: wine_deubg
.PHONY: build
.PHONY: debug
.PHONY: release
.PHONY: ok
$(BUILD): debug
all: clean compile run
compile: message $(addprefix $(ODIR)/, $(CPP_FILES:.cpp=.o)) $(addprefix $(ODIR)/, $(C_FILES:.c=.o)) | $(ODIR)
@$(CCX) $(O_FILES) -o $(BUILD) -I $(INCLUDE) $(CC_ARGS) $(CCX_ARGS) $(DEFINES)
#@strip $(BUILD) -o $(BUILD).tmp
#@mv $(BUILD).tmp $(BUILD)
message:
@echo Building ...
@echo "\tDebug Build = $(DEBUG)"
@echo "\tTarget = $(UNAME)"
@echo "\tVersion = $(VERSION)"
@echo "\tC++ Files to Compile = $(words $(CPP_FILES))"
@echo "\tC Files to Compile = $(words $(C_FILES))"
$(ODIR):
@mkdir -p $@
link:
@echo $(CCX) $(O_FILES) -o $(BUILD) -I $(INCLUDE) $(CC_ARGS) $(CCX_ARGS) $(DEFINES)
run:
@./$(BUILD)
clean:
@rm -rf $(ODIR)
@rm -rf x64
@rm -rf Debug
@rm -rf Release
@rm -rf .vs
@rm -rf $(BUILD)
debug:
@$(MAKE) compile DEBUG=true --no-print-directory
release:
@$(MAKE) compile --no-print-directory
compile1:
@$(foreach cc,$(CPP_FILES), $(shell $(CC) -I $(INCLUDE) $(CC_ARGS) $(DEFINES) -c $(cc) -o $(ODIR)/$(notdir $(basename $(cc)).o)))
@$(CC) -o $(BUILD) -I $(INCLUDE) $(CC_ARGS) $(DEFINES) $(O_FILES)
compile2:
#@$(CC) -o $(BUILD) -I $(INCLUDE) $(CC_ARGS) $(DEFINES) $(CPP_FILES)
@$(CC) $(CPP_FILES) -o $(BUILD) -I $(INCLUDE) $(CC_ARGS) $(DEFINES)
#rm $(find ./$(ODIR)/ -name *.o)
wine_debug:
@$(MAKE) UNAME=Windows DEBUG=true --no-print-directory
wine_release:
@$(MAKE) UNAME=Windows --no-print-directory
#FOR DEBUGGGING PURPOSES
print:
#@echo $(CC) -o $(BUILD) -I $(INCLUDE) $(CC_ARGS) $(DEFINES) $(CPP_FILES)
@echo $(CC) $*.cpp -o $@ -I $(INCLUDE) $(CC_ARGS) $(DEFINES)
print_H:
@echo $(H_FILES)
print_O:
@echo $(O_FILES)
print_C:
@echo $(C_FILES)
print_CPP:
@echo $(CPP_FILES)
print_dir:
@echo $(dir include/resource/resources.h)
print_CC:
@echo $(UNAME)