-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (46 loc) · 1.06 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
### VARIABLES ###
# Names
LIB = datalib.a
# Instructions
CC = gcc -Wall -Wextra -Werror
AR = ar rc
RM = rm -f
# Directories
inc = inc
src = src
obj = obj
# Files
INC = $(wildcard $(inc)/*.h $(inc)/*/*.h $(inc)/*/*/*.h)
SRC = $(wildcard $(src)/*.c $(src)/*/*.c $(src)/*/*/*.c)
OBJ = $(patsubst $(src)/%.c, $(obj)/%.o, $(SRC))
### RULES ###
# Main rules
all: $(OBJ)
@$(AR) $(LIB) $(OBJ)
@echo "File '$(LIB)' created."
clean:
@$(RM) -r $(obj)
@echo "Object files removed."
fclean: clean
@$(RM) $(LIB)
@echo "File '$(LIB)' removed."
re: fclean all
@echo "It was recompiled."
.PHONY: all clean fclean re
$(obj)/%.o: $(src)/%.c
@mkdir -p $(dir $@)
@$(CC) -c $< -o $@
@echo "File '$<' compiled."
# Makefile info
info:
@echo "Library : $(LIB)"
@echo
@echo "Compile : '$(CC) (...)' + '$(AR) (...)'"
@echo "Remove : '$(RM) (...)'"
@echo
@echo "Headers :"
@for file in $(INC); do echo " · $$file"; done
@echo "Sources :"
@for file in $(SRC); do echo " · $$file"; done
@echo "Objects :"
@for file in $(OBJ); do echo " · $$file"; done