forked from travisvroman/kohi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.tests.linux.mak
45 lines (34 loc) · 1.26 KB
/
Makefile.tests.linux.mak
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
BUILD_DIR := bin
OBJ_DIR := obj
ASSEMBLY := tests
EXTENSION :=
COMPILER_FLAGS := -g -MD -Werror=vla -fdeclspec -fPIC
INCLUDE_FLAGS := -Iengine/src -I$(VULKAN_SDK)\include
LINKER_FLAGS := -L./$(BUILD_DIR)/ -lengine -Wl,-rpath,.
DEFINES := -D_DEBUG -DKIMPORT
# Make does not offer a recursive wildcard function, so here's one:
#rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRC_FILES := $(shell find $(ASSEMBLY) -name *.c) # .c files
DIRECTORIES := $(shell find $(ASSEMBLY) -type d) # directories with .h files
OBJ_FILES := $(SRC_FILES:%=$(OBJ_DIR)/%.o) # compiled .o objects
all: scaffold compile link
.PHONY: scaffold
scaffold: # create build directory
@echo Scaffolding folder structure...
@mkdir -p $(addprefix $(OBJ_DIR)/,$(DIRECTORIES))
@echo Done.
.PHONY: link
link: scaffold $(OBJ_FILES) # link
@echo Linking $(ASSEMBLY)...
clang $(OBJ_FILES) -o $(BUILD_DIR)/$(ASSEMBLY)$(EXTENSION) $(LINKER_FLAGS)
.PHONY: compile
compile: #compile .c files
@echo Compiling...
.PHONY: clean
clean: # clean build directory
rm -rf $(BUILD_DIR)/$(ASSEMBLY)
rm -rf $(OBJ_DIR)/$(ASSEMBLY)
$(OBJ_DIR)/%.c.o: %.c # compile .c to .o object
@echo $<...
@clang $< $(COMPILER_FLAGS) -c -o $@ $(DEFINES) $(INCLUDE_FLAGS)
-include $(OBJ_FILES:.o=.d)