]> git.ipfire.org Git - thirdparty/lldpd.git/blame - src/lib/Makefile.am
build: use `cc -E` instead of `cpp` to build atom list
[thirdparty/lldpd.git] / src / lib / Makefile.am
CommitLineData
d627ab69
VB
1AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS)
2AM_CPPFLAGS = $(LLDP_CPPFLAGS)
e6515ff5 3AM_LDFLAGS = $(LLDP_LDFLAGS)
03ee074d 4
4b292b55
VB
5lib_LTLIBRARIES = liblldpctl.la
6include_HEADERS = lldpctl.h
7
f17837f7
VB
8noinst_LTLIBRARIES = libfixedpoint.la
9libfixedpoint_la_SOURCES = fixedpoint.h fixedpoint.c
10
d954509e 11ATOM_FILES = \
94c98157 12 atoms/config.c atoms/dot1.c atoms/dot3.c \
c576fd21 13 atoms/interface.c atoms/med.c atoms/mgmt.c atoms/port.c \
99ef55d3 14 atoms/custom.c atoms/chassis.c
d954509e
VB
15liblldpctl_la_SOURCES = \
16 lldpctl.h atom.h helpers.h \
e3783368 17 errors.c connection.c atom.c helpers.c \
d954509e 18 $(ATOM_FILES)
2c18cfb8 19nodist_liblldpctl_la_SOURCES = atom-glue.c
f17837f7 20liblldpctl_la_LIBADD = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoint.la
4b292b55 21
2c18cfb8 22atom-glue.c: $(ATOM_FILES) Makefile
106aa50d 23 $(AM_V_GEN)(for f in $(ATOM_FILES:%=$(srcdir)/%); do \
2a64d539 24 $(CC) -E $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
106aa50d 25 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $$f; done | \
e3783368
VB
26 $(SED) -n 's+^void init_atom_builder_\([^(]*\)().*, \([0-9]*\)).*+\2 \1+p' | \
27 sort | \
d954509e 28 $(AWK) '{ atoms[$$2] = 1 } \
2c18cfb8
VB
29 END { for (atom in atoms) { print "void init_atom_builder_"atom"(void);" } \
30 print "void init_atom_builder() {"; \
d954509e
VB
31 print " static int init = 0; if (init) return; init++;"; \
32 for (atom in atoms) { print " init_atom_builder_"atom"();" } \
33 print "}"; }' && \
106aa50d 34 for f in $(ATOM_FILES:%=$(srcdir)/%); do \
2a64d539 35 $(CC) -E $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
106aa50d 36 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $$f; done | \
e3783368 37 $(SED) -n 's+^void init_atom_map_\([^(]*\)().*, \([0-9]*\)).*+\2 \1+p' | \
d954509e
VB
38 sort -n | \
39 $(AWK) '{ atoms[$$2] = 1 } \
2c18cfb8
VB
40 END { for (atom in atoms) { print "void init_atom_map_"atom"(void);" } \
41 print "void init_atom_map() {"; \
d954509e
VB
42 print " static int init = 0; if (init) return; init++;"; \
43 for (atom in atoms) { print " init_atom_map_"atom"();" } \
44 print "}"; }' ) \
45 > $@.tmp
b921abc2
VB
46 $(AM_V_at)$(GREP) -q init_atom_builder_ $@.tmp
47 $(AM_V_at)$(GREP) -q init_atom_map_ $@.tmp
48 $(AM_V_at)mv $@.tmp $@
2c18cfb8 49CLEANFILES = atom-glue.c
d954509e 50
4b292b55 51# -version-info format is `current`:`revision`:`age`. For more details, see:
81291d63 52# https://www.sourceware.org/autobook/autobook/autobook_61.html#Library-Versioning
f571f2db
VB
53#
54# -version-number could be computed from -version-info, mostly major
55# is `current` - `age`, minor is `age` and revision is `revision' and
56# major.minor should be used when updaing lldpctl.map.
9d7e82a1 57liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -version-info 13:0:9
f571f2db
VB
58liblldpctl_la_DEPENDENCIES = libfixedpoint.la
59
60if HAVE_LD_VERSION_SCRIPT
61liblldpctl_la_DEPENDENCIES += lldpctl.map
62liblldpctl_la_LDFLAGS += -Wl,--version-script=$(srcdir)/lldpctl.map
63else
64liblldpctl_la_LDFLAGS += -export-symbols-regex '^lldpctl_'
65endif
4b292b55 66
4b292b55 67pkgconfig_DATA = lldpctl.pc
95493844
VB
68
69TEMPLATES = lldpctl.pc
e92d8842 70EXTRA_DIST = lldpctl.pc.in lldpctl.map
d954509e 71CLEANFILES += $(TEMPLATES)
95493844
VB
72lldpctl.pc: lldpctl.pc.in
73include $(top_srcdir)/edit.am