-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile_tests
More file actions
49 lines (34 loc) · 1009 Bytes
/
makefile_tests
File metadata and controls
49 lines (34 loc) · 1009 Bytes
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
# Minimal Makefile for pico-CAS project
# Compiler and flags
CC = gcc
CFLAGS = -std=c99 -Wall -Wextra -g
INCLUDES = -I./src -I./tests
# Source files
SRC_DIR = src
TEST_DIR = tests
SRCS = $(SRC_DIR)/expr.c $(SRC_DIR)/part.c $(SRC_DIR)/print.c $(SRC_DIR)/parse.c $(SRC_DIR)/repl.c
OBJS = $(SRCS:.c=.o)
# Targets
all: expr_tests parse_tests picocas
# Pattern rule for object files
$(SRC_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/%.h
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Test executable
expr_tests: $(TEST_DIR)/test_expr.c $(TEST_DIR)/test_part.c $(SRC_DIR)/expr.o $(SRC_DIR)/part.o $(SRC_DIR)/print.o
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@
parse_tests: tests/test_parse.c src/expr.o src/print.o src/parse.o
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@
LDFLAGS = -lreadline
picocas: $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c $<
test_parse: parse_tests
./parse_tests
# Run tests
test: expr_tests
./expr_tests
# Clean
clean:
rm -f $(OBJS) expr_tests
.PHONY: all test clean