-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·60 lines (46 loc) · 1.47 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
FLAGS = -g -Wall -Wextra -Werror -O3
CC = gcc
SRC_PATH = ./res/src/
BIN_PATH = ./res/bin/
INCLUDE_PATH = ./res/include/
BLACKLIST =
SRC_BLACKLIST = $(addprefix $(SRC_PATH), $(BLACKLIST))
INCLUDE = -I$(INCLUDE_PATH)
SRCS = $(wildcard $(SRC_PATH)*.c)
SRC = $(filter-out $(SRC_BLACKLIST), $(SRCS))
BINS = $(SRC:.c=.o)
BIN = $(addprefix $(BIN_PATH), $(addprefix $(LIBNAME)_, $(notdir $(BINS))))
COMPILE = $(CC) $(FLAGS) $(INCLUDE)
.PHONY = all extract clean fclean re
# Colors
G = \33[1;32m
N = \033[0m
# Colors
all: libud_$(LIBNAME).a
libud_$(LIBNAME).a: $(BIN) extract
ifdef ARNAME
@$(eval LIB_OBJ=$(shell echo *.o))
endif
@ar rc libud_${LIBNAME}.a ${BIN} ${LIB_OBJ}
@echo "\t$(G)Success: Static library [ libud_${LIBNAME}.a ] compiled.$(N)"
@ranlib libud_${LIBNAME}.a
@echo "\t$(G)Success: Static library [ libud_${LIBNAME}.a ] indexed.$(N)"
ifdef ARNAME
@rm *.o
endif
extract:
ifdef ARNAME
@for dep in $(ARNAME); do \
ar x $${dep}; \
done
endif
$(BIN_PATH)$(LIBNAME)_%.o: $(SRC_PATH)%.c $(DEPHEADER)
@mkdir -p $(BIN_PATH) || true
@echo -n "\t$(G)Success: "
$(COMPILE) $< -o $@ -c
@echo -n "$(N)"
clean:
@rm -f $(BIN_PATH)/*.o
fclean: clean
@rm -f ${wildcard *.a}
re: fclean all