-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
65 lines (48 loc) · 1.74 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
PROG=hap
SRCS += src/hap.c \
src/hap_pairing.c \
src/hap_network.c \
src/hap_convenience.c \
src/buf.c \
src/http_parser.c \
src/intvec.c \
O ?= build
SONAME=libhap.so.0
PREFIX ?= /usr/local
CFLAGS += -std=gnu99 -O2 -Wall -Werror -Wno-unused-function -g
CFLAGS += $(shell pkg-config --cflags libcrypto avahi-client)
LDFLAGS += $(shell pkg-config --libs libcrypto avahi-client)
LDFLAGS += -lpthread
ifeq (${ASAN},1)
O = build.asan
CFLAGS += -fsanitize=address
LDFLAGS += -fsanitize=address
PROG = hap.asan
endif
CFLAGS_shared = -fvisibility=hidden -fPIC -shared -DHAP_SHARED_OBJECT_BUILD
OBJS = $(SRCS:%.c=$(O)/%.o)
DEPS = ${OBJS:%.o=%.d}
${PROG}: ${OBJS} src/main.c Makefile
@mkdir -p $(dir $@)
${CC} ${CFLAGS} -o $@ ${OBJS} src/main.c ${LDFLAGS}
${O}/%.o: %.c Makefile | checkextdeps
@mkdir -p $(dir $@)
${CC} -MD ${CFLAGS} -c -o $@ $<
${O}/${SONAME}: ${SRCS} Makefile
@mkdir -p $(dir $@)
${CC} -Wl,-soname,${SONAME} -Wl,--no-undefined ${CFLAGS} ${CFLAGS_shared} -o $@ ${SRCS} ${LDFLAGS}
strip --strip-all --discard-all $@
solib: ${O}/${SONAME}
install: ${O}/${SONAME}
@mkdir -p "${PREFIX}/include/libhap" "${PREFIX}/lib/"
cp src/hap.h "${PREFIX}/include/libhap/"
cp "${O}/${SONAME}" "${PREFIX}/lib/"
ln -srf "${PREFIX}/lib/${SONAME}" "${PREFIX}/lib/libhap.so"
if [ "x`id -u $$USER`" = "x0" ]; then ldconfig ; fi
uninstall:
rm -rf "${PREFIX}/lib/libhap.so" "${PREFIX}/lib/${SONAME}" "${PREFIX}/include/libhap"
checkextdeps:
@which pkg-config >/dev/null || (echo "\nDependency unmet: Need pkg-config\n" && exit 1)
@pkg-config --atleast-version=1.1.1 libcrypto || (echo "\nDependency unmet: Need at least openssl >= 1.1.1\n" && exit 1)
@pkg-config avahi-client || (echo "\nDependency unmet: Need avahi-client\n" && exit 1)
-include $(DEPS)