-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (28 loc) · 833 Bytes
/
Copy pathMakefile
File metadata and controls
37 lines (28 loc) · 833 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
37
CC=gcc
INCLUDE=-I'include' -I'include/third_party'
CFLAGS=-std=c99 -Wall -g -D_POSIX_SOURCE -D_GNU_SOURCE $(INCLUDE)
SRC_DIR=src
TEST_DIR=tests
SRCS := $(shell find $(SRC_DIR)/* -maxdepth 0 -name '*.c')
TEST_SRCS := $(shell find $(TEST_DIR)/* -maxdepth 0 -name '*.c')
all: dirs
$(CC) $(CFLAGS) $(SRCS) main.c -o bin/main -lm
optimized: dirs
$(CC) -O2 $(CFLAGS) $(SRCS) main.c -o bin/main -lm -lstdc++
run: all
./bin/main
test: dirs
$(CC) $(CFLAGS) $(SRCS) $(TEST_SRCS) -o bin/test \
-lm -lstdc++
runtest: test
./bin/test
memcheck: all
valgrind --leak-check=full --show-leak-kinds=all ./bin/main
gprof: dirs
$(CC) $(CFLAGS) $(SRCS) -pg main.c -o bin/main -lm+ \
&& ./bin/main && gprof ./bin/main > prof/gprof.info \
&& mv gmon.out prof
dirs:
mkdir -p bin prof lib
clean:
rm prof/gmon.out && rm prof/gprof.info