-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (38 loc) · 1.12 KB
/
Makefile
File metadata and controls
54 lines (38 loc) · 1.12 KB
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
NAME := libnt_string_c.a
CC := gcc
INCLUDES := -I./include
CFLAGS := -std=c89 -pedantic -Wall -Wextra -Werror \
-Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes \
-Wundef -Wpointer-arith -Wwrite-strings $(INCLUDES)
AR := ar
ARFLAGS := rcs
RM := rm -rf
BUILD_DIR := build
OBJ_DIR := $(BUILD_DIR)/obj
LIB_DIR := $(BUILD_DIR)/lib
SRCS := $(wildcard src/*.c)
OBJS := $(patsubst src/%.c,$(OBJ_DIR)/%.o,$(SRCS))
DEPS := $(OBJS:.o=.d)
all: $(LIB_DIR)/$(NAME)
$(LIB_DIR)/$(NAME): $(OBJS) | $(LIB_DIR)
@$(AR) $(ARFLAGS) $@ $(OBJS)
@echo "Compilation completed."
$(OBJ_DIR)/%.o: src/%.c | $(OBJ_DIR)
@$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
@echo "Compiled $< into $@"
$(OBJ_DIR):
@mkdir -p $@
$(LIB_DIR):
@mkdir -p $@
$(BUILD_DIR):
@mkdir -p $@
clean:
@echo "Cleaning up object files and dependencies..."
$(RM) $(OBJ_DIR)
fclean:
@echo "Cleaning up the $(NAME) library..."
$(RM) $(BUILD_DIR)
@echo "Local clean-up completed."
re: fclean all
-include $(DEPS)
.PHONY: all clean fclean re