-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·55 lines (39 loc) · 876 Bytes
/
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
CC = gcc
FLAGS = -O0 -std=c99 -pedantic -g -Wall -Werror \
-Werror=return-type -Werror=uninitialized -lm
LNK = -L./
INC = -I./
COMP = $(CC) $(FLAGS) $(INC)
LINK = $(CC) $(FLAGS) $(INC) $(LNK)
EXE = fdf_example
EXT = c
SRC = $(wildcard *.$(EXT))
# For windows:
#MAKE_DIR = $(if exist $(1),,mkdir $(1))
#S=\\
# Linux and Unix-like:
MAKE_DIR = mkdir -p $(1)
S=/
OBJ_DIR = obj
OBJ = $(SRC:%.$(EXT)=$(OBJ_DIR)$(S)%.o)
OBJ_DIRS = $(dir $(OBJ))
DEPS = $(OBJ:%.o=%.d)
.PHONY: dirs all help clean
all : dirs $(EXE)
dirs : $(OBJ_DIR)
$(OBJ_DIR) :
$(call $(MAKE_DIR),$@)
help :
@echo "SRC is $(SRC)"
@echo "OBJ is $(OBJ)"
@echo "DEPS is $(DEPS)"
$(EXE) : $(OBJ)
$(LINK) $(OBJ) -o $@
$(OBJ_DIR)$(S)%.o : %.$(EXT)
$(call MAKE_DIR,$(dir $@))
$(COMP) -c $< -o $@
$(COMP) -M -MT '$@' $< -MF $(@:%.o=%.d)
clean:
rm -r $(OBJ_DIR)
rm -f $(EXE)
-include $(DEPS)