- add release build - control framerate - fix bug that caused camera to shake - enable double-buffering and VSync
42 lines
890 B
Makefile
Executable File
42 lines
890 B
Makefile
Executable File
INC = include
|
|
OBJ = obj
|
|
SRC = src
|
|
EXE = Game
|
|
REL = Release
|
|
|
|
CC = gcc
|
|
CFLAGS = -w -ggdb -I$(INC)
|
|
LIBS = -lGLEW -lGLU -lGL -lSDL2 -lcglm -lz -lm
|
|
RELFLAGS = -O3 -s
|
|
|
|
OBJFILES := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(shell find $(SRC) -name '*.c'))
|
|
OBJDIRS := $(patsubst $(SRC)%, $(OBJ)%, $(shell find $(SRC) -type d))
|
|
CLEANDIRS := $(addsuffix /.clean, $(OBJDIRS));
|
|
|
|
# Explicit targets
|
|
.PHONY: all release clean
|
|
.DEFAULT_GOAL := all
|
|
|
|
# Build executable
|
|
all: $(EXE)
|
|
$(EXE): $(OBJFILES) | $(OBJDIRS)
|
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
|
|
|
# Compile object files
|
|
$(OBJ)/%.o: $(SRC)/%.c | $(OBJDIRS)
|
|
$(CC) -c -o $@ $(SRC)/$*.c $(CFLAGS)
|
|
|
|
# Create obj directory tree if it doesn't exist
|
|
$(OBJDIRS):
|
|
mkdir -p $@
|
|
|
|
release: $(REL)
|
|
$(REL): $(OBJFILES) | $(OBJDIRS)
|
|
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) $(RELFLAGS)
|
|
|
|
# Delete previously built files
|
|
clean: $(CLEANDIRS)
|
|
rm -f $(EXE) $(REL)
|
|
%.clean:
|
|
rm -f $**.o
|