-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (43 loc) · 1.13 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
NAME := libminimath.a
SHELL = /bin/sh
RM = /bin/rm
.SUFFIXES:
.SUFFIXES: .c .o .h
include includes.mk sources.mk
OBJ_FILES = $(SRC_FILES:%.c=%.o)
# ****************************** DIRS AND PATHS ****************************** #
INC_DIR = include
SRC_DIR = src
OBJ_DIR = obj
INC = $(addprefix $(INC_DIR)/, $(INC_FILES))
OBJ = $(addprefix $(OBJ_DIR)/, $(OBJ_FILES))
VPATH = $(SRC_DIR)
# *************************** COMPILING AND FLAGS **************************** #
CC = gcc
AR = ar
ARFLAGS = -rcs
CFLAGS = -Wall -Wextra -Werror -g3
CPPFLAGS = -I$(INC_DIR)
# ********************************** RULES *********************************** #
all: $(NAME)
# OBJ DIR #
$(OBJ_DIR):
@mkdir -p $@
@echo "Created\t\t$@ directory"
# COMPILING #
$(OBJ_DIR)/%.o : %.c $(INC)
@echo "\r\033[KCompiling\t$< \c"
@$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
# ARCHIVING AND INDEXING #
$(NAME): $(OBJ_DIR) $(OBJ) $(INC)
@$(AR) $(ARFLAGS) $@ $(OBJ)
@echo "\nOK\t\t$@ is ready"
# CLEAN #
clean:
@$(RM) -rf $(OBJ_DIR)
@echo "Cleaned\t\tobject files"
fclean: clean
@$(RM) -f $(NAME)
@echo "Removed\t\t$(NAME)"
re: fclean all
.PHONY: all clean fclean re