-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
219 lines (170 loc) · 4.85 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
_SYS:=$(shell uname -o)
ifeq ($(_SYS),Msys)
WIN32:=1
endif
TARGET:=
TARGET+=main_cpp.exe
TARGET+=main_c.exe
TARGET+=mainmix_c.exe
TARGET+=maingl_c.exe
#TARGET+=main_v.exe
TARGET+=nsauzede/vsdl2/examples/main_v.exe
#TARGET+=tetris_v.exe
#TARGET+=tetrisnomix_v.exe
#TARGET+=tvintris.exe
#TARGET+=tvintris0_v.exe
#TARGET+=tvintrisgl_v.exe
#TARGET+=maingl_v.exe
TARGET+=glfnt.exe
ifndef WIN32
TARGET+=mainnk_v.exe
TARGET+=mainig_v.exe
endif
#CFLAGS:=
CFLAGS+=-Wall
#CFLAGS+=-Werror
CFLAGS+=-Wextra
#CFLAGS+=-pedantic
CFLAGS+=-Wno-unused-variable
CFLAGS+=-Wno-unused-parameter
CFLAGS+=-Wno-unused-result
CXXFLAGS:=
CXXFLAGS+=-Wall
CXXFLAGS+=-Werror
CXXFLAGS+=-Wextra
CXXFLAGS+=-g
CFLAGS+=-g
ifdef NOPT
CXXFLAGS+=-O0
CFLAGS+=-O0
endif
CXXFLAGS+=-I.
V:=./v/v
#VFLAGS:=-debug -show_c_cmd
VCFLAGS:=-std=gnu11 -w -g -O0
ifdef WIN32
GLLDLIBS:=-lopengl32 -lglu32
else
GLLDLIBS:=-lGL -lGLU
endif
GLADFLAGS:=-I ../v/thirdparty/ -I ../stb
GLADLIBS:=../v/thirdparty/glad/glad.o -l dl -lglfw
LDLIBS+=-L. -lgc
AR:=ar
all: SDL_CHECK SUBM_CHECK VMOD_CHECK $(TARGET)
VMOD_CHECK: V_CHECK NSAUZEDE_CHECK VSDL2_CHECK VNK_CHECK VIG_CHECK
nsauzede/vig/README.md:
git submodule deinit --force --all
git submodule update --init --recursive
SUBM_CHECK: nsauzede/vig/README.md
GC_CHECK: libgc.a
ifdef WIN32
GLLIBS:=-lGLEW32 -lopengl32 -lfreetype -lglfw3 -pthread
else
GLLIBS:=-lGLEW -lGL -lfreetype -lglfw -ldl -lX11 -pthread
endif
glfnt.exe: glfnt.cpp
g++ $^ $(CXXFLAGS) -o $@ `pkg-config freetype2 --cflags` -I v/thirdparty/ $(GLLIBS)
%gl_c.exe: LDLIBS+=$(GLLDLIBS)
%glsl_c.exe: LDLIBS+=$(GLLDLIBS)
%gl_v.exe: LDLIBS+=$(GLLDLIBS)
%glad.exe: CXXFLAGS+=$(GLADFLAGS)
%glad.exe: LDLIBS+=$(GLADLIBS)
libgc.o: v/thirdparty/libgc/gc.c
$(CC) -c $< -o $@
libgc.a: libgc.o
$(AR) cr $@ $^
include sdl.mak
ifeq ($(SDL_VER),1)
SDL_FLAGS+=-DSDL1
else
SDL_FLAGS+=-DSDL2
endif
#CFLAGS+=$(SDL_FLAGS)
#CXXFLAGS+=$(SDL_FLAGS)
%_cpp.exe: CXXFLAGS+=$(SDL_FLAGS)
%_c.exe: CFLAGS+=$(SDL_FLAGS)
%_v.exe: CFLAGS+=$(SDL_FLAGS)
tvintris.exe: CFLAGS+=$(SDL_FLAGS)
ifeq ($(SDL_VER),1)
LDLIBS+=$(SDL_LIBS) -lSDL_ttf -lSDL_mixer
else
LDLIBS+=$(SDL_LIBS) -lSDL2_ttf -lSDL2_mixer -lSDL2_image
endif
CFLAGS+=-pthread
CXXFLAGS+=-pthread
LDFLAGS+=-pthread
V_CHECK: $(V) GC_CHECK
$(V):
git clone --filter=tree:0 https://github.com/nsauzede/v
(cd $(@D) ; $(MAKE) ; cd -)
%ig_v.exe: CFLAGS+=-Insauzede/vig -DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1 -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1 -DIMGUI_IMPL_API= $(SDL_FLAGS)
%ig_v.exe: LDFLAGS=
%ig_v.exe: LDLIBS+=nsauzede/vig/imgui_impl_sdl2.o nsauzede/vig/imgui_impl_opengl3.o nsauzede/vig/cimgui/bld/CMakeFiles/cimgui.dir/cimgui.cpp.o nsauzede/vig/cimgui/bld/CMakeFiles/cimgui.dir/imgui/*.cpp.o $(SDL_LIBS) -lGL -lGLEW -lm -ldl
mainig.tmp.c: nsauzede/vig/examples/mainig/mainig.v | VIG_CHECK
$(V) -o $@ $(VFLAGS) $^
mainig_v.exe: mainig.tmp.o
$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)
NSAUZEDE_CHECK:
mkdir -p $(HOME)/.vmodules
rm -Rf $(HOME)/.vmodules/nsauzede
ln -sf $(PWD)/nsauzede $(HOME)/.vmodules
$(HOME)/.vmodules/nsauzede/vig/v.mod:
$(V) install nsauzede.vig
#.PHONY: _VIG_CHECK VIG_CHECK
_VIG_CHECK:
touch nsauzede/vig/v.mod
VIG_CHECK: _VIG_CHECK $(HOME)/.vmodules/nsauzede/vig/v.mod
$(MAKE) -C nsauzede/vig
%ig_v.exe: %ig_v.o | VIG_CHECK
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
ifdef WIN32
NKLDLIBS:=-lopengl32 -lglew32
else
NKLDLIBS:=-lGL -lGLEW
endif
%nk_v.exe: CFLAGS+=-Insauzede/vnk -DNK_INCLUDE_FIXED_TYPES -DNK_INCLUDE_STANDARD_IO -DNK_INCLUDE_STANDARD_VARARGS -DNK_INCLUDE_DEFAULT_ALLOCATOR -DNK_INCLUDE_VERTEX_BUFFER_OUTPUT -DNK_INCLUDE_FONT_BAKING -DNK_INCLUDE_DEFAULT_FONT -DNK_IMPLEMENTATION -DNK_SDL_GL3_IMPLEMENTATION $(SDL_FLAGS)
%nk_v.exe: LDFLAGS=
%nk_v.exe: LDLIBS+=$(SDL_LIBS) $(NKLDLIBS) -lm
$(HOME)/.vmodules/nsauzede/vsdl2/v.mod:
$(V) install nsauzede.vsdl2
#.PHONY: _VSDL2_CHECK VSDL2_CHECK
_VSDL2_CHECK:
touch nsauzede/vsdl2/v.mod
VSDL2_CHECK: _VSDL2_CHECK $(HOME)/.vmodules/nsauzede/vsdl2/v.mod
$(HOME)/.vmodules/nsauzede/vnk/v.mod:
$(V) install nsauzede.vnk
#.PHONY: _VNK_CHECK VNK_CHECK
_VNK_CHECK:
touch nsauzede/vnk/v.mod
VNK_CHECK: _VNK_CHECK $(HOME)/.vmodules/nsauzede/vnk/v.mod
$(MAKE) -C nsauzede/vnk
mainnk_v.c: nsauzede/vnk/examples/mainnk_v/mainnk_v.v
$(V) -o $@ $(VFLAGS) $^
%nk_v.exe: %nk_v.o | VNK_CHECK
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
%.exe: %.o
$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)
vsdlstub.o: vsdl/vsdlstub.c
$(CC) -c -o $@ $(CFLAGS) -g $^
ifdef WIN32
CFLAGS+=-Wno-incompatible-pointer-types
endif
tvintris.tmp.c: nsauzede/vsdl2/examples/tvintris/tvintris.v
$(V) -o $@ $(VFLAGS) $^
tvintris.exe: tvintris.tmp.o
$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)
%_v.exe: CFLAGS+=$(VCFLAGS)
#%_v.exe: LDLIBS+=vsdlstub.o
#%.c: %.v | vsdlstub.o
%.c: %.v
# $(MAKE) -s $(V)
$(V) -o $@ $(VFLAGS) $^
clean:
$(RM) $(TARGET) *.o *_v.c
clobber: clean
$(RM) *~ *.exe fns.txt *.tmp.c .tmp.*.c *.so *_v
mrproper: clobber
$(RM) -Rf v
$(MAKE) -C nsauzede/vig clobber
$(MAKE) -C nsauzede/vnk clobber