This repository has been archived by the owner on Feb 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
105 lines (81 loc) · 2.96 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
# Note: uses GNU Make features
CXXFLAGS ?= -Wall -Wextra -pedantic -O2 -Wno-unused-parameter
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
SBINDIR ?= $(PREFIX)/sbin
MANDIR ?= $(PREFIX)/share/man
ENABLE_MAN ?= yes
ENABLE_IFUPDOWN ?= no
# libndp
LIBNDP_CFLAGS ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags libndp)
LIBNDP_LIBS ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs libndp)
# CXXFLAGS and LDFLAGS
CXXFLAGS += -std=c++11
CXXFLAGS += $(LIBNDP_CFLAGS)
LDFLAGS += -lrt
# Files
PROGRAMS = rdiscd rdiscd-mkaddress rdiscmon
COMMON_OBJFILES = rdisc.o util.o
DAEMON_OBJFILES = sha256.o rfc7217.o
all: build
#
# Build
#
BUILD_MAN_TARGETS-yes = build-man
BUILD_MAN_TARGETS-no =
BUILD_IFUPDOWN_TARGETS-yes = build-ifupdown
BUILD_IFUPDOWN_TARGETS-no =
BUILD_TARGETS := build-bin $(BUILD_MAN_TARGETS-$(ENABLE_MAN)) $(BUILD_IFUPDOWN_TARGETS-$(ENABLE_IFUPDOWN))
build: $(BUILD_TARGETS)
build-bin: $(PROGRAMS)
rdiscd: rdiscd.o $(DAEMON_OBJFILES) $(COMMON_OBJFILES)
$(CXX) $(CXXFLAGS) -o $@ rdiscd.o $(DAEMON_OBJFILES) $(COMMON_OBJFILES) $(LDFLAGS) $(LIBNDP_LIBS)
rdiscd-mkaddress: rdiscd-mkaddress.o $(DAEMON_OBJFILES) $(COMMON_OBJFILES)
$(CXX) $(CXXFLAGS) -o $@ rdiscd-mkaddress.o $(DAEMON_OBJFILES) $(COMMON_OBJFILES) $(LDFLAGS) $(LIBNDP_LIBS)
rdiscmon: rdiscmon.o $(COMMON_OBJFILES)
$(CXX) $(CXXFLAGS) -o $@ rdiscmon.o $(COMMON_OBJFILES) $(LDFLAGS) $(LIBNDP_LIBS)
build-man:
build-ifupdown:
#
# Clean
#
CLEAN_MAN_TARGETS-yes = clean-man
CLEAN_MAN_TARGETS-no =
CLEAN_IFUPDOWN_TARGETS-yes = clean-ifupdown
CLEAN_IFUPDOWN_TARGETS-no =
CLEAN_TARGETS := clean-bin $(CLEAN_MAN_TARGETS-$(ENABLE_MAN)) $(CLEAN_IFUPDOWN_TARGETS-$(ENABLE_IFUPDOWN))
clean: $(CLEAN_TARGETS)
clean-bin:
rm -f *.o $(PROGRAMS)
clean-man:
clean-ifupdown:
#
# Install
#
INSTALL_MAN_TARGETS-yes = install-man
INSTALL_MAN_TARGETS-no =
INSTALL_IFUPDOWN_TARGETS-yes = install-ifupdown
INSTALL_IFUPDOWN_TARGETS-no =
INSTALL_TARGETS := install-bin $(INSTALL_MAN_TARGETS-$(ENABLE_MAN)) $(INSTALL_IFUPDOWN_TARGETS-$(ENABLE_IFUPDOWN))
install: $(INSTALL_TARGETS)
install-bin: build-bin
install -d $(DESTDIR)$(BINDIR)
install -m 755 rdiscd-mkaddress $(DESTDIR)$(BINDIR)/
install -d $(DESTDIR)$(SBINDIR)
install -m 755 rdiscd $(DESTDIR)$(SBINDIR)/
install -m 755 rdiscd-keygen $(DESTDIR)$(SBINDIR)/
install -m 755 rdiscmon $(DESTDIR)$(SBINDIR)/
install-man: build-man
install -d $(DESTDIR)$(MANDIR)/man8
install -m 644 rdiscd.8 $(DESTDIR)$(MANDIR)/man8/
install -m 644 rdiscd-keygen.8 $(DESTDIR)$(MANDIR)/man8/
install -m 644 rdiscmon.8 $(DESTDIR)$(MANDIR)/man8/
install-ifupdown: build-ifupdown
install -d $(DESTDIR)/etc/network/if-post-down.d
install -m 755 rdiscd.if-post-down $(DESTDIR)/etc/network/if-post-down.d/000-rdiscd
install -d $(DESTDIR)/etc/network/if-pre-up.d
install -m 755 rdiscd.if-pre-up $(DESTDIR)/etc/network/if-pre-up.d/zzz-rdiscd
.PHONY: all \
build build-bin build-man build-ifupdown \
clean clean-bin clean-man clean-ifupdown \
install install-bin install-man install-ifupdown