|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com>
- # Released under the terms of the MIT License. See LICENSE for details.
-
- PROGRAM = crater
- SOURCES = src
- BUILD = build
- DEVEXT = -dev
-
- CC = clang
- FLAGS = -O2 -Wall -Wextra -pedantic -std=c11
- CFLAGS = $(shell sdl2-config --cflags)
- LIBS = $(shell sdl2-config --libs)
- MKDIR = mkdir -p
- RM = rm -rf
-
- MODE = release
- BNRY = $(PROGRAM)
- SRCS = $(foreach d,.,$(wildcard *.c)) $(foreach d,$(SOURCES),$(wildcard $(addprefix $(d)/*,.c)))
- OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS)))
- DEPS = $(OBJS:%.o=%.d)
- DIRS = $(sort $(dir $(OBJS)))
-
- ifdef DEBUG
- BNRY := $(BNRY)$(DEVEXT)
- FLAGS += -g -DDEBUG_MODE
- MODE = debug
- endif
-
- .PHONY: all clean
-
- all: $(BNRY)
-
- clean:
- $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT)
-
- $(DIRS):
- $(MKDIR) $@
-
- $(BNRY): $(OBJS)
- $(CC) $(FLAGS) $(LIBS) $(OBJS) -o $@
-
- $(OBJS): | $(DIRS)
-
- $(BUILD)/$(MODE)/%.o: %.c
- $(CC) $(FLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
-
- -include $(DEPS)
|