-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (63 loc) · 1.56 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ifdef I_WANT_GCC
CC = gcc
FLAGS = -Wall -Wextra
else
CC = clang
FLAGS = -Weverything
endif
PYTHON = .env/bin/python
FLAGS += -std=c11 -Werror
FLAGS += -Wno-error=unused-parameter
FLAGS += -Wno-error=unused-variable
FLAGS += -Wno-error=unused-function
FLAGS += -Wno-error=double-promotion
FLAGS += -Wno-reserved-id-macro
FLAGS += -Wno-format-nonliteral
FLAGS += -g -O3
# FLAGS += -pg
FLAGS += -DNTHREADS=16
LINKER = -lpthread
UNAME := $(shell uname)
ARCH := $(shell uname -m)
# linux is annoying and doesn't link math library by default
ifeq ($(UNAME), Linux)
MATH = -lm
endif
# probably shouldn't use Weverthing but this fixes it for mac
ifeq ($(UNAME), Darwin)
FLAGS += -Wno-poison-system-directories -DMAC
endif
ifeq ($(ARCH), arm64)
FLAGS += -mcpu=apple-m1
else
FLAGS += -march=native
endif
SRC := $(wildcard src/*.c)
OBJ := $(SRC:.c=.o)
ONLY_FORMAT := $(wildcard src/*.h) tests/heap_test.c
OUTPUTDIR := output
.PHONY: all format clean test run
all: format voronoi
# the leading '-' keeps make from aborting if this fails
format:
@-clang-format -i -style=file $(SRC) $(ONLY_FORMAT)
%.o: %.c %.h
$(CC) $(FLAGS) -c $< -o $@
# the leading '@' means don't echo the command
$(OUTPUTDIR):
@mkdir -p $@
voronoi: $(OBJ) | $(OUTPUTDIR)
$(CC) $(FLAGS) $(LINKER) $(MATH) $^ -o $@
tests/heap_test: tests/heap_test.c src/heap.o
$(CC) $(FLAGS) $(MATH) $^ -o $@
test: format voronoi tests/heap_test
rm -f output/*
tests/heap_test
bash tests/main_test.sh
clean:
rm -rf tests/*.dSYM
rm -f $(OBJ) *.gif output/*
run: voronoi
$(PYTHON) plot.py -g 100
voronoi -n 100
$(PYTHON) plot.py