commit f28cc747452bff742306cd9e53d27249fbd0838e parent 29617b17aad13ee63c9497367c388f1b46fb3a3d Author: Michael Savage <mikejsavage@gmail.com> Date: Sat Jan 30 14:29:46 +0000 Comment Makefile Diffstat:
Makefile | | | 15 | +++++++++++++-- |
diff --git a/Makefile b/Makefile @@ -4,25 +4,28 @@ STBS := stb_truetype stb_image stb_image_write stb_perlin all: $(BINS) $(STB_OBJS) $(MODULES) +# List binary dependencies medfall: main.o gl.o memory_arena.o pp: pp.o stb_image.o stb_image_write.o sound: linux_audio.o wave.o audio.o memory_arena.o +# List module dependencies bsp.so: bsp.o bsp_renderer.o hm.so: hm.o heightmap.o terrain_manager.o stb_perlin.o btt.so: btt.o heightmap.o gpubtt.o skybox.o audio.so: test_audio.o audio.o wave.o linux_audio.o sm.so: shadow_map.o +# Common dependencies COMMON_OBJS := memory_arena.o work_queue.o immediate.o benchmark.o stb_truetype.o stb_image.o +# Compiler flags WARNINGS := -Wall -Wextra -Wno-unused-parameter -Wno-unused-function CXXFLAGS += -std=c++11 -O2 \ -msse2 -ggdb3 -fno-omit-frame-pointer $(WARNINGS) -DGL_GLEXT_PROTOTYPES -DGLFW_INCLUDE_NONE -ffreestanding -fno-exceptions LDFLAGS += -lm -pthread -STB_OBJS := $(addsuffix .o,$(STBS)) -STB_CCS := $(addsuffix .cc,$(STBS)) +# The STB libraries need you to define STB_*_IMPLEMENTATION to get the actual code STB_CXXFLAGS := -DSTB_IMAGE_IMPLEMENTATION -DSTB_IMAGE_WRITE_IMPLEMENTATION -DSTB_PERLIN_IMPLEMENTATION -DSTB_TRUETYPE_IMPLEMENTATION # OS detection @@ -33,18 +36,26 @@ else LDFLAGS += -framework OpenGL -lglfw3 endif +# Create the binaries $(BINS): %: $(CXX) -o $@ $^ $(LDFLAGS) +# Create stb_*.cc and then stb_*.o +STB_OBJS := $(addsuffix .o,$(STBS)) +STB_CCS := $(addsuffix .cc,$(STBS)) + $(STB_CCS): %.cc: %.h cp $^ $*.cc $(STB_OBJS): %.o: %.cc $(CXX) -c -o $@ $*.cc $(CXXFLAGS) $(STB_CXXFLAGS) +# Build the game modules $(MODULES): %.so: $(COMMON_OBJS) $(CXX) -o $@ $^ $(LDFLAGS) -shared +# Build *.o from *.cc +# The -M* stuff is for generating dependency lists %.o: %.cc $(CXX) -c -o $@ $< -MMD -MP -MF .deps/$*.d $(CXXFLAGS)