-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
34 lines (24 loc) · 803 Bytes
/
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
CC ?= gcc
CFLAGS += -g -Wall -Wextra -pedantic -std=c99
# Compile all c files to executables
SRC_DIR = common_user_error logical memory overflow undefined_behavior
SAFE_SRCS = $(foreach dir, $(SRC_DIR), $(wildcard $(dir)/*_safe.c))
UNSAFE_SRCS = $(foreach dir, $(SRC_DIR), $(wildcard $(dir)/*_unsafe.c))
BUILD_DIR ?= .
SAFE_PROGS = $(addprefix $(BUILD_DIR)/, $(patsubst %.c, %, $(SAFE_SRCS)))
UNSAFE_PROGS = $(addprefix $(BUILD_DIR)/, $(patsubst %.c, %, $(UNSAFE_SRCS)))
PROGS = $(SAFE_PROGS) $(UNSAFE_PROGS)
.PHONY: all
all: $(PROGS)
%: %.c
$(CC) $(CFLAGS) $< -o $@
.PHONY: safe
safe: $(SAFE_PROGS)
for p in $^; do echo "Running $$p"; ./$$p; done
.PHONY: unsafe
unsafe: $(UNSAFE_PROGS)
for p in $^; do echo "Running $$p"; ./$$p; done
.PHONY: clean
clean:
rm -f $(PROGS)
rm -rf **/*.dSYM