-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (35 loc) · 1.3 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
CC = gcc
CFLAGS = -g -Wall -O0 -std=c11 -Wextra -Wwrite-strings \
-Wno-parentheses -Wpedantic -Warray-bounds -Wconversion -Wstrict-prototypes -Wnewline-eof
# Test for leaks with llvm
# Apple clang does not support sanitize
ifeq ($(CHECKLEAK),1)
CC=/opt/homebrew/opt/llvm/bin/clang
CFLAGS += -fsanitize=address -fsanitize=leak
endif
#LDFLAGS = -lm
SOURCES=$(wildcard src/**/*.c src/*.c)
OBJECTS=$(patsubst %.c, %.o, $(SOURCES)) # list *.c -> *.o
TARGET = bin
all: build
# The first target defined in the makefile is the one
# used when make is invoked with no argument. Given the definitions
# above, this Makefile file will build the one named TARGET and
# assume that it depends on all the named OBJECTS files.
$(TARGET) : $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
build: $(OBJECTS)
# Phony means not a "real" target, it doesn't build anything
# The phony target "clean" is used to remove all compiled object files.
test:
make -C ./tests
.PHONY: clean check
.SILENT: clean
clean:
rm -rf build $(OBJECTS) $(TESTS) $(TARGET) test
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print` # Remove XCode junk
check:
@echo Files with pontentially dangerous functions.
@egrep '[^_.>a-zA-Z0-9] (str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)\
|stpn?cpy|a?sn?printf|byte_)' $(SOURCES) || true