-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (63 loc) · 1.81 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
# Compiler and flags
CC = gcc
WARNINGS = -Wall -Werror
OPTFLAGS = -O0 -g
STDFLAGS = -std=gnu99
override CFLAGS := $(WARNINGS) $(STDFLAGS) $(OPTFLAGS) $(CFLAGS) -I.
# Debug support
DEBUG=0
ifeq ($(DEBUG),1)
override CFLAGS += -fsanitize=undefined
override LDFLAGS += -fsanitize=undefined -fsanitize=leak
endif
# Directories
TESTDIR=tests
# Test configuration
test_files=test_busy_threads test_many_threads \
test_random_threads test_new_threads \
test_zombie_threads test_wait_thread test_sync \
test_mutex test_mutex_2 test_mutex_3 \
test_barrier test_barrier_2 test_barrier_3
custom_tests= test_one_thread test_custom_schedule \
test_early_exit test_mutex test_barrier
# For cleanup, we need all test files regardless of PREEMPT setting
all_test_files=$(test_files) $(custom_tests)
all_test_binaries := $(addprefix $(TESTDIR)/,$(all_test_files))
# Preemption configuration
PREEMPT=1
ifeq ($(PREEMPT),0)
override CFLAGS += -DPREEMPT=0
test_files=$(custom_tests)
endif
# Library configuration
TSTMYPTHREADS=1
ifeq ($(TSTMYPTHREADS),1)
mythread=threads.o
else
mythread=
override LDFLAGS += -pthread
endif
# Test building rules
test_files := $(addprefix $(TESTDIR)/,$(test_files))
objects := $(addsuffix .o,$(test_files))
# Targets
.PHONY: all build clean test version
all: test
build: threads.o $(test_files)
# Run the test programs
test: $(test_files)
@echo "Running tests..."
@/bin/bash run_tests.sh $(test_files)
version:
@echo "Threading Library Build System"
@echo "CC: $(shell $(CC) --version | head -n 1)"
@echo "CFLAGS: $(CFLAGS)"
clean:
rm -f *.o *.d *~ $(TESTDIR)/*.o $(TESTDIR)/*.d $(all_test_binaries)
# Automatic dependency generation
%.d: %.c
@$(CC) $(CFLAGS) -MM -MT '$*.o $@' $< > $@
-include $(objects:.o=.d)
-include threads.d
threads.o: threads.c ec440threads.h
$(test_files): %: %.o $(mythread)