-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile
120 lines (92 loc) · 3.22 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
CFLAGS ?= -Wall -Wwrite-strings -pedantic
CFLAGS += -std=gnu99
LDFLAGS += -lc
FEATURES ?= dns lpd tls bob cmd debug nss #natpmp upnp
OBJS = build/searches.o build/kad.o build/log.o \
build/conf.o build/net.o build/utils.o \
build/announces.o build/peerfile.o \
build/unix.o
ifeq ($(OS),Windows_NT)
OBJS += build/windows.o
endif
.PHONY: all clean strip install kadnode \
libnss_kadnode arch-pkg deb-pkg osx-pkg manpage install uninstall
all: kadnode
ifeq ($(findstring lpd,$(FEATURES)),lpd)
OBJS += build/ext-lpd.o
CFLAGS += -DLPD
endif
ifeq ($(findstring bob,$(FEATURES)),bob)
OBJS += build/ext-bob.o build/ecc_point_compression.o
CFLAGS += -DBOB
LDFLAGS += -lmbedtls -lmbedx509 -lmbedcrypto
endif
ifeq ($(findstring cmd,$(FEATURES)),cmd)
OBJS += build/ext-cmd.o
CFLAGS += -DCMD
endif
ifeq ($(findstring debug,$(FEATURES)),debug)
OBJS += build/tests.o
CFLAGS += -g -DDEBUG
endif
ifeq ($(findstring dns,$(FEATURES)),dns)
OBJS += build/ext-dns.o
CFLAGS += -DDNS
endif
ifeq ($(findstring nss,$(FEATURES)),nss)
OBJS += build/ext-nss.o
CFLAGS += -DNSS
EXTRA += libnss_kadnode
endif
ifeq ($(findstring tls,$(FEATURES)),tls)
OBJS += build/ext-tls-client.o build/ext-tls-server.o
CFLAGS += -DTLS
LDFLAGS += -lmbedtls -lmbedx509 -lmbedcrypto
endif
ifeq ($(findstring upnp,$(FEATURES)),upnp)
OBJS += build/upnp.o
CFLAGS += -DFWD_UPNP
LDFLAGS += -Wl,-Bdynamic -lminiupnpc
ENABLE_FORWARDING = 1
endif
ifeq ($(findstring natpmp,$(FEATURES)),natpmp)
OBJS += build/natpmp.o
CFLAGS += -DFWD_NATPMP
LDFLAGS += -Wl,-Bdynamic -lnatpmp
ENABLE_FORWARDING = 1
endif
ifeq ($(ENABLE_FORWARDING),1)
OBJS += build/ext-fwd.o
CFLAGS += -DFWD
endif
build/%.o : src/%.c src/%.h
$(CC) $(CFLAGS) -c -o $@ $<
libnss_kadnode:
$(CC) $(CFLAGS) -fPIC -c -o build/ext-libnss.o src/ext-libnss.c
$(CC) $(CFLAGS) -fPIC -c -o build/ext-libnss-utils.o src/ext-libnss-utils.c
$(CC) $(CFLAGS) -fPIC -c -o build/ext-libnss-bsd.o src/ext-libnss-bsd.c
$(CC) $(CFLAGS) $(LDFLAGS) -fPIC -shared -Wl,-soname,libnss_kadnode.so -o build/libnss_kadnode.so build/ext-libnss.o build/ext-libnss-utils.o build/ext-libnss-bsd.o
kadnode: build/main.o $(OBJS) $(EXTRA)
$(CC) $(CFLAGS) build/main.o $(OBJS) $(LDFLAGS) -o build/kadnode
ln -s kadnode build/kadnode-ctl 2> /dev/null || true
clean:
rm -rf build/*
manpage:
ronn --roff --manual=Kadnode\ Manual --organization=mwarning --date=2024-10-26 misc/manpage.md
mv misc/manpage.1 misc/manpage
install:
install -D -m755 -s build/kadnode $(DESTDIR)/usr/bin/
ln -s kadnode $(DESTDIR)/usr/bin/kadnode-ctl || true
install -D -m755 -s build/libnss_kadnode-2.0.so $(DESTDIR)/lib/libnss_kadnode.so.2 2> /dev/null || true
install -D -m644 misc/kadnode.conf $(DESTDIR)/etc/kadnode/kadnode.conf
install -D -m644 misc/peers.txt $(DESTDIR)/etc/kadnode/peers.txt
install_nss:
sed -i -e '/kadnode/!s/^\(hosts:.*\)\s\{1,\}dns\(.*\)/\1 kadnode dns\2/' $(DESTDIR)/etc/nsswitch.conf 2> /dev/null || true
uninstall:
rm -f $(DESTDIR)/usr/bin/kadnode
rm -f $(DESTDIR)/usr/bin/kadnode-ctl
rm -f $(DESTDIR)/lib/libnss_kadnode.so
rm -f $(DESTDIR)/etc/kadnode/kadnode.conf
rm -f $(DESTDIR)/etc/kadnode/peers.txt
uninstall_nss:
sed -i -e 's/^\(hosts:.*\)kadnode \(.*\)/\1\2/' $(DESTDIR)/etc/nsswitch.conf 2> /dev/null || true