-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (29 loc) · 899 Bytes
/
Copy pathMakefile
File metadata and controls
40 lines (29 loc) · 899 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
# LDPC (1023, 781) simulator
CC ?= cc
CFLAGS ?= -O2 -std=c11 -Wall -Wextra
LDFLAGS ?= -lm
SRC_DIR := src
TEST_DIR := tests
BIN := ldpc_sim
SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(SRCS:.c=.o)
LIB_OBJS := $(filter-out $(SRC_DIR)/main.o,$(OBJS)) # everything but main()
TEST_BIN := $(TEST_DIR)/selftest
.PHONY: all run test clean
all: $(BIN)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(SRC_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
# Build and run with the default configuration (config/sim.txt).
run: $(BIN)
./$(BIN) config/sim.txt
# Build and run the correctness self-test.
test: $(TEST_BIN)
./$(TEST_BIN)
$(TEST_BIN): $(TEST_DIR)/selftest.o $(LIB_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(TEST_DIR)/selftest.o: $(TEST_DIR)/selftest.c
$(CC) $(CFLAGS) -I$(SRC_DIR) -c $< -o $@
clean:
rm -f $(OBJS) $(BIN) $(TEST_DIR)/*.o $(TEST_BIN)