]> git.ipfire.org Git - thirdparty/lldpd.git/blob - src/lib/Makefile.am
build: make generation of atom-glue compatible with older gcc versions
[thirdparty/lldpd.git] / src / lib / Makefile.am
1 AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS)
2 AM_CPPFLAGS = $(LLDP_CPPFLAGS)
3 AM_LDFLAGS = $(LLDP_LDFLAGS)
4
5 lib_LTLIBRARIES = liblldpctl.la
6 include_HEADERS = lldpctl.h
7
8 noinst_LTLIBRARIES = libfixedpoint.la
9 libfixedpoint_la_SOURCES = fixedpoint.h fixedpoint.c
10
11 ATOM_FILES = \
12 atoms/config.c atoms/dot1.c atoms/dot3.c \
13 atoms/interface.c atoms/med.c atoms/mgmt.c atoms/port.c \
14 atoms/custom.c atoms/chassis.c
15 liblldpctl_la_SOURCES = \
16 lldpctl.h atom.h helpers.h \
17 errors.c connection.c atom.c helpers.c \
18 $(ATOM_FILES)
19 nodist_liblldpctl_la_SOURCES = atom-glue.c
20 liblldpctl_la_LIBADD = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoint.la
21
22 atom-glue.c: $(ATOM_FILES) Makefile
23 $(AM_V_GEN)(for f in $(ATOM_FILES:%=$(srcdir)/%); do \
24 $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
25 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $$f; done | \
26 $(SED) -n 's+^void init_atom_builder_\([^(]*\)().*, \([0-9]*\)).*+\2 \1+p' | \
27 sort | \
28 $(AWK) '{ atoms[$$2] = 1 } \
29 END { for (atom in atoms) { print "void init_atom_builder_"atom"(void);" } \
30 print "void init_atom_builder() {"; \
31 print " static int init = 0; if (init) return; init++;"; \
32 for (atom in atoms) { print " init_atom_builder_"atom"();" } \
33 print "}"; }' && \
34 for f in $(ATOM_FILES:%=$(srcdir)/%); do \
35 $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
36 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $$f; done | \
37 $(SED) -n 's+^void init_atom_map_\([^(]*\)().*, \([0-9]*\)).*+\2 \1+p' | \
38 sort -n | \
39 $(AWK) '{ atoms[$$2] = 1 } \
40 END { for (atom in atoms) { print "void init_atom_map_"atom"(void);" } \
41 print "void init_atom_map() {"; \
42 print " static int init = 0; if (init) return; init++;"; \
43 for (atom in atoms) { print " init_atom_map_"atom"();" } \
44 print "}"; }' ) \
45 > $@.tmp
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 $@
49 CLEANFILES = atom-glue.c
50
51 # -version-info format is `current`:`revision`:`age`. For more details, see:
52 # https://www.sourceware.org/autobook/autobook/autobook_61.html#Library-Versioning
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.
57 liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -version-info 12:0:8
58 liblldpctl_la_DEPENDENCIES = libfixedpoint.la
59
60 if HAVE_LD_VERSION_SCRIPT
61 liblldpctl_la_DEPENDENCIES += lldpctl.map
62 liblldpctl_la_LDFLAGS += -Wl,--version-script=$(srcdir)/lldpctl.map
63 else
64 liblldpctl_la_LDFLAGS += -export-symbols-regex '^lldpctl_'
65 endif
66
67 pkgconfig_DATA = lldpctl.pc
68
69 TEMPLATES = lldpctl.pc
70 EXTRA_DIST = lldpctl.pc.in lldpctl.map
71 CLEANFILES += $(TEMPLATES)
72 lldpctl.pc: lldpctl.pc.in
73 include $(top_srcdir)/edit.am