-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
56 lines (42 loc) · 1.48 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
# Set directories up
SRC_DIR := ./src
BUILD_DIR := ./bin
INCLUDE_DIR := ./include
TESTS_DIR := ./tests
# Source files and object files
SRCS = $(wildcard $(SRC_DIR)/*.c)
TEST = $(wildcard $(TESTS_DIR)/*.c)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
HEADERS = $(wildcard include/*.h)
# Compiler flags
CC=gcc
CFLAGS=-g -Wall -lcriterion -I/opt/homebrew/include/ -I../common/ -I$(INCLUDE_DIR)
# Target executable name
TARGET = unit_tests
# Build all
all: clean build_debug unit_tests
./unit_tests -j1 --timeout 10
# Rule to build the executable
unit_tests: clean unit_tests.c bin $(OBJS) $(TEST)
$(CC) $(CFLAGS) unit_tests.c -o $@ $(OBJS)
# Rule to build the debug executable
build_debug: clean debug.c bin $(OBJS) $(TEST)
$(CC) $(CFLAGS) debug.c -o debug $(OBJS)
# Rule to build the debug executable
debug: clean build_debug
gdb ./debug
# Rule to compile .c files into .o files
bin/%.o: src/%.c $(HEADERS) $(TEST)
$(CC) $(CFLAGS) -c $< -o $@
# Rule to run the grader
grade:
python ../../helpers/grader.py
# Clean rule to remove object files and the executable
clean:
rm -rf bin unit_tests debug
check:
clang-tidy -checks=bugprone-*,readability-*,-readability-identifier-length,-readability-else-after-return,-bugprone-easily-swappable-parameters,-readability-redundant-control-flow,-readability-non-const-parameter -warnings-as-errors=bugprone-*,readability-* src/student_code.c -- -I$(INCLUDE_DIR) -I../common/
bin:
mkdir -p bin
.PHONY: all clean grade build_debug
.INTERMEDIATE: .build_debug