-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.mk
88 lines (68 loc) · 1.85 KB
/
common.mk
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.PHONY: all clean test runtest clean_test flags builddirs
# paths
SRCPATH=src
TESTPATH=test
TESTBIN=test/bin
OBJPATH=obj
BINPATH=bin
# objects to be included in the library
OBJ=SDL_shader.o \
opengl/SDL_GL_shader.o \
d3d/SDL_D3D_shader.o \
opengles2/SDL_GLES2_shader.o
#d3d11/SDL_D3D11_shader.o \
DIRS=opengl/ \
d3d \
d3d11 \
opengles2 \
test
# objects needed for the test cases
TEST_OBJ=test/SDL_test_font.o
TEST_BIN=$(TEST_CASES:%=$(TESTBIN)/test_%$(EXE_EXT))
TEST_LDFLAGS=-L. -lSDL2_shader
INCLUDE=
OBJECTS=$(OBJ:%=$(OBJPATH)/%)
TEST_OBJECTS=$(TEST_OBJ:%=$(OBJPATH)/%)
BUILDDIRS=$(DIRS:%=$(OBJPATH)/%)
ifdef NO_COLOR
CLR=
GREEN=
CYAN=
RED=
YELLOW=
else
CLR="\x1b[0m"
GREEN="\x1b[32;01m"
CYAN="\x1b[36;01m"
RED="\x1b[31;01m"
YELLOW="\x1b[33;01m"
endif
all: libSDL2_shader.a flags
libSDL2_shader.a: builddirs $(OBJECTS)
$(AR) rcs libSDL2_shader.a $(OBJECTS)
flags:
@echo -e $(YELLOW)CFLAGS = $(CFLAGS)$(CLR)
@echo -e $(YELLOW)CPPFLAGS = $(CPPFLAGS)$(CLR)
builddirs:
@$(MKDIR_LIST) $(BUILDDIRS)
test: libSDL2_shader.a $(TEST_OBJECTS) runtest
runtest: $(TEST_BIN)
@$(foreach TEST_CASE,$(TEST_CASES), \
echo -e $(GREEN)"### Testing: $(TEST_CASE) ###"$(CLR); \
cd $(TESTBIN); \
$(RUN) ./test_$(TEST_CASE)$(EXE_EXT); \
cd ../.. ;)
$(OBJPATH)/%.o : $(SRCPATH)/%.cpp
@echo "$(GPP) (CPPFLAGS) -c $< -o $@"
@$(GPP) $(CPPFLAGS) $(INCLUDE) -c $< -o $@
$(OBJPATH)/%.o : $(SRCPATH)/%.c
@echo "$(GCC) (CFLAGS) -c $< -o $@"
@$(GCC) $(CFLAGS) $(INCLUDE) -c $< -o $@
$(TESTBIN)/test_%$(EXE_EXT) : $(TESTPATH)/%/main.c libSDL2_shader.a
@echo "$(GCC) (CFLAGS) (OBJECTS) $< -o $@"
@$(GCC) $(CFLAGS) $(INCLUDE) -I$(SRCPATH) $(TEST_OBJECTS) \
$< $(LDFLAGS) $(TEST_LDFLAGS) -o $@
clean_test:
$(RM) $(TEST_BIN)
clean: clean_test
$(RM) $(OBJECTS) $(MAIN_OBJECT) $(COMPILE_OBJECT) $(TEST_OBJECTS)