xref: /aosp_15_r20/external/iptables/iptables/Makefile.am (revision a71a954618bbadd4a345637e5edcf36eec826889)
1# -*- Makefile -*-
2
3AM_CFLAGS        = ${regular_CFLAGS}
4AM_CPPFLAGS      = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include -I${top_srcdir} ${kinclude_CPPFLAGS} ${libmnl_CFLAGS} ${libnftnl_CFLAGS} ${libnetfilter_conntrack_CFLAGS}
5AM_LDFLAGS       = ${regular_LDFLAGS}
6
7BUILT_SOURCES =
8
9common_sources = iptables-xml.c xtables-multi.h xshared.c xshared.h
10common_ldadd   = ../extensions/libext.a ../libxtables/libxtables.la -lm
11common_cflags  = ${AM_CFLAGS}
12if ENABLE_STATIC
13common_cflags += -DALL_INCLUSIVE
14endif
15
16xtables_legacy_multi_SOURCES  = ${common_sources} xtables-legacy-multi.c \
17				iptables-restore.c iptables-save.c
18xtables_legacy_multi_CFLAGS   = ${common_cflags}
19xtables_legacy_multi_LDADD    = ${common_ldadd}
20if ENABLE_IPV4
21xtables_legacy_multi_SOURCES += iptables-standalone.c iptables.c iptables-multi.h
22xtables_legacy_multi_CFLAGS  += -DENABLE_IPV4
23xtables_legacy_multi_LDADD   += ../libiptc/libip4tc.la ../extensions/libext4.a
24endif
25if ENABLE_IPV6
26xtables_legacy_multi_SOURCES += ip6tables-standalone.c ip6tables.c ip6tables-multi.h
27xtables_legacy_multi_CFLAGS  += -DENABLE_IPV6
28xtables_legacy_multi_LDADD   += ../libiptc/libip6tc.la ../extensions/libext6.a
29endif
30
31# iptables using nf_tables api
32if ENABLE_NFTABLES
33xtables_nft_multi_SOURCES  = ${common_sources} xtables-nft-multi.c
34xtables_nft_multi_CFLAGS   = ${common_cflags}
35xtables_nft_multi_LDADD    = ${common_ldadd} \
36			     ../extensions/libext_arpt.a \
37			     ../extensions/libext_ebt.a \
38			     ../extensions/libext4.a \
39			     ../extensions/libext6.a \
40			     ${libmnl_LIBS} ${libnftnl_LIBS} \
41			     ${libnetfilter_conntrack_LIBS}
42xtables_nft_multi_CFLAGS  += -DENABLE_NFTABLES -DENABLE_IPV4 -DENABLE_IPV6
43xtables_nft_multi_SOURCES += nft.c nft.h \
44			     nft-arp.c nft-ipv4.c nft-ipv6.c \
45			     nft-bridge.c nft-bridge.h \
46			     nft-cache.c nft-cache.h \
47			     nft-chain.c nft-chain.h \
48			     nft-cmd.c nft-cmd.h \
49			     nft-ruleparse.c nft-ruleparse.h \
50			     nft-ruleparse-arp.c nft-ruleparse-bridge.c \
51			     nft-ruleparse-ipv4.c nft-ruleparse-ipv6.c \
52			     nft-shared.c nft-shared.h \
53			     xtables-monitor.c \
54			     xtables.c xtables-arp.c xtables-eb.c \
55			     xtables-standalone.c xtables-eb-standalone.c \
56			     xtables-translate.c xtables-eb-translate.c \
57			     xtables-save.c xtables-restore.c
58endif
59
60sbin_PROGRAMS    = xtables-legacy-multi
61if ENABLE_NFTABLES
62sbin_PROGRAMS	+= xtables-nft-multi
63endif
64man_MANS         = iptables.8 iptables-restore.8 iptables-save.8 \
65                   iptables-xml.1 ip6tables.8 ip6tables-restore.8 \
66                   ip6tables-save.8 iptables-extensions.8 \
67                   iptables-apply.8 ip6tables-apply.8
68
69dist_sbin_SCRIPTS = iptables-apply
70dist_pkgdata_DATA = iptables.xslt
71
72if ENABLE_NFTABLES
73man_MANS	+= iptables-translate.8 ip6tables-translate.8 \
74		   iptables-restore-translate.8 ip6tables-restore-translate.8 \
75		   xtables-monitor.8 ebtables-translate.8
76
77dist_man_MANS	 = xtables-nft.8 xtables-translate.8 xtables-legacy.8 \
78		   arptables-nft.8 arptables-nft-restore.8 arptables-nft-save.8 \
79		   ebtables-nft.8
80endif
81CLEANFILES       = ${man_MANS} iptables-extensions.8.tmpl
82
83vx_bin_links   = iptables-xml
84if ENABLE_IPV4
85v4_sbin_links  = iptables-legacy iptables-legacy-restore iptables-legacy-save \
86		 iptables iptables-restore iptables-save
87endif
88if ENABLE_IPV6
89v6_sbin_links  = ip6tables-legacy ip6tables-legacy-restore ip6tables-legacy-save \
90		 ip6tables ip6tables-restore ip6tables-save
91endif
92if ENABLE_NFTABLES
93x_sbin_links  = iptables-nft iptables-nft-restore iptables-nft-save \
94		ip6tables-nft ip6tables-nft-restore ip6tables-nft-save \
95		iptables-translate ip6tables-translate ebtables-translate \
96		iptables-restore-translate ip6tables-restore-translate \
97		arptables-nft arptables \
98		arptables-nft-restore arptables-restore \
99		arptables-nft-save arptables-save \
100		ebtables-nft ebtables \
101		ebtables-nft-restore ebtables-restore \
102		ebtables-nft-save ebtables-save \
103		xtables-monitor
104endif
105
106iptables-extensions.8: iptables-extensions.8.tmpl ../extensions/matches.man ../extensions/targets.man
107	${AM_VERBOSE_GEN} sed \
108		-e '/@MATCH@/ r ../extensions/matches.man' \
109		-e '/@TARGET@/ r ../extensions/targets.man' $< >$@;
110
111iptables-translate.8 ip6tables-translate.8 iptables-restore-translate.8 ip6tables-restore-translate.8 ebtables-translate.8:
112	${AM_VERBOSE_GEN} echo '.so man8/xtables-translate.8' >$@
113
114ip6tables.8 ip6tables-apply.8 ip6tables-restore.8 ip6tables-save.8:
115	${AM_VERBOSE_GEN} echo "$@" | sed 's|^ip6|.so man8/ip|' >$@
116
117pkgconfig_DATA = xtables.pc
118
119# Using if..fi avoids an ugly "error (ignored)" message :)
120install-exec-hook:
121	-if test -z "${DESTDIR}"; then /sbin/ldconfig; fi;
122	${INSTALL} -dm0755 "${DESTDIR}${bindir}";
123	for i in ${vx_bin_links}; do ${LN_S} -f "${sbindir}/xtables-legacy-multi" "${DESTDIR}${bindir}/$$i"; done;
124	for i in ${v4_sbin_links}; do ${LN_S} -f xtables-legacy-multi "${DESTDIR}${sbindir}/$$i"; done;
125	for i in ${v6_sbin_links}; do ${LN_S} -f xtables-legacy-multi "${DESTDIR}${sbindir}/$$i"; done;
126	for i in ${x_sbin_links}; do ${LN_S} -f xtables-nft-multi "${DESTDIR}${sbindir}/$$i"; done;
127	${LN_S} -f iptables-apply "${DESTDIR}${sbindir}/ip6tables-apply"
128
129uninstall-hook:
130	dir=${DESTDIR}${bindir}; { \
131		test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
132	} || { \
133		test -z "${vx_bin_links}" || ( \
134			cd "$$dir" && rm -f ${vx_bin_links} \
135		) \
136	}
137	dir=${DESTDIR}${sbindir}; { \
138		test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
139	} || { \
140		test -z "${v4_sbin_links}" || ( \
141			cd "$$dir" && rm -f ${v4_sbin_links} \
142		); \
143		test -z "${v6_sbin_links}" || ( \
144			cd "$$dir" && rm -f ${v6_sbin_links} \
145		); \
146		test -z "${x_sbin_links}" || ( \
147			cd "$$dir" && rm -f ${x_sbin_links} \
148		); \
149		( cd "$$dir" && rm -f ip6tables-apply ); \
150	}
151
152EXTRA_DIST = tests
153