-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
36 lines (26 loc) · 672 Bytes
/
Makefile
File metadata and controls
36 lines (26 loc) · 672 Bytes
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
# Compiles all C files in the src directory
CFLAGS= -Wall -Wextra -Werror -Ofast
LDFLAGS= -lpthread -lm
CC=clang
ODIR= obj
SDIR= src
EDIR= bin
SRCS := $(wildcard $(SDIR)/*.c)
_PRGS := $(patsubst %.c,%,$(SRCS))
PRGS := $(patsubst $(SDIR)/%,$(EDIR)/%,$(_PRGS))
_OBJS := $(patsubst %,%.o,$(PRGS))
OBJS := $(patsubst $(EDIR)/%,$(ODIR)/%,$(_OBJS))
all : $(PRGS)
debug: clean
debug: CFLAGS += -DDEBUG -g
debug: $(PRGS)
## Compile the object files
$(ODIR)/%.o : $(SDIR)/%.c
$(CC) -c $< $(CFLAGS) -o $@
## Compile the executables
OBJ = $(patsubst $(EDIR)/%,$(ODIR)/%.o,$@)
$(PRGS): $(OBJS)
$(CC) $(OBJ) $(LDFLAGS) -o $@
.PHONY: clean
clean:
$(RM) $(PRGS) $(ODIR)/*.o