-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (39 loc) · 1.19 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
# MacWarmer
OBJS_DIR = .objs
# define all the student executables
EXES = warmer
# list object file dependencies for each
OBJS=$(EXES).o smc.o pid.o pid_c.o monitor.o calculatepi.o
# set up compiler
CC = cc
WARNINGS = -Wall -Wextra -Werror -Wno-error=unused-parameter
CFLAGS_DEBUG = $(INCLUDES) -O0 $(WARNINGS) -g -std=c99 -c -MMD -MP -D_GNU_SOURCE -DDEBUG
CFLAGS_RELEASE = $(INCLUDES) -O2 $(WARNINGS) -g -std=c99 -c -MMD -MP -D_GNU_SOURCE
# set up linker
LD = cc
LDFLAGS = -pthread -fPIC -framework IOKit
.PHONY: all
all: clean release
# build types
# run clean before building debug so that all of the release executables
# disappear
.PHONY: debug
.PHONY: release
release: $(EXES)
# include dependencies
-include $(OBJS_DIR)/*.d
$(OBJS_DIR):
@mkdir -p $(OBJS_DIR)
# patterns to create objects
# keep the debug and release postfix for object files so that we can always
# separate them correctly
$(OBJS_DIR)/%-release.o: %.c | $(OBJS_DIR)
$(CC) $(CFLAGS_RELEASE) $< -o $@
# exes
# you will need a triple of exe and exe-debug and exe-tsan for each exe (other
# than provided exes)
$(EXES): $(OBJS:%.o=$(OBJS_DIR)/%-release.o)
$(LD) $^ $(LDFLAGS) -o $@
.PHONY: clean
clean:
-rm -rf .objs $(EXES)