-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
62 lines (42 loc) · 1 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
TARGETS=test_pc
ifdef D
DEBUG=-g
OPT=
else
DEBUG=
OPT=-Ofast
endif
ifdef P
PROFILE=-pg -no-pie # for bug in gprof.
endif
LOC_INCLUDE=include
LOC_SRC=src
LOC_TEST=test
OBJDIR=obj
CC = gcc -std=gnu11
LD= gcc -std=gnu11
CXXFLAGS = -Wall $(DEBUG) $(PROFILE) $(OPT) $(ARCH) -m64 -I. -Iinclude
LDFLAGS = $(DEBUG) $(PROFILE) $(OPT) -lpthread
#
# declaration of dependencies
#
all: $(TARGETS)
# dependencies between programs and .o files
test_pc: $(OBJDIR)/test_partitioned_counter.o \
$(OBJDIR)/partitioned_counter.o
# dependencies between .o files and .h files
# dependencies between .o files and .cc (or .c) files
$(OBJDIR)/partitioned_counter.o: $(LOC_INCLUDE)/partitioned_counter.h
#
# generic build rules
#
$(TARGETS):
$(LD) $^ -o $@ $(LDFLAGS)
$(OBJDIR)/%.o: $(LOC_SRC)/%.c | $(OBJDIR)
$(CC) $(CXXFLAGS) $(INCLUDE) $< -c -o $@
$(OBJDIR)/%.o: $(LOC_TEST)/%.c | $(OBJDIR)
$(CC) $(CXXFLAGS) $(INCLUDE) $< -c -o $@
$(OBJDIR):
@mkdir -p $(OBJDIR)
clean:
rm -rf $(OBJDIR) $(TARGETS) core