-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (143 loc) · 3.98 KB
/
Makefile
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell sh -c 'uname -s 2>/dev/null || echo not')
endif
CL := cl icl
ifneq (,$(findstring $(CC),$(CL)))
RM=del /q /f
endif
CSTD := $(CSTD)
ifndef $(CSTD)
CSTD=c89
endif
ifneq (,$(findstring $(CC),$(CL)))
CFLAGS=/W4 /sdl /D_CRT_SECURE_NO_WARNINGS
else
CFLAGS=-Wall -Wextra -g -std=$(CSTD)
endif
ifeq ($(detected_OS),Windows)
TEST_BOOLEAN_EXEC=test_boolean.exe
TEST_INTEGER_EXEC=test_integer.exe
TEST_IO_EXEC=test_cio.exe
TEST_MATH_EXEC=test_cmath.exe
TEST_STRING_EXEC=test_cstring.exe
TEST_TERM_COLOR_EXEC=
TEST_TIME_EXEC=test_ctime.exe
else
TEST_BOOLEAN_EXEC=test_boolean
TEST_INTEGER_EXEC=test_integer
TEST_IO_EXEC=test_cio
TEST_MATH_EXEC=test_cmath
TEST_STRING_EXEC=test_cstring
TEST_TERM_COLOR_EXEC=test_term_color
TEST_TIME_EXEC=test_ctime
endif
ifneq (,$(findstring $(CC),$(CL)))
TEST_BOOLEAN_OBJ=test_boolean.obj
TEST_INTEGER_OBJ=test_integer.obj
TEST_IO_OBJ=cio.obj test_cio.obj
TEST_MATH_OBJ=test_cmath.obj
TEST_STRING_OBJ=cstring.obj test_cstring.obj
TEST_TERM_COLOR_OBJ=test_term_color.obj
TEST_TIME_OBJ=clibs_time.obj test_ctime.obj
else
TEST_BOOLEAN_OBJ=test_boolean.o
TEST_INTEGER_OBJ=test_integer.o
TEST_IO_OBJ=cio.o test_cio.o
TEST_MATH_OBJ=test_cmath.o
TEST_STRING_OBJ=cstring.o test_cstring.o
TEST_TERM_COLOR_OBJ=test_term_color.o
TEST_TIME_OBJ=clibs_time.o test_ctime.o
endif
TEST_EXEC=$(TEST_BOOLEAN_EXEC) $(TEST_INTEGER_EXEC) $(TEST_IO_EXEC) \
$(TEST_MATH_EXEC) $(TEST_STRING_EXEC) $(TEST_TERM_COLOR_EXEC) \
$(TEST_TIME_EXEC)
.PHONY: all test clean
all: test
ifneq (,$(findstring $(CC),$(CL)))
$(MAKE) test
$(MAKE) clean
else
$(MAKE) test
$(MAKE) clean
$(MAKE) test CSTD=c99
$(MAKE) clean
$(MAKE) test CSTD=c11
$(MAKE) clean
endif
test: $(TEST_EXEC)
ifeq ($(detected_OS),Windows)
.\$(TEST_BOOLEAN_EXEC)
.\$(TEST_INTEGER_EXEC)
.\$(TEST_IO_EXEC)
.\$(TEST_MATH_EXEC)
.\$(TEST_STRING_EXEC)
echo "Skip term color testing"
.\$(TEST_TIME_EXEC)
else
./$(TEST_BOOLEAN_EXEC)
./$(TEST_INTEGER_EXEC)
./$(TEST_IO_EXEC)
./$(TEST_MATH_EXEC)
./$(TEST_STRING_EXEC)
./$(TEST_TERM_COLOR_EXEC)
./$(TEST_TIME_EXEC)
endif
$(TEST_BOOLEAN_EXEC): $(TEST_BOOLEAN_OBJ)
ifneq (,$(findstring $(CC),$(CL)))
$(CC) /Fe:$(TEST_BOOLEAN_EXEC) $(TEST_BOOLEAN_OBJ) $(CFLAGS)
else
$(CC) -o $(TEST_BOOLEAN_EXEC) $(TEST_BOOLEAN_OBJ) $(CFLAGS)
endif # cl.exe
$(TEST_INTEGER_EXEC): $(TEST_INTEGER_OBJ)
ifneq (,$(findstring $(CC),$(CL)))
$(CC) /Fe:$(TEST_INTEGER_EXEC) $(TEST_INTEGER_OBJ) $(CFLAGS)
else
$(CC) -o $(TEST_INTEGER_EXEC) $(TEST_INTEGER_OBJ) $(CFLAGS)
endif # cl.exe
$(TEST_IO_EXEC): $(TEST_IO_OBJ)
ifneq (,$(findstring $(CC),$(CL)))
$(CC) /Fe:$(TEST_IO_EXEC) $(TEST_IO_OBJ) $(CFLAGS)
else
$(CC) -o $(TEST_IO_EXEC) $(TEST_IO_OBJ) $(CFLAGS)
endif # cl.exe
$(TEST_MATH_EXEC): $(TEST_MATH_OBJ)
ifneq (,$(findstring $(CC),$(CL)))
$(CC) /Fe:$(TEST_MATH_EXEC) $(TEST_MATH_OBJ) $(CFLAGS)
else
$(CC) -o $(TEST_MATH_EXEC) $(TEST_MATH_OBJ) $(CFLAGS)
endif # cl.exe
$(TEST_STRING_EXEC): $(TEST_STRING_OBJ)
ifneq (,$(findstring $(CC),$(CL)))
$(CC) /Fe:$(TEST_STRING_EXEC) $(TEST_STRING_OBJ) $(CFLAGS)
else
$(CC) -o $(TEST_STRING_EXEC) $(TEST_STRING_OBJ) $(CFLAGS)
endif # cl.exe
$(TEST_TERM_COLOR_EXEC): $(TEST_TERM_COLOR_OBJ)
ifeq ($(detected_OS),Windows)
echo "Not supported"
else
$(CC) -o $(TEST_TERM_COLOR_EXEC) $(TEST_TERM_COLOR_OBJ) $(CFLAGS)
endif # Windows
$(TEST_TIME_EXEC): $(TEST_TIME_OBJ)
ifneq (,$(findstring $(CC),$(CL)))
$(CC) /Fe:$(TEST_TIME_EXEC) $(TEST_TIME_OBJ) $(CFLAGS)
else
$(CC) -o $(TEST_TIME_EXEC) $(TEST_TIME_OBJ) $(CFLAGS)
endif
test_integer.o:
ifeq ($(CSTD),c89)
$(CC) -std=c89 -o get_sizeof_data_type get_sizeof_data_type.c
./get_sizeof_data_type
endif # c89
$(CC) -c test_integer.c $(CFLAGS)
%.obj: %.c
$(CC) /c $< $(CFLAGS)
%.o: %.c
$(CC) -c $< $(CFLAGS)
clean:
$(RM) $(TEST_EXEC) $(TEST_BOOLEAN_OBJ) $(TEST_INTEGER_OBJ) \
$(TEST_IO_OBJ) $(TEST_MATH_OBJ) $(TEST_STRING_OBJ) \
$(TEST_TERM_COLOR_OBJ) $(TEST_TIME_OBJ) \
get_sizeof_data_type get_sizeof_data_type.exe _sizeof_data_type.h