-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
50 lines (38 loc) · 777 Bytes
/
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
# Program name
NAME = philo
# Compiler
CC = gcc
# Directories
SRCDIR = source
INCDIR = headers
BUILDDIR = build
# Flags etc.
CFLAGS = -Wall -g
LIBS = -pthread
INC = -I$(INCDIR)
# ------------------
# Functionality
# ------------------
SRC = $(shell find $(SRCDIR) -name '*.c')
OBJ = $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC))
# Default
compile: makedir $(NAME)
# Link
$(NAME): $(OBJ)
$(CC) -o $(NAME) $^ $(LIBS)
# Clean objects
clean:
@rm -f $(BUILDDIR)/*
# Clean the binary too
fullclean: clean
@rm -f $(NAME)
# Full clean and make again
remake: fullclean compile
# Create Build directory
makedir:
@mkdir -p $(BUILDDIR)
# Compile
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -o $@ -c $< $(INC)
# PHONY
.PHONY: compile clean fullclean remake