summaryrefslogtreecommitdiffstats
path: root/src/daemon/Makefile.am
blob: 42240a411dabad619327b8557903291b6ff73bf8 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS)
AM_CPPFLAGS = $(LLDP_CPPFLAGS)
AM_LDFLAGS = $(LLDP_LDFLAGS)
BUILT_SOURCES =
CLEANFILES =

sbin_PROGRAMS = lldpd
man_MANS = lldpd.8

noinst_LTLIBRARIES = liblldpd.la

## Convenience library for lldpd and tests
nodist_liblldpd_la_SOURCES =
liblldpd_la_SOURCES  = \
	frame.h frame.c \
	lldp-tlv.h \
	client.c \
	priv.c \
	privsep.c privsep_io.c privsep_fd.c \
	interfaces.c \
	event.c lldpd.c \
	pattern.c \
	bitmap.c \
	probes.d trace.h \
	protocols/lldp.c \
	protocols/cdp.c \
	protocols/cdp.h \
	protocols/sonmp.c \
	protocols/sonmp.h \
	protocols/edp.c \
	protocols/edp.h
liblldpd_la_CFLAGS   = $(AM_CFLAGS) @libevent_CFLAGS@ @libcap_CFLAGS@
liblldpd_la_CPPFLAGS = $(AM_CPPFLAGS) -DSYSCONFDIR='"$(sysconfdir)"' -DLLDPCLI_PATH='"$(sbindir)/lldpcli"'
liblldpd_la_LIBADD   = \
	$(top_builddir)/src/libcommon-daemon-client.la \
	$(top_builddir)/src/libcommon-daemon-lib.la @libevent_LIBS@ @libcap_LIBS@

## lldpd
lldpd_SOURCES = main.c
lldpd_LDFLAGS = $(AM_LDFLAGS) $(LLDP_BIN_LDFLAGS)
lldpd_LDADD   = liblldpd.la @libevent_LDFLAGS@

if HOST_OS_LINUX
liblldpd_la_SOURCES += \
	forward-linux.c \
	interfaces-linux.c \
	netlink.c \
	dmi-linux.c \
	priv-linux.c
endif
if HOST_OS_DRAGONFLY
liblldpd_la_SOURCES += \
	forward-bsd.c \
	interfaces-bpf.c \
	interfaces-bsd.c \
	dmi-dummy.c \
	priv-bsd.c
endif
if HOST_OS_FREEBSD
liblldpd_la_SOURCES += \
	forward-bsd.c \
	interfaces-bpf.c \
	interfaces-bsd.c \
	dmi-freebsd.c \
	priv-bsd.c
endif
if HOST_OS_OPENBSD
liblldpd_la_SOURCES += \
	interfaces-bpf.c \
	forward-bsd.c \
	interfaces-bsd.c \
	dmi-openbsd.c \
	priv-bsd.c
endif
if HOST_OS_NETBSD
liblldpd_la_SOURCES += \
	forward-bsd.c \
	interfaces-bpf.c \
	interfaces-bsd.c \
	dmi-dummy.c \
	priv-bsd.c
endif
if HOST_OS_OSX
liblldpd_la_SOURCES += \
	forward-bsd.c \
	interfaces-bpf.c \
	interfaces-bsd.c \
	dmi-osx.c \
	priv-bsd.c
liblldpd_la_LDFLAGS  = $(AM_LDFLAGS)
liblldpd_la_LDFLAGS += -framework Foundation
liblldpd_la_LDFLAGS += -framework CoreFoundation -framework IOKit
liblldpd_la_LDFLAGS += -framework IOKit
endif
if HOST_OS_SOLARIS
liblldpd_la_SOURCES += \
	forward-solaris.c \
	interfaces-bpf.c \
	interfaces-solaris.c \
	dmi-dummy.c \
	priv-bsd.c
endif

# seccomp support
if USE_SECCOMP
BUILT_SOURCES += syscall-names.h
CLEANFILES    += syscall-names.h syscall-names.h.tmp
syscall-names.h:
	$(AM_V_GEN)
	$(AM_V_at)echo "#include <sys/syscall.h>" | $(CPP) -dM - > $@.tmp ;\
	echo "static const char *syscall_names[] = {" > $@ ;\
	grep '^#define __NR_' $@.tmp | \
		LC_ALL=C sed -r -n -e 's/^\#define[ \t]+__NR_([a-z0-9_]+)[ \t]+([0-9]+)(.*)/ [\2] = "\1",/p' >> $@ ;\
	echo "};" >> $@ ;\
	rm $@.tmp
nodist_liblldpd_la_SOURCES += syscall-names.h
liblldpd_la_SOURCES += priv-seccomp.c
liblldpd_la_CFLAGS  += @libseccomp_CFLAGS@
liblldpd_la_LIBADD  += @libseccomp_LIBS@
endif

# Add SNMP support if needed
if USE_SNMP
noinst_LTLIBRARIES       += liblldpd-snmp.la
liblldpd_snmp_la_SOURCES  = agent.c agent_priv.c agent.h
liblldpd_snmp_la_CFLAGS   = $(liblldpd_la_CFLAGS) @NETSNMP_CFLAGS@
liblldpd_snmp_la_CPPFLAGS = $(liblldpd_la_CPPFLAGS)
liblldpd_la_LIBADD       += liblldpd-snmp.la
lldpd_LDADD              += @NETSNMP_LIBS@
endif

## Systemtap/DTrace
EXTRA_DIST = dtrace2systemtap.awk
if ENABLE_SYSTEMTAP
BUILT_SOURCES += probes.h
CLEANFILES    += probes.h lldpd.stp
probes.h: probes.d
	$(AM_V_GEN)
	$(AM_V_at)$(DTRACE) -C -h -s $< -o $@
probes.o: probes.d
	$(AM_V_GEN)
	$(AM_V_at)$(DTRACE) -C -G -s $< -o $@
lldpd_LDADD += probes.o

lldpd.stp: probes.d $(srcdir)/dtrace2systemtap.awk $(top_builddir)/config.status
	$(AM_V_GEN)$(AWK) -f $(srcdir)/dtrace2systemtap.awk -v sbindir=$(sbindir) $< > $@ || ( rm -f $@ ; exit 1 )
tapsetdir = $(datadir)/systemtap/tapset
tapset_DATA = lldpd.stp
endif

## libevent
if LIBEVENT_EMBEDDED
event.c: $(top_builddir)/libevent/libevent.la
$(top_builddir)/libevent/libevent.la: $(top_srcdir)/libevent/*.c $(top_srcdir)/libevent/*.h
	(cd $(top_builddir)/libevent && $(MAKE))
endif

## systemd service file
if HAVE_SYSTEMDSYSTEMUNITDIR
systemdsystemunit_DATA = lldpd.service
endif

if HAVE_SYSUSERSDIR
sysusers_DATA = lldpd.sysusers.conf
endif

if HOST_OS_LINUX
if HAVE_APPARMORDIR
apparmor_DATA = usr.sbin.lldpd
endif
endif

TEMPLATES   = lldpd.8    lldpd.service    lldpd.sysusers.conf    usr.sbin.lldpd
EXTRA_DIST += lldpd.8.in lldpd.service.in lldpd.sysusers.conf.in usr.sbin.lldpd.in
CLEANFILES += $(TEMPLATES)
lldpd.8: lldpd.8.in
lldpd.service: lldpd.service.in
lldpd.sysusers.conf: lldpd.sysusers.conf.in
usr.sbin.lldpd: usr.sbin.lldpd.in
include $(top_srcdir)/edit.am