forked from AlexGustafsson/perf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (38 loc) · 1.72 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
# Disable echoing of commands
MAKEFLAGS += --silent
export CCFLAGS := $(CCFLAGS) -Wall -Wextra -pedantic -Wno-unused-parameter -fno-omit-frame-pointer -g
source := $(shell find * -type f -name "*.c" -not -path "build/*")
headers := $(shell find * -type f -name "*.h" -not -path "build/*")
.PHONY: build library format clean
build: library examples
library: build/lib/perf/libperf.a lib/perf.h lib/utilities.h
mkdir -p build/include/perf/
cp lib/perf.h lib/utilities.h build/include/perf
examples: build/examples/full build/examples/minimal build/examples/pi
build/lib/perf/libperf.a: build/perf.o build/utilities.o
mkdir -p $(dir $@)
$(AR) rcs $@ $^
build/perf.o: lib/perf.c lib/perf.h
mkdir -p $(dir $@)
$(CC) $(CCFLAGS) -c -o $@ $<
build/utilities.o: lib/utilities.c lib/utilities.h
mkdir -p $(dir $@)
$(CC) $(CCFLAGS) -c -o $@ $<
build/examples/full: library examples/full/main.c examples/full/harness.c examples/full/harness.h
mkdir -p $(dir $@)
$(CC) $(CCFLAGS) -o $@ examples/full/main.c examples/full/harness.c -I build/include -L build/lib/perf -lperf -lcap
build/examples/minimal: library examples/minimal/main.c
mkdir -p $(dir $@)
$(CC) $(CCFLAGS) -o $@ examples/minimal/main.c -I build/include -L build/lib/perf -lperf -lcap
build/examples/pi: library examples/pi/main.c
mkdir -p $(dir $@)
$(CC) $(CCFLAGS) -o $@ examples/pi/main.c examples/pi/harness.c -I build/include -L build/lib/perf -lperf -lcap -lm
# Create the compilation database for llvm tools
compile_commands.json: Makefile
# compiledb is installed using: pip install compiledb
compiledb -n make
# Format code according to .clang-format
format: compile_commands.json
clang-format -style=file -i $(source) $(headers)
clean:
rm -rf build &>/dev/null || true