-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
36 lines (27 loc) · 881 Bytes
/
Makefile
File metadata and controls
36 lines (27 loc) · 881 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
# This is can be made much better
BINARY=cmonkey
LIBDIRS=./lib/
CODEDIRS=.
INCDIRS=. ./include/
CC=gcc
OPT=-O0
# generate files that encode make rules for the .h dependencies
DEPFLAGS=-MP -MD
CFLAGS= -Wall -Wextra -Wpedantic \
-Wformat=2 -Wno-unused-parameter -Wshadow \
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
-Wredundant-decls -Wnested-externs -Wmissing-include-dirs
CFLAGS += -g $(foreach D,$(INCDIRS), -I$(D)) $(OPT) $(DEPFLAGS)
CODEFILES=$(foreach D, $(CODEDIRS), $(wildcard $(D)/*.c))
LIBFILES=$(foreach D, $(LIBDIRS), $(wildcard $(D)/*.c))
CFILES=$(CODEFILES) $(LIBFILES)
# pattern substitution
OBJECTS=$(patsubst %.c, %.o, $(CFILES))
DEPFILES=$(patsubst %.c, %.d, $(CFILES))
all: $(BINARY)
$(BINARY): $(OBJECTS)
$(CC) -o $@ $^
%.o:%.c
$(CC) $(CFLAGS) -c -o $@ $^
clean:
rm -rf $(BINARY) $(OBJECTS) $(DEPFILES)