-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
76 lines (55 loc) · 1.93 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
CC=gcc
CFLAGS= -std=gnu11
LDFLAGS=-lelf -ldl -Wl,-z,noexecstack
VERSION=0.1.0
PREFIX=/usr
OBJECTS = $(patsubst src/%.c, build/lib/%.o, $(wildcard src/*.c))
HEADERS = $(wildcard src/*.h)
SOLINK = libstapsdt.so
SONAME = libstapsdt.so.0
all: out/libstapsdt.a out/$(SONAME)
install:
mkdir -p $(DESTDIR)$(PREFIX)/lib
mkdir -p $(DESTDIR)$(PREFIX)/include
cp out/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
cp src/libstapsdt.h $(DESTDIR)$(PREFIX)/include/
ln -s $(DESTDIR)$(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(SOLINK)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/lib/$(SONAME)
rm -f $(DESTDIR)$(PREFIX)/lib/$(SOLINK)
rm -f $(DESTDIR)$(PREFIX)/include/libstapsdt.h
build/lib/libstapsdt-x86_64.o: src/asm/libstapsdt-x86_64.s
mkdir -p build
$(CC) $(CFLAGS) -fPIC -c $^ -o $@
build/lib/%.o: src/%.c $(HEADERS)
mkdir -p build/lib/
$(CC) $(CFLAGS) -fPIC -c $< -o $@
out/libstapsdt.a: $(OBJECTS) build/lib/libstapsdt-x86_64.o
mkdir -p out
ar rcs $@ $^
out/$(SONAME): $(OBJECTS) build/lib/libstapsdt-x86_64.o
mkdir -p out
$(CC) $(CFLAGS) -shared -Wl,-soname=$(SONAME) -o $@ $^ $(LDFLAGS)
demo: all example/demo.c
$(CC) $(CFLAGS) example/demo.c out/libstapsdt.a -o demo -Isrc/ $(LDFLAGS)
test: all
make -C ./tests/
clean:
rm -rf build/*
rm -rf out/*
make clean -C ./tests/
lint:
clang-tidy src/*.h src/*.c -- -Isrc/
format:
clang-tidy src/*.h src/*.c -fix -- -Isrc/
docs:
make -C ./docs/ html
docs-server:
cd docs/_build/html; python3 -m http.server;
deb-pkg-setup:
mkdir -p dist/libstapsdt-$(VERSION)/;
git archive HEAD | gzip > dist/libstapsdt-$(VERSION).tar.gz;
tar xvzf dist/libstapsdt-$(VERSION).tar.gz -C dist/libstapsdt-$(VERSION)/;
cd dist/libstapsdt-$(VERSION); dh_make -l -c mit -y -f ../libstapsdt-$(VERSION).tar.gz;
rm -rf dist/libstapsdt-$(VERSION)/debian/*.ex dist/libstapsdt-$(VERSION)/debian/*.EX dist/libstapsdt-$(VERSION)/debian/README.*
.PHONY: all clear lint format build-tests docs install uninstall deb-pkg-setup