forked from scanoss/wayuu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·82 lines (66 loc) · 2.17 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
77
78
79
80
81
82
CC=gcc
# Enable all compiler warnings.
CCFLAGS=-g -Wall -fPIC
# Linker flags
LDFLAGS=-lpthread -lssl -lm -lcrypto -I.
# Valgrind flags
VGFLAGS ?= \
--quiet --leak-check=full --show-leak-kinds=all \
--track-origins=yes --error-exitcode=1
SOURCES=$(wildcard *.c)
# TESTABLE_SOURCES are $SOURCES without main.c
TESTABLE_SOURCES=$(filter-out main.c, $(SOURCES))
TEST_SOURCES=$(wildcard test/*.c) $(wildcard test/**/*.c)
OBJ_TEST=$(patsubst %.c,%.o,$(TEST_SOURCES))
OBJECTS=$(SOURCES:.c=.o)
TESTABLE_OBJECTS=$(filter-out main.o,$(SOURCES:.c=.o))
WAYUU_HEADERS=$(wildcard *.h)
TARGET=wayuu
VERSION:=`./wayuu -v`
all: clean $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) -g -o $@ $^ $(LDFLAGS)
lib: $(TESTABLE_OBJECTS)
rm -f libwayuu.a
$(CC) $(CCFLAGS) -o $@ -c $<
ar -cvq libwayuu.a *.o
slib: $(TESTABLE_OBJECTS)
$(CC) -g -o libwayuu.so $^ $(LDFLAGS) -shared -fpic
%.o: %.c
$(CC) $(CCFLAGS) -DWAYUU_DIST -o $@ -c $<
test/%.o: test/%.c
@mkdir -p $(dir $@)
$(CC) -DSNOW_ENABLED -I. -Itest/. $(CCFLAGS) -c -o $@ $<
test-$(TARGET): $(OBJ_TEST) $(TESTABLE_OBJECTS)
$(CC) -g -o $@ $(OBJ_TEST) $(TESTABLE_OBJECTS) $(LDFLAGS)
.PHONY: test
test: clean test-$(TARGET)
valgrind $(VGFLAGS) ./test-$(TARGET) $(ARGS)
run-valgrind: $(TARGET)
valgrind $(VGFLAGS) ./$(TARGET) -d $(ARGS)
.PHONY: clean
clean:
rm -f *.o **/*.o test/*.o test/**/*.o $(TARGET) test-$(TARGET)
.PHONY: print_src
print_src:
$(info $$SOURCES is [${SOURCES}])
$(info $$TESTABLE_SOURCES is [${TESTABLE_SOURCES}])
$(info $$TESTABLE_OBJECTS is [${TESTABLE_OBJECTS}])
$(info $$TEST_SOURCES is [${TEST_SOURCES}])
$(info $$OBJ_TEST is [${OBJ_TEST}])
install:
@cp libwayuu.so /usr/lib
@mkdir -p /usr/include/wayuu
@cp $(WAYUU_HEADERS) /usr/include/wayuu
deb: $(TARGET) slib
@rm -rf dist/debian
@mkdir -p dist/debian/DEBIAN
@mkdir -p dist/debian/usr/include/wayuu
@mkdir -p dist/debian/usr/lib
@mkdir -p dist/debian/usr/bin
cat packages/debian/control | sed "s/%VERSION%/$(VERSION)/" > dist/debian/DEBIAN/control
@cp -vax $(TARGET) dist/debian/usr/bin
@cp -vax $(WAYUU_HEADERS) dist/debian/usr/include/wayuu
@cp -vax libwayuu.so dist/debian/usr/lib
dpkg-deb --build dist/debian
mv dist/debian.deb dist/wayuu-$(VERSION)-amd64.deb