-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (48 loc) · 1.12 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
#directories
IDIR = inc
ODIR = obj
SDIR = src
LDIR = libmx
#compiler settings
CC = clang
CFLAGS = -std=c11
CCFLAGS = -std=c11 -Wall -Wextra -Werror -Wpedantic
FLAGS = $(CCFLAGS) -I $(IDIR) -I $(LDIR)/$(IDIR)
#dependencies
NAME = pathfinder
LIB = libmx.a
#headers
DEPS := $(wildcard $(IDIR)/*.h)
#sources
SRCS := $(wildcard $(SDIR)/*.c)
#objects
_OBJS = $(SRCS:.c=.o)
OBJS = $(subst $(SDIR),$(ODIR),$(_OBJS))
#TARGETS
all: $(NAME)
#make library
$(LDIR)/$(LIB):
@make -C $(LDIR)
#make objects
$(ODIR)/%.o: $(SDIR)/%.c $(DEPS)
@mkdir -p obj
@printf "\33[2KCompiling \33[0;32m$<\33[m\n"
@$(CC) $(FLAGS) -c $< -o $@
#make excecutable
$(NAME): $(OBJS) $(LDIR)/$(LIB)
@$(CC) $(FLAGS) $^ -o $@
@printf "\r\33[2KExcecutable for \33[0;32m$@\33[m done!\n"
@printf "Usage: ./$@ [filename]\n"
.PHONY: clean uninstall reinstall
#delete all files
uninstall: clean
@printf "\r\33[2K\33[0;33mUninstalling $(NAME)...\33[m\n"
@rm -f $(NAME)
@make $@ -C $(LDIR)
#remove all temp files
clean:
@rm -rf $(ODIR)
@printf "\r\33[2K\33[0;33mRemoving temporary $(NAME) files...\33[m\n"
@make $@ -C $(LDIR)
#rebuild project
reinstall: uninstall all