-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
87 lines (66 loc) · 1.69 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
EXE = F16Sim
ifdef OS
#EXE +=.exe
RM = del /Q
FixPath = $(subst /,\,$1)
MKDIR_P = mkdir
else
ifeq ($(shell uname), Linux)
RM = rm -f
FixPath = $1
MKDIR_P = mkdir -p
endif
endif
#$(call FixPath,TEXT)
#***************************************
# Settings
#***************************************
CC=gcc
EXT=c
#+++++++++++++++++++++
# Paths
#+++++++++++++++++++++
SRC_DIR=src
OBJ_DIR=obj
#+++++++++++++++++++++
# Source Files
#+++++++++++++++++++++
SRC = $(wildcard $(SRC_DIR)/*.$(EXT))
OBJ = $(SRC:$(SRC_DIR)/%.$(EXT)=$(OBJ_DIR)/%.o)
#+++++++++++++++++++++
# Flags
#+++++++++++++++++++++
# Compiler Flags
#STD = -std=gnu11
STD = -std=gnu99
#STD = -std=c99
CFLAGS += $(STD) -Wall -Wno-implicit-function-declaration -Wno-unused-variable -Wno-unused-but-set-variable -Wno-int-conversion -Wno-comment # some warnings about bad code
# Preprocessor Flags
CPPFLAGS += -Iinclude # -I is a preprocessor flag, not a compiler flag
# Linker Flags
LDFLAGS += -Llib
# External Libraries
LDLIBS += -lm
#***************************************
# Compile
#***************************************
.PHONY: all clean directories
all: directories $(EXE)
# all:
# @echo "SRC: $(SRC)"
# @echo "OBJ: $(OBJ)"
$(EXE): $(OBJ)
$(CC) $(LDFLAGS) $(call FixPath,$^) $(LDLIBS) -o $(call FixPath,$@)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $(call FixPath,$<) -o $(call FixPath,$@)
#***************************************
# Clean
#***************************************
clean:
$(RM) -r $(OBJ_DIR)/*
#***************************************
# MakeDirectories
#***************************************
directories: ${OBJ_DIR}
${OBJ_DIR}:
${MKDIR_P} ${OBJ_DIR}