-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
57 lines (40 loc) · 1.24 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
.PHONY : examples test
CC = gcc
CFLAGS = -Wall -fPIC -g
3S_LIBS = src/core.c src/llist.c src/stack.c src/queue.c
3S_OBJS = core.o llist.o stack.o queue.o
TINYTEST_PATH = tinytest
TINYTEST_OBJ = $(TINYTEST_PATH)/tinytest.o
EXAMPLES_BIN = example01 example02 example03
default: examples
examples: $(EXAMPLES_BIN)
example01.o: examples/example01.c
$(CC) $(CFLAGS) $^ -c
example01: $(3S_OBJS) example01.o
$(CC) $(CFLAGS) $^ -o $@
@echo Execute using ./$@
example02.o: examples/example02.c
$(CC) $(CFLAGS) $^ -c
example02: $(3S_OBJS) example02.o
$(CC) $(CFLAGS) $^ -o $@
@echo Execute using ./$@
example03.o: examples/example03.c
$(CC) $(CFLAGS) $^ -c
example03: $(3S_OBJS) example03.o
$(CC) $(CFLAGS) $^ -o $@
@echo Execute using ./$@
$(3S_OBJS): $(3S_LIBS)
$(CC) $(CFLAGS) $^ -c
$(TINYTEST_OBJ): $(TINYTEST_PATH)
cd $(TINYTEST_PATH) && $(MAKE)
test: test_generic_values
test_generic_values: $(TINYTEST_OBJ) $(3S_OBJS) tests/test_generic_values.c
-@$(CC) $(CFLAGS) tests/test_generic_values.c -c
-@$(CC) $(CFLAGS) $(3S_OBJS) $(TINYTEST_OBJ) test_generic_values.o -o $@
-@echo
-@echo "Running tests for 'test_generic_values'"
-@echo -n "|__ Result: " && ./$@
-@rm $@
clean:
-cd &(TINYTEST_PATH) && $(MAKE) clean
-rm *.o $(EXAMPLES_BIN)