Last active
April 21, 2019 20:51
-
-
Save hikiko/d848614018de5f12d02fb3bf7a65c25f to your computer and use it in GitHub Desktop.
name it MakefileSimple put it in VKDF_HOME, builds the lib and the data/spirv shaders, generates framework/config.h To run it see the comments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src = $(filter-out %-sdl.cpp %-glfw.cpp, $(wildcard framework/*.cpp)) | |
obj = $(src:.cpp=.o) | |
dep = $(obj:.o=.d) | |
lib_so = libvkdf.so | |
spv = $(patsubst %.input,%.spv,$(wildcard data/spirv/*.input)) \ | |
$(patsubst %.frag,%.frag.spv,$(wildcard data/spirv/*.frag)) \ | |
$(patsubst %.vert,%.vert.spv,$(wildcard data/spirv/*.vert)) | |
dbg = -g | |
opt = -O0 | |
inc = -Iframework | |
def = -DVKDF_PLATFORM_SDL -DVKDF_DATA_DIR=\"$(shell pwd)/data/\" | |
config = framework/config.h | |
ifeq ($(wildcard $(config)),) | |
$(file >$(config),$^) | |
endif | |
unused = -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable | |
CXX = g++ | |
CXXFLAGS = -Wall $(unused) $(dbg) $(opt) $(inc) $(def) \ | |
-Wextra `pkg-config --cflags glm glib-2.0 sdl2` -fPIC | |
LDFLAGS = -lvulkan -lassimp -lSDL2_image \ | |
`pkg-config --libs glm glib-2.0 sdl2` | |
GLSLANG = glslangValidator | |
FIXUP_GLSL := python $(shell pwd)/scripts/fixup-glsl.py | |
$(lib_so): $(obj) $(spv) | |
$(CXX) -o $@ -shared $(obj) $(LDFLAGS) | |
%.frag: %.frag.input | |
cd $(dir $<) && $(FIXUP_GLSL) $(notdir $<) $(notdir $@) | |
%.vert: %.vert.input | |
cd $(dir $<) && $(FIXUP_GLSL) $(notdir $<) $(notdir $@) | |
%.vert.spv: %.vert | |
$(GLSLANG) -V $< -o $@ | |
%.frag.spv: %.frag | |
$(GLSLANG) -V $< -o $@ | |
-include $(dep) | |
# to create dependency files to rebuild when the included .h are modified | |
%.d: %.cpp | |
@echo "Generating depfile: $@" | |
@$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@ | |
.PHONY: clean | |
clean: | |
rm -f $(obj) $(lib_so) $(dep) $(spv) $(config) | |
.PHONY: sponza | |
sponza: | |
$(MAKE) -f MakefileSimple -C demos/sponza |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In VKDF_HOME:
make -f MakefileSimple
builds vkdf and shaders and generates config.hmake -f MakefileSimple sponza
builds sponza