-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (82 loc) · 2.04 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#### Start of system configuration section. ####
GIT_VERSION := "$(shell git describe --abbrev=4 --dirty --always --tags)"
CC := gcc
CFLAGS := -Wall -Wextra -Wimplicit -std=c99 \
-Wno-unused-parameter \
-O2 -march=native \
##############\
-Wconversion \
-DPROC_COUNT=$(shell nproc --all) \
-rdynamic -Og -ggdb3 \
-fsanitize=address -rdynamic \
-pg -rdynamic \
-O3 -march=native \
-DCOLORPRINT_DISABLE \
-O0 -g \
-rdynamic -Og -ggdb3 \
-DCOLORPRINT_DISABLE \
-Werror \
-Warith-conversion \
-pg -O2 \
-DNDEBUG \
-march=native \
-Og -rdynamic \
-march=native \
-Wall \
###############
LDFLAGS := \
-lm \
##############\
-rdynamic -Og -ggdb3 \
-rdynamic -ggdb3 \
-fsanitize=address -rdynamic \
-pg -rdynamic \
-fsanitize=address \
-pg \
CSUFFIX := .c
HSUFFIX := .h
#### End of system configuration section. ####
APPNAME = a
# Path for important files
# .c and .h files
SRC_DIR = src
# .o files
OBJ_DIR = obj
# target directory
TRG_DIR = .
.PHONY: all clean
# Files to compile
TARGET := $(addprefix $(TRG_DIR)/,$(APPNAME))
C_FILES := $(wildcard $(SRC_DIR)/*$(CSUFFIX))
O_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(C_FILES:$(CSUFFIX)=.o)))
D_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(C_FILES:$(CSUFFIX)=.d)))
all: $(TARGET)
# link all .o files
$(TARGET): $(O_FILES) | $(TRG_DIR)
@echo link : $@ #$^
@$(CC) $(LDFLAGS) -o $@ $^
# depend include files
-include $(D_FILES)
# compile all .c Files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%$(CSUFFIX) Makefile | $(OBJ_DIR)
@echo compile : $<
@$(CC) $(CFLAGS) -c -DVERSION=\"$(GIT_VERSION)\" -MMD -o $@ $<
# create directories if they don't exist
# .o dir
$(OBJ_DIR):
@mkdir $@
# target dir
$(TRG_DIR):
@mkdir $@
#### CLEANING ####
ifeq ($(OS),Windows_NT)
# Cleaning rules for Windows OS (no clue if this works)
clean:
@del /q $(OBJ_DIR), $(TRG_DIR)
@rmdir $(OBJ_DIR)
@rmdir $(TRG_DIR)
else
# Cleaning rules for Unix-based OS
clean:
@rm -rf $(OBJ_DIR) $(TRG_DIR) $(TARGET)
endif