-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (34 loc) · 773 Bytes
/
Makefile
File metadata and controls
45 lines (34 loc) · 773 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
# --- Config ---
CC := gcc
CSTD := -std=c11
WARN := -Wall -Wextra -Wpedantic
OPT := -O2
DBG := -g
INCS := -Iinclude
# --- Paths ---
SRC_DIR := src
BLD_DIR := build
BIN := $(BLD_DIR)/app
# --- Files ---
SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BLD_DIR)/%.o,$(SRCS))
# --- Flags ---
CFLAGS := $(CSTD) $(WARN) $(OPT) $(INCS)
LDFLAGS :=
# --- Default target ---
all: $(BIN)
# Link
$(BIN): $(OBJS)
@mkdir -p $(BLD_DIR)
$(CC) $(OBJS) -o $(BIN) $(LDFLAGS)
# Compile each .c -> .o
$(BLD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(BLD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
run: all
./$(BIN)
debug: CFLAGS := $(CSTD) $(WARN) -O0 $(DBG) $(INCS)
debug: clean all
clean:
rm -rf $(BLD_DIR)
.PHONY: all run debug clean