-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (36 loc) · 1.03 KB
/
Makefile
File metadata and controls
49 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CC := g++
OS := $(shell uname)
ifeq ($(OS),Darwin)
LDFLAGS := -llua
else
LDFLAGS := -lrt -llua
endif
CFLAGS := -g
MODULES := src/Core/Camera src/Core/Math src/Core/Basic src/Core/Graphics src/Core/Util src/Core/State src/Core/Scripting src/Core/Controller src/Core/UI
SRC_DIR := $(addprefix ,$(MODULES))
BUILD_DIR := $(addprefix build/,$(MODULES))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
OBJ := $(patsubst %.cpp,build/%.o,$(SRC))
ifeq ($(OS),Darwin)
INCLUDES := -Isrc/ -Ilib/lua-5.2.3/src -Wno-deprecated-declarations
else
INCLUDES := -Isrc/ -Ilib/lua-5.2.3/src
endif
OUT := libcashew.a
vpath %.cpp $(SRC_DIR)
define make-goal
$1/%.o: %.cpp
$(CC) $(CFLAGS) $(INCLUDES) -c $$< -o $$@
endef
.PHONY: all checkdirs clean depend
all: checkdirs $(OUT)
$(OUT): $(OBJ)
ar rcs $(OUT) $(OBJ)
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
@mkdir -p $@
clean:
@rm -rf $(BUILD_DIR)
depend:
@makedepend -pbuild/ -- $(CFLAGS) -- $(SRC)
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))