-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (35 loc) · 1.09 KB
/
Copy pathMakefile
File metadata and controls
45 lines (35 loc) · 1.09 KB
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
CC := gcc
SRC_DIR := src
CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -I $(SRC_DIR)/
BUILD_DIR := build
TARGET := myapp
BIN_TARGET := $(BUILD_DIR)/$(TARGET)
TEST_OUTPUT := output.txt
# ---------- START FILES ----------
SRCS := \
# ---------- END FILES ----------
# ---------- START OBJECT FILES ----------
OBJS := \
# ---------- END OBJECT FILES ----------
all: $(BIN_TARGET)
$(BIN_TARGET): $(OBJS)
@mkdir -p $(dir $@)
@echo "=== Linking $@ START at $$(date +'%T') ==="
@start_time=$$(date +%s); \
$(CC) $(CFLAGS) $^ -o $@; \
end_time=$$(date +%s); \
echo "=== Linking $@ END at $$(date +'%T'), duration: $$((end_time - start_time)) seconds ==="
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
@echo "+++ Compiling $< START at $$(date +'%T') +++"
@start_time=$$(date +%s); \
$(CC) $(CFLAGS) -c $< -o $@; \
end_time=$$(date +%s); \
echo "+++ Compiling $< END at $$(date +'%T'), duration: $$((end_time - start_time)) seconds +++"
clean:
rm -rf $(BUILD_DIR)
.PHONY: test
test: $(BIN_TARGET)
@echo "Running test with input file"
@./$(BIN_TARGET) --help > $(TEST_OUTPUT)
.PHONY: all clean