summaryrefslogtreecommitdiff
path: root/Makefile
blob: 312e062bd0259752cc572941194b03988d76c03d (plain) (blame)
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
# generated by configure.lua

cflags = -pedantic -Wall -Wextra -Dplat_x11 -Dplat_x86 -Dplat_posix -Dallocation_default_alignment=8 -Icfg -Iqstd -Isc/glslang -MMD -MF $(basename $@).d 

.PHONY: all clean
all: c2

ifndef config
  config=debug
endif
ifeq ($(config),debug)
  opt_com = -DDEBUG -g -O0
  opt_lnk =
endif
ifeq ($(config),release)
  opt_com = -DNDEBUG -O3
  opt_lnk = -s
endif

qstd/memory.o: qstd/memory.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c qstd/memory.c -o qstd/memory.o
qstd/plat.o: qstd/plat.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c qstd/plat.c -o qstd/plat.o
qstd/str.o: qstd/str.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c qstd/str.c -o qstd/str.o
qstd/pack.o: qstd/pack.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c qstd/pack.c -o qstd/pack.o
libqstd.a: qstd/memory.o qstd/plat.o qstd/str.o qstd/pack.o 
	ar -rcs libqstd.a qstd/memory.o qstd/plat.o qstd/str.o qstd/pack.o 

cfg/cfgparse.o: cfg/cfgparse.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c cfg/cfgparse.c -o cfg/cfgparse.o
libcfg.a: cfg/cfgparse.o 
	ar -rcs libcfg.a cfg/cfgparse.o 

sc/sc.o: sc/sc.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c sc/sc.cpp -o sc/sc.o
sc/includer.o: sc/includer.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c sc/includer.cpp -o sc/includer.o
shadercompiler: sc/sc.o sc/includer.o libqstd.a libcfg.a 
	g++ $(opt_lnk) $(lflags) -o shadercompiler sc/sc.o sc/includer.o libqstd.a libcfg.a -Lsc/glslang/build/glslang -Lsc/glslang/build/SPIRV -Lsc/glslang/build/glslang/OSDependent/Unix -Lsc/glslang/build/External/spirv-tools/source -Lsc/glslang/build/External/spirv-tools/source/link -Lsc/glslang/build/External/spirv-tools/source/opt -lglslang -lglslang-default-resource-limits -lSPIRV -lMachineIndependent -lSPVRemapper -lOSDependent -lGenericCodeGen -lSPIRV-Tools-link -lSPIRV-Tools-opt -lSPIRV-Tools 

app.o: app.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c app.cpp -o app.o
c2.o: c2.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c c2.cpp -o c2.o
video.o: video.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c video.cpp -o video.o
pipeline.o: pipeline.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c pipeline.cpp -o pipeline.o
asset.o: asset.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c asset.cpp -o asset.o
ui.o: ui.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c ui.cpp -o ui.o
maths.o: maths.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c maths.cpp -o maths.o
model.o: model.cpp
	g++ -std=c++20 $(opt_com) $(cflags) -c model.cpp -o model.o
c2: app.o c2.o video.o pipeline.o asset.o ui.o maths.o model.o libqstd.a 
	g++ $(opt_lnk) $(lflags) -o c2 app.o c2.o video.o pipeline.o asset.o ui.o maths.o model.o libqstd.a -lX11 -lm 

c2: pack

convtexture.o: convtexture.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c convtexture.c -o convtexture.o
convtexture: convtexture.o libqstd.a 
	gcc $(opt_lnk) $(lflags) -o convtexture convtexture.o libqstd.a 

convmodel.o: convmodel.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c convmodel.c -o convmodel.o
convmodel: convmodel.o libqstd.a 
	gcc $(opt_lnk) $(lflags) -o convmodel convmodel.o libqstd.a 

convmaterial.o: convmaterial.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c convmaterial.c -o convmaterial.o
convmaterial: convmaterial.o libqstd.a libcfg.a 
	gcc $(opt_lnk) $(lflags) -o convmaterial convmaterial.o libqstd.a libcfg.a 

packer.o: packer.c
	gcc -std=gnu99 $(opt_com) $(cflags) -c packer.c -o packer.o
packer: packer.o libqstd.a 
	gcc $(opt_lnk) $(lflags) -o packer packer.o libqstd.a 

data/triangle.csh: intermediate/triangle.glsl shadercompiler | data
	./shadercompiler intermediate/triangle.glsl data/triangle.csh
data/ui.csh: intermediate/ui.glsl shadercompiler | data
	./shadercompiler intermediate/ui.glsl data/ui.csh
data/surface.csh: intermediate/surface.glsl shadercompiler | data
	./shadercompiler intermediate/surface.glsl data/surface.csh
data/surface_depthonly.csh: intermediate/surface_depthonly.glsl shadercompiler | data
	./shadercompiler intermediate/surface_depthonly.glsl data/surface_depthonly.csh
data/sky.csh: intermediate/sky.glsl shadercompiler | data
	./shadercompiler intermediate/sky.glsl data/sky.csh
data/mip_spec.csh: intermediate/mip_spec.glsl shadercompiler | data
	./shadercompiler intermediate/mip_spec.glsl data/mip_spec.csh

data/monkey.mdl: convmodel intermediate/monkey.glb data/triangle.csh data/ui.csh data/surface.csh data/surface_depthonly.csh data/sky.csh data/mip_spec.csh | data
	./convmodel data intermediate/monkey.glb data/monkey.mdl

data/22.tex: convtexture intermediate/22.bmp | data
	./convtexture intermediate/22.bmp data/22.tex bc1
data/kita.tex: convtexture intermediate/kita.bmp | data
	./convtexture intermediate/kita.bmp data/kita.tex bc1
data/brick_albedo.tex: convtexture intermediate/brick_albedo.bmp | data
	./convtexture intermediate/brick_albedo.bmp data/brick_albedo.tex bc1
data/brick_ao.tex: convtexture intermediate/brick_ao.bmp | data
	./convtexture intermediate/brick_ao.bmp data/brick_ao.tex bc4
data/brick_normal.tex: convtexture intermediate/brick_normal.bmp | data
	./convtexture intermediate/brick_normal.bmp data/brick_normal.tex bc5
data/sky.tex: convtexture intermediate/sky.hdr | data
	./convtexture intermediate/sky.hdr data/sky.tex rgba16f

data/bricks.mat: convmaterial intermediate/bricks.mat | data
	./convmaterial intermediate/bricks.mat data/bricks.mat
data/plastic.mat: convmaterial intermediate/plastic.mat | data
	./convmaterial intermediate/plastic.mat data/plastic.mat

pack: packer data/triangle.csh data/ui.csh data/surface.csh data/surface_depthonly.csh data/sky.csh data/mip_spec.csh data/monkey.mdl data/22.tex data/kita.tex data/brick_albedo.tex data/brick_ao.tex data/brick_normal.tex data/sky.tex data/bricks.mat data/plastic.mat 
	./packer pack data triangle.csh ui.csh surface.csh surface_depthonly.csh sky.csh mip_spec.csh monkey.mdl 22.tex kita.tex brick_albedo.tex brick_ao.tex brick_normal.tex sky.tex bricks.mat plastic.mat 

data:
	mkdir -p data

-include qstd/memory.d qstd/plat.d qstd/str.d qstd/pack.d cfg/cfgparse.d sc/sc.d sc/includer.d app.d c2.d video.d pipeline.d asset.d ui.d maths.d model.d convtexture.d convmodel.d convmaterial.d packer.d 

clean:
	rm -f qstd/memory.o qstd/plat.o qstd/str.o qstd/pack.o cfg/cfgparse.o sc/sc.o sc/includer.o app.o c2.o video.o pipeline.o asset.o ui.o maths.o model.o convtexture.o convmodel.o convmaterial.o packer.o qstd/memory.d qstd/plat.d qstd/str.d qstd/pack.d cfg/cfgparse.d sc/sc.d sc/includer.d app.d c2.d video.d pipeline.d asset.d ui.d maths.d model.d convtexture.d convmodel.d convmaterial.d packer.d data/triangle.csh data/ui.csh data/surface.csh data/surface_depthonly.csh data/sky.csh data/mip_spec.csh data/monkey.mdl data/22.tex data/kita.tex data/brick_albedo.tex data/brick_ao.tex data/brick_normal.tex data/sky.tex data/bricks.mat data/plastic.mat 
	rm -f shadercompiler
	rmdir data
	rm -f c2
	rm -f convtexture
	rm -f convmodel
	rm -f convmaterial
	rm -f libqstd.a
	rm -f libcfg.a