-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (50 loc) · 1.23 KB
/
Copy pathMakefile
File metadata and controls
61 lines (50 loc) · 1.23 KB
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
CC = clang
NAME = libgithub
UNAME_S = $(shell uname -s)
CFLAGS = -std=c2x -O2 -fPIC -Wall -Wextra
ifeq ($(UNAME_S),FreeBSD)
CFLAGS += $(shell pkg-config --cflags --libs libcurl)
endif
LDFLAGS = -lcurl
# respect traditional UNIX paths
INCDIR = /usr/local/include
LIBDIR = /usr/local/lib
ifeq ($(UNAME_S),Darwin)
$(NAME).dylib: clean
$(CC) -dynamiclib -o $@ github.c $(CFLAGS) $(LDFLAGS)
else
$(NAME).so: clean
$(CC) -shared -o $@ github.c $(CFLAGS) $(LDFLAGS)
endif
.PHONY: tests
tests: clean
$(CC) -o tests/tests tests/unity.c tests/github_test.c github.c $(CFLAGS) $(LDFLAGS)
tests/tests
rm -f tests/tests
.PHONY: valgrind
valgrind: tests
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --tool=memcheck ./tests/tests 2>&1 | awk -F':' '/definitely lost:/ {print $2}'
.PHONY: install
install:
cp github.h $(INCDIR)
ifeq ($(UNAME_S),Darwin)
cp $(NAME).dylib $(LIBDIR)
else
cp $(NAME).so $(LIBDIR)
endif
uninstall:
rm -f $(INCDIR)/github.h
ifeq ($(UNAME_S),Darwin)
rm -f $(LIBDIR)/$(NAME).dylib
else
rm -f $(LIBDIR)/$(NAME).so
endif
.PHONY: clean
clean:
rm -f $(NAME).dylib
rm -f $(NAME).so
rm -f example
rm -f tests/tests
.PHONY: example
example: clean
$(CC) $(CFLAGS) -o $@ github.c example.c $(LDFLAGS)