forked from zorgnax/libtap
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
72 lines (53 loc) · 1.66 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
CC ?= gcc
CFLAGS += -Wall -I. -fPIC
PREFIX ?= $(DESTDIR)/usr/local
TESTS = $(patsubst %.c, %, $(wildcard t/*.c))
ifdef ANSI
# -D_BSD_SOURCE for MAP_ANONYMOUS
CFLAGS += -ansi -D_BSD_SOURCE
LDLIBS += -lbsd-compat
endif
%:
$(CC) $(LDFLAGS) $(TARGET_ARCH) $(filter %.o %.a %.so, $^) $(LDLIBS) -o $@
%.o:
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $(filter %.c, $^) $(LDLIBS) -o $@
%.a:
$(AR) rcs $@ $(filter %.o, $^)
%.so:
$(CC) -shared $(LDFLAGS) $(TARGET_ARCH) $(filter %.o, $^) $(LDLIBS) -o $@
all: libtap.a libtap.so tap.pc tests
tap.pc:
@echo generating tap.pc
@echo 'prefix='$(PREFIX) > tap.pc
@echo 'exec_prefix=$${prefix}' >> tap.pc
@echo 'libdir=$${prefix}/lib' >> tap.pc
@echo 'includedir=$${prefix}/include' >> tap.pc
@echo '' >> tap.pc
@echo 'Name: libtap' >> tap.pc
@echo 'Description: Write tests in C' >> tap.pc
@echo 'Version: 0.1.0' >> tap.pc
@echo 'URL: https://github.com/zorgnax/libtap' >> tap.pc
@echo 'Libs: -L$${libdir} -ltap' >> tap.pc
@echo 'Cflags: -I$${includedir}' >> tap.pc
libtap.a: tap.o
libtap.so: tap.o
tap.o: tap.c tap.h
tests: $(TESTS)
$(TESTS): %: %.o libtap.a
$(patsubst %, %.o, $(TESTS)): %.o: %.c tap.h
clean:
rm -rf *.o t/*.o tap.pc libtap.a libtap.so $(TESTS)
install: libtap.a tap.h libtap.so tap.pc
mkdir -p $(PREFIX)/lib $(PREFIX)/include $(PREFIX)/lib/pkgconfig
install -c libtap.a $(PREFIX)/lib
install -c libtap.so $(PREFIX)/lib
install -c tap.pc $(PREFIX)/lib/pkgconfig
install -c tap.h $(PREFIX)/include
uninstall:
rm $(PREFIX)/lib/libtap.a $(PREFIX)/lib/libtap.so $(PREFIX)/include/tap.h
dist:
rm libtap.zip
zip -r libtap *
check test: all
./t/test
.PHONY: all clean install uninstall dist check test tests