ifndef config config=debug_gnu64 endif .PHONY: all clean compiler = gcc tool_compiler = gcc linker = gcc includes = -I./ cflags = $(includes) $(conf_cflags) \ -Wall -Wextra -pedantic -std=c90 lflags = $(libs) $(conf_lflags) target = 1bitjam int_dir = intermediate data_dir = data convimg = convimg convanim = convanim packassets = packassets pack = pack.h ifeq ($(config), debug_gnu64) compiler = gcc tool_compiler = gcc linker = gcc conf_cflags = -DDEBUG -Dplat_x11 -Dplat_x86 \ -Dplat_posix -Dallocation_default_alignment=8 \ -Dplat_pulse \ -g libs = -lX11 -lXi -lpulse -lpulse-simple -lpthread -lm endif ifeq ($(config), release_gnu64) compiler = gcc tool_compiler = gcc linker = gcc conf_cflags = -DNDEBUG -Dplat_x11 -Dplat_x86 \ -Dplat_posix -Dallocation_default_alignment=8 \ -Dplat_pulse \ -s -O3 -m64 conf_lflags = -m64 -s libs = -lX11 -lXi -lpulse -lpulse-simple -lpthread -lm endif sources = \ 1bitjam.c \ animation.c \ asset.c \ deathzone.c \ effect.c \ enemy.c \ game.c \ hud.c \ map.c \ maths.c \ memory.c \ particle.c \ physics.c \ plat.c \ player.c \ random.c \ rect.c \ render.c \ world.c \ image_sources = \ $(int_dir)/arms.bmp \ $(int_dir)/guy.bmp \ $(int_dir)/hud.bmp \ $(int_dir)/map.bmp \ $(int_dir)/mask.bmp \ $(int_dir)/npc.bmp \ $(int_dir)/rooms.bmp \ anim_sources = \ $(int_dir)/demon_fly_left.anm \ $(int_dir)/demon_fly_right.anm \ $(int_dir)/demon_idle_left.anm \ $(int_dir)/demon_idle_right.anm \ $(int_dir)/demon_jump_left.anm \ $(int_dir)/demon_jump_right.anm \ $(int_dir)/demon_walk_left.anm \ $(int_dir)/demon_walk_right.anm \ $(int_dir)/fade_in.anm \ $(int_dir)/fade_out.anm \ $(int_dir)/guy_fall_left.anm \ $(int_dir)/guy_fall_right.anm \ $(int_dir)/guy_idle_left.anm \ $(int_dir)/guy_idle_right.anm \ $(int_dir)/guy_jump_left.anm \ $(int_dir)/guy_jump_right.anm \ $(int_dir)/guy_run_left.anm \ $(int_dir)/guy_run_right.anm \ $(int_dir)/guy_slash_left.anm \ $(int_dir)/guy_slash_right.anm \ $(int_dir)/slash_left.anm \ $(int_dir)/slash_right.anm \ $(int_dir)/smol_slash_left.anm \ $(int_dir)/smol_slash_right.anm \ objects = $(sources:%.c=%.o) images = $(image_sources:$(int_dir)/%.bmp=$(data_dir)/%.img) animations = $(anim_sources:$(int_dir)/%.anm=$(data_dir)/%.anm) all: $(target) $(pack) $(objects): %.o : %.c | $(pack) $(compiler) -MMD -MF $(basename $@).d $(cflags) -o $@ -c $< $(images): $(data_dir)/%.img : $(int_dir)/%.bmp | $(convimg) $(data_dir) ./$(convimg) $< $@ $(animations): $(data_dir)/%.anm : $(int_dir)/%.anm | $(convanim) $(data_dir) ./$(convanim) $< $@ $(pack): $(packassets) $(images) $(animations) ./$(packassets) \ $(pack) \ $(data_dir) \ $(notdir $(animations)) \ $(notdir $(images)) $(convimg): convimg.c $(tool_compiler) convimg.c $(cflags) -o $@ $(convanim): convanim.c $(tool_compiler) convanim.c $(cflags) -o $@ $(packassets): packassets.c $(tool_compiler) packassets.c $(cflags) -o $@ $(target): $(objects) $(linker) $(objects) -o $@ $(lflags) $(data_dir): mkdir -p $(data_dir) clean: rm *.d rm *.o rm $(pack) rm -r $(data_dir) rm $(target) rm $(convimg) rm $(convanim) -include $(sources:%.c=%.d)