-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (50 loc) · 1.14 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
57
58
59
60
61
62
63
64
65
66
# Compiler settings
CC = gcc
CFLAGS = -Wall -Wextra -g3 -std=c99 -O0 -I$(INC_DIR) -MP -MD
RELEASE_CFLAGS = -s -fomit-frame-pointer -fdata-sections -ffunction-sections -DNDEBUG -std=c99 -O2 -I$(INC_DIR)
# Directories
SRC_DIR = src
INC_DIR = src
BIN_DIR = bin
# Files
SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(SRCS:$(SRC_DIR)/%.c=$(BIN_DIR)/%.o)
DEPS := $(OBJS:%.o=%.d)
# Targets
EXECUTABLE = $(BIN_DIR)/program.exe
TARGET = yacbfi
ifeq ($(OS),Windows_NT)
TARGET := $(TARGET).exe
BIN_DIR := $(subst /,\,$(BIN_DIR))
REM = del /Q /F
REMDIR = rmdir /S /Q
else
REM = rm -rf
REMDIR := $(REM)
endif
# Phony targets
.PHONY: all clean release
# Default target
all: $(BIN_DIR)/$(TARGET)
# Release target
release: CFLAGS = $(RELEASE_CFLAGS)
release: clean all
# Linking
$(BIN_DIR)/$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
# Compiling
$(BIN_DIR)/%.o: $(SRC_DIR)/%.c | $(BIN_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# Create bin dir
$(BIN_DIR):
@mkdir $@
# Get git status
diff:
$(info The status of the repository, and the volume of per-file changes:)
@git status
@git diff --stat
# Cleaning
clean:
$(REMDIR) $(BIN_DIR)
# Include dependencies
-include $(DEPS)