-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile.old
More file actions
executable file
·193 lines (156 loc) · 4.54 KB
/
Makefile.old
File metadata and controls
executable file
·193 lines (156 loc) · 4.54 KB
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
VULKANCFLAGS=/
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
detected_OS := Windows
else
detected_OS := $(shell uname)
endif
VULKANLIBS?=-lvulkan
ifeq ($(detected_OS),Darwin)
# -all_load is only needed for a static library; move to dynamicl and it goes away
PLATFORM_LDFLAGS=-framework Cocoa -framework IOSurface -framework IOKit \
-framework CoreGraphics -framework QuartzCore -lstdc++ -framework Metal \
-rdynamic -all_load \
-fsanitize=address
AR?=ar
ARCOMMAND?=ru
endif
ifeq ($(detected_OS),Linux)
PLATFORM_LDFLAGS=-lasan -lcheck -ldl
AR?=ar
ARCOMMAND?=r
endif
PKGS=talloc glfw3 check
CTAGS=/opt/homebrew/bin/ctags
# From: https://airbus-seclab.github.io/c-compiler-security/#clang-tldr
# Removed: -Wfloat-equal <- too many floats
# Removed: -Wcast-qual <- stb image is super unhappy about this
# Not yet: -Wconversion; many of them
# Not yet: -Wvla; detects the function param one, which is annoying
# Not yet: -Wvla-larger-than=0 ; gcc only
# Not yet: -Wimplicit-fallthrough
# Not yet; built in is set to '0'; -D_FORTIFY_SOURCE=2
WARNINGS= \
-Werror \
-Wall -Wextra \
-Walloca -Wformat=2 -Wformat-security -Wnull-dereference \
-Wstack-protector -Wstrict-overflow=3 -Warray-bounds \
-Warray-bounds-pointer-arithmetic -Wassign-enum -Wbad-function-cast \
-Wconditional-uninitialized -Wformat-type-confusion \
-Widiomatic-parentheses -Wloop-analysis -Wpointer-arith \
-Wshift-sign-overflow -Wshorten-64-to-32 -Wswitch-enum \
-Wtautological-constant-in-range-compare -Wunreachable-code-aggressive \
-fstack-protector-strong
OPTIMIZATION=-O2
CFLAGS+=-g ${OPTIMIZATION} ${WARNINGS} `pkg-config --cflags ${PKGS}` -F /Library/Frameworks \
-Ithird-party/cglm/include -fsanitize=address \
-I/usr/local/include -Ithird-party
LDFLAGS+=${PLATFORM_LDFLAGS} `pkg-config --libs ${PKGS}` ${VULKANLIBS}
ifdef GITHUB
CFLAGS+=-DGITHUB=1
endif
#SHADERCC?=glslc
SHADERCC?=~/work/vulkan/turtle-support/mac/glslc
TESTS= \
helpers.o \
trtl_shader.o \
trtl_shader_check.o \
trtl_solo.o \
trtl_solo_check.o \
trtl_timer.o \
trtl_timer_check.o \
trtl_uniform.o \
trtl_uniform_check.o \
turtle.o
SOURCES= \
vertex.c \
images.c \
stringlist.c \
helpers.c \
objloader.c \
blobby.c \
trtl_barriers.c \
trtl_uniform.c \
trtl_object_mesh_old.c \
trtl_object_canvas.c \
trtl_object_grid.c \
trtl_object_sprite.c \
trtl_pipeline.c \
trtl_scribe.c \
trtl_shader.c \
trtl_shell.c \
trtl_seer.c \
trtl_solo.c \
trtl_texture.c \
trtl_timer.c \
trtl_vulkan.c \
turtle.c
APPS=triangles
SHADERS= \
shaders/frag.spv \
shaders/vert.spv \
shaders/canvas/test-color-fill.spv \
shaders/canvas/stars-1.spv \
shaders/canvas/sepia.spv \
shaders/canvas/canvas-vertex.spv \
shaders/grid/lines.spv \
shaders/grid/grid-vertex.spv \
shaders/grid/browns.spv \
shaders/grid/red.spv \
shaders/sprite/sprite-vertex.spv \
shaders/sprite/sprite-fragment.spv
OBJECTS := $(SOURCES:%.c=%.o)
SHADER_OBJECTS := $(SHADERS:%.spv=%.o)
ALL: triangles libturtle.a trtl_check ${SHADERS}
# Dependancies (from http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr)
DEPDIR := .deps
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
%.o : %.c $(DEPDIR)/%.d | $(DEPDIR)
@echo Compile $<
@mkdir -p $(DEPDIR)
@$(COMPILE.c) $(OUTPUT_OPTION) $<
$(DEPDIR): ; @mkdir -p $@
DEPFILES := $(SOURCES:%.c=$(DEPDIR)/%.d)
$(DEPFILES):
include $(wildcard $(DEPFILES))
%.spv : %.frag
@echo Shader Compile $<
@${SHADERCC} -o $@ $<
%.spv : %.vert
@echo Shader Compile $<
@${SHADERCC} -o $@ $<
%.s: SYMBOLNAME=$(subst -,_,$(subst .,_,$(subst /,_,$<)))
%.s: %.spv
@echo Generate SPV binary $@
@echo "\t.global _data_start_${SYMBOLNAME}" > $@
@echo "\t.global _data_end_${SYMBOLNAME}" >> $@
@echo "\t.align 2" >> $@
@echo "_data_start_${SYMBOLNAME}:" >> $@
@echo "\t.incbin \"$<\"" >> $@
@echo "_data_end_${SYMBOLNAME}:" >> $@
# FIXME: Fix this dependancy
shaders/frag.spv: shaders/shader.frag
@echo Shader Compile $<
@${SHADERCC} -o $@ $<
shaders/vert.spv: shaders/shader.vert
${SHADERCC} -o $@ $<
trtl_check: trtl_check.o ${TESTS} ${OBJECTS}
${CC} -o $@ $^ ${LDFLAGS}
.PHONY: check
check: trtl_check
./trtl_check
libturtle.a: ${OBJECTS} ${SHADER_OBJECTS}
@echo Link #<
${AR} ${ARCOMMAND} $@ $^
@ranlib $@
triangles: triangles.o libturtle.a
.PHONY: clean
clean:
rm -f ${OBJECTS} triangles triangles.o ${SHADERS} ${SHADER_OBJECTS} libturtle.a
.PHONY: fixme
fixme:
@grep -in 'fixme\|todo\|xxx' *.[ch] | sort -R
.PHONY: tags
tags:
${CTAGS} *.c *.h
print-%: ; @echo $*=$($*)