This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (103 loc) · 4.69 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
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell sh -c 'uname -s 2>/dev/null || echo not')
endif
#OBJS specifies which files to compile as part of the project
OBJS = ./*cpp ./src/*o
ifeq ($(detected_OS),Windows)
endif
#CC specifies which compiler we're using
CC = g++
ASTYLE = astyle
SRCS=$(wildcard ./src/*.cpp)
PROGS = $(patsubst ./src/%.cpp, ./build/%.o,$(SRCS))
.DEFAULT_GOAL := default
# -w suppresses all warnings
# -Wl,-subsystem,windows gets rid of the console window
#COMPILER_FLAGS = -fpermissive -m64 -s -Wall
LIBRARY_PATHS = -L ./lib
INCLUDE_PATHS = -I ./include -I ./glfw/include -I . -I ./meshoptimizer/src
#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -static-libgcc -static-libstdc++
#-lpthread
WINAPI = -lmingw32 -lkernel32 -lm -ldxguid -ldxerr8 -luser32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lgdi32 -lcomdlg32 -lwinspool
WINAPI+= -lcomctl32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lshlwapi -lversion -ldbghelp -lwinpthread
_UNIX = -lpthread -lX11 -lxcb -lXau -lXext -lXdmcp -lpthread -ldl
VETHER = -lVEther -lglfw -lglslang -lbullet3 -lmeshoptimizer
#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = vether.exe
#for further optimization use -flto flag.
SHARED_FLAGS = -O3 -g -Wl,--no-relax -m64 -Wall -Wextra -masm=intel -fno-align-functions -fno-exceptions -Wno-deprecated-copy -Wno-unused-parameter -Wno-cast-function-type -Wno-write-strings
export SHARED_FLAGS
#-mpush-args -mno-accumulate-outgoing-args -mno-stack-arg-probe
#Monolithic compile.
all :
$(CC) -Os -static $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(SHARED_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)
allwin :
$(CC) -Os -static $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(SHARED_FLAGS) $(LINKER_FLAGS) $(WINAPI) -o $(OBJ_NAME)
all_individual : $(PROGS)
./build/%.o: ./src/%.cpp
$(CC) -c -static $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(SHARED_FLAGS) $(LINKER_FLAGS) $(WINAPI) -o $@ $<
VEther:
$(MAKE) all -C ./glsl_compiler
$(MAKE) all -C ./glfw
$(MAKE) all -C ./bullet3
$(MAKE) all -C ./meshoptimizer
$(MAKE) all -C ./src
#Building a static lib out of src files. Benefits - faster compile time. Makes project modular.
#all_slwin <- use this for compilation on windows OS.
all_slwin: VEther
$(CC) -flto -static main.cpp $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(VETHER) $(SHARED_FLAGS) $(LINKER_FLAGS) $(WINAPI) -o $(OBJ_NAME)
glsl_m32: SHARED_FLAGS = -Os -m32 -s -Wall -Wextra -fno-align-functions -fno-exceptions -Wno-unused-parameter -Wno-cast-function-type -Wno-write-strings
glsl_m32:
$(MAKE) all -C ./glsl_compiler
all_flto: SHARED_FLAGS = -flto -O3 -m32 -s -Wall -Wextra -fno-align-functions -fno-exceptions -Wno-unused-parameter -Wno-cast-function-type -Wno-write-strings
all_flto: glsl_m32
$(MAKE) all -C ./glfw
$(MAKE) all -C ./bullet3
$(MAKE) all -C ./meshoptimizer
$(MAKE) all -C ./src
$(CC) -flto -static main.cpp $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(VETHER) $(SHARED_FLAGS) $(LINKER_FLAGS) $(WINAPI) -o $(OBJ_NAME)
#all_sl <- any other system.
all_sl: VEther
$(CC) main.cpp $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(VETHER) $(SHARED_FLAGS) $(_UNIX) -o $(OBJ_NAME)
all_u:
$(MAKE) all -C ./glsl_compiler
$(MAKE) all -C ./glfw
$(MAKE) all -C ./bullet3
$(MAKE) all -C ./meshoptimizer
$(CC) -c $(SHARED_FLAGS) $(INCLUDE_PATHS) -I ./bullet3 -I ./src -o ./lib/vether.o vether.cpp
ar -cvr ./lib/libVEther.a ./lib/vether.o
gcc-ranlib ./lib/libVEther.a
$(CC) main.cpp $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(VETHER) $(SHARED_FLAGS) $(_UNIX) -o $(OBJ_NAME)
debug:
objcopy --only-keep-debug $(OBJ_NAME) main.debug
clean_f:
find . -type f -name '*.orig' -delete
clean:
$(MAKE) clean -C ./glsl_compiler
$(MAKE) clean -C ./src
$(MAKE) clean -C ./glfw
$(MAKE) clean -C ./bullet3
$(MAKE) clean -C ./meshoptimizer
find . -type f -name '*.o' -delete
c:
$(MAKE) clean -C ./src
.IGNORE format:
$(ASTYLE) --style=allman --indent=tab --recursive *.c, *.cpp, *.h, *.hpp
etags:
find . \( -name "*[tT]est*" -o -name "CVS" -o -name "*#*" -o -name "html" -o -name "*~" -o -name "*.ca*" \) -prune -o \( -iname "*.c" -o -iname "*.cpp" -o -iname "*.cxx" -o -iname "*.h" -o -iname "*.hh" \) -exec etags -a {} \;
print:
echo "Please specify the target."
echo "make all_slwin = incremental build for windows"
echo "make all_flto = 32 bit lto build for windows"
echo "make all_sl = incrementail build for *nix"
echo "make all_u = uniform build for *nix"
echo "make c = clean everything in ./src (because headers are not recompiled automatically with sl builds)"
echo "make clean = remove all build files"
echo "make format = use astyle to format all code"
echo "make clean_f = remove .orig files created by astyle"
echo "make etags = recursive etags generation"
default:
$(MAKE) print -s