compiler = gcc tool_compiler = gcc linker = gcc cflags = -I./ -g -DDEBUG -Dplat_x11 -Dplat_x86 \ -Dplat_posix -Dallocation_default_alignment=8 \ -Wall -Wextra -pedantic -std=c90 lflags = -lX11 -lXi int_dir = intermediate data_dir = data target = 3de convmesh = convmesh convtexture = convtexture packassets = packassets pack = pack sources = \ 3de.c \ asset.c \ maths.c \ memory.c \ plat.c \ player.c \ rect.c \ render.c \ standard.c objects = $(sources:%.c=%.o) mesh_sources = \ $(int_dir)/monkey.obj \ $(int_dir)/cube.obj texture_sources = \ $(int_dir)/gun.bmp \ meshes = $(mesh_sources:$(int_dir)/%.obj=$(data_dir)/%.msh) textures = $(texture_sources:$(int_dir)/%.bmp=$(data_dir)/%.bc1) all: $(target) $(pack) $(objects): %.o : %.c $(compiler) -MMD -MF $(basename $@).d $(cflags) -o $@ -c $< $(target): $(objects) $(linker) $(objects) -o $@ $(lflags) $(meshes): $(data_dir)/%.msh : $(int_dir)/%.obj | $(convmesh) $(data_dir) ./$(convmesh) $< $@ $(textures): $(data_dir)/%.bc1 : $(int_dir)/%.bmp | $(convtexture) $(data_dir) ./$(convtexture) $< $@ $(convmesh): convmesh.c $(tool_compiler) $(cflags) -o $@ $< $(convtexture): convtexture.c $(tool_compiler) $(cflags) -o $@ $< -lm $(packassets): packassets.c $(tool_compiler) packassets.c $(cflags) -o $@ $(pack): $(packassets) $(meshes) $(textures) ./$(packassets) \ $(data_dir) \ $(notdir $(meshes)) \ $(notdir $(textures)) $(data_dir): mkdir -p $(data_dir) clean: rm -f $(packassets) rm -f $(convmesh) rm -f $(convtexture) rm -rf data rm *.d rm *.o rm $(target) -include $(sources:%.c=%.d)