Skip to content

Instantly share code, notes, and snippets.

@hikiko
Last active April 21, 2019 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hikiko/eac31eb9b02567d6e75afecacf4df0cb to your computer and use it in GitHub Desktop.
Save hikiko/eac31eb9b02567d6e75afecacf4df0cb to your computer and use it in GitHub Desktop.
name it MakefileSimple, put it in VKDF_HOME/demos/sponza
src = $(wildcard *.cpp)
obj = $(src:.cpp=.o)
dep = $(obj.o=.d)
bin = sponza
vkdf_root = ../..
spv = $(patsubst %.input,%.spv,$(wildcard *.input)) \
$(patsubst %.frag,%.frag.spv,$(wildcard *.frag)) \
$(patsubst %.vert,%.vert.spv,$(wildcard *.vert))
dbg = -g
opt = -O0
inc = -I$(vkdf_root)/framework
def = -DVKDF_PLATFORM_SDL
CXX = g++
CXXFLAGS = -Wall $(dbg) $(opt) $(inc) $(def) `pkg-config --cflags glm glib-2.0 sdl2`
LDFLAGS = -L$(vkdf_root) -lvkdf -lvulkan -lassimp -lSDL2_image \
`pkg-config --libs glm glib-2.0 sdl2`
GLSLANG = glslangValidator
FIXUP_GLSL := python $(vkdf_root)/scripts/fixup-glsl.py
$(bin): $(obj) $(vkdf_root)/libvkdf.so $(spv)
$(CXX) -o $@ $(obj) -Wl,-rpath=$(vkdf_root) $(LDFLAGS)
%.frag: %.frag.input
$(FIXUP_GLSL) $< $@
%.vert: %.vert.input
$(FIXUP_GLSL) $< $@
%.vert.spv: %.vert
$(GLSLANG) -V $< -o $@
%.frag.spv: %.frag
$(GLSLANG) -V $< -o $@
-include $(dep)
%.d: %.cpp
@echo "Generating depfile: $@"
@$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
.PHONY: clean
clean:
rm -f $(obj) $(bin) $(dep) *.spv
@hikiko
Copy link
Author

hikiko commented Apr 21, 2019

you either run make -f MakefileSimple sponza in VKDF_HOME or cd to demos/sponza and run make -f MakefileSimple (make sure vkdf is up to date and you have a VKDF_HOME/libvkdf.so)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment