1# -*- Makefile -*- 2 3top_builddir = @top_builddir@ 4builddir = @builddir@ 5top_srcdir = @top_srcdir@ 6srcdir = @srcdir@ 7ksourcedir = @ksourcedir@ 8prefix = @prefix@ 9exec_prefix = @exec_prefix@ 10libdir = @libdir@ 11libexecdir = @libexecdir@ 12xtlibdir = @xtlibdir@ 13 14AR = @AR@ 15CC = @CC@ 16CCLD = ${CC} 17CFLAGS = @CFLAGS@ 18CPPFLAGS = @CPPFLAGS@ 19LDFLAGS = @LDFLAGS@ 20regular_CFLAGS = @regular_CFLAGS@ 21regular_CPPFLAGS = @regular_CPPFLAGS@ 22kinclude_CPPFLAGS = @kinclude_CPPFLAGS@ 23 24AM_CFLAGS = ${regular_CFLAGS} 25AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_builddir} -I${top_srcdir}/include -I${top_srcdir} ${kinclude_CPPFLAGS} ${CPPFLAGS} @libnetfilter_conntrack_CFLAGS@ @libnftnl_CFLAGS@ 26AM_DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ 27AM_LDFLAGS = @noundef_LDFLAGS@ @regular_LDFLAGS@ 28 29ifeq (${V},) 30AM_LIBTOOL_SILENT = --silent 31AM_VERBOSE_CC = @echo " CC " $@; 32AM_VERBOSE_CCLD = @echo " CCLD " $@; 33AM_VERBOSE_CXX = @echo " CXX " $@; 34AM_VERBOSE_CXXLD = @echo " CXXLD " $@; 35AM_VERBOSE_AR = @echo " AR " $@; 36AM_VERBOSE_GEN = @echo " GEN " $@; 37endif 38 39# 40# Wildcard module list 41# 42pfx_build_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(sort $(wildcard ${srcdir}/libxt_*.c))) 43@ENABLE_NFTABLES_TRUE@ pfb_build_mod := $(patsubst ${srcdir}/libebt_%.c,%,$(sort $(wildcard ${srcdir}/libebt_*.c))) 44@ENABLE_NFTABLES_TRUE@ pfa_build_mod := $(patsubst ${srcdir}/libarpt_%.c,%,$(sort $(wildcard ${srcdir}/libarpt_*.c))) 45pfx_symlinks := NOTRACK state REDIRECT MASQUERADE SNAT DNAT 46@ENABLE_IPV4_TRUE@ pf4_build_mod := $(patsubst ${srcdir}/libipt_%.c,%,$(sort $(wildcard ${srcdir}/libipt_*.c))) 47@ENABLE_IPV6_TRUE@ pf6_build_mod := $(patsubst ${srcdir}/libip6t_%.c,%,$(sort $(wildcard ${srcdir}/libip6t_*.c))) 48pfx_build_mod := $(filter-out @blacklist_modules@ @blacklist_x_modules@,${pfx_build_mod}) 49pfb_build_mod := $(filter-out @blacklist_modules@ @blacklist_b_modules@,${pfb_build_mod}) 50pfa_build_mod := $(filter-out @blacklist_modules@ @blacklist_a_modules@,${pfa_build_mod}) 51pf4_build_mod := $(filter-out @blacklist_modules@ @blacklist_4_modules@,${pf4_build_mod}) 52pf6_build_mod := $(filter-out @blacklist_modules@ @blacklist_6_modules@,${pf6_build_mod}) 53pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_mod}) 54pfb_objs := $(patsubst %,libebt_%.o,${pfb_build_mod}) 55pfa_objs := $(patsubst %,libarpt_%.o,${pfa_build_mod}) 56pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_mod}) 57pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_mod}) 58pfx_solibs := $(patsubst %,libxt_%.so,${pfx_build_mod}) 59pfb_solibs := $(patsubst %,libebt_%.so,${pfb_build_mod}) 60pfa_solibs := $(patsubst %,libarpt_%.so,${pfa_build_mod}) 61pf4_solibs := $(patsubst %,libipt_%.so,${pf4_build_mod}) 62pf6_solibs := $(patsubst %,libip6t_%.so,${pf6_build_mod}) 63pfx_symlink_files := $(patsubst %,libxt_%.so,${pfx_symlinks}) 64 65 66# 67# Building blocks 68# 69targets := libext.a libext4.a libext6.a libext_ebt.a libext_arpt.a matches.man targets.man 70targets_install := 71@ENABLE_STATIC_TRUE@ libext_objs := ${pfx_objs} 72@ENABLE_STATIC_TRUE@ libext_ebt_objs := ${pfb_objs} 73@ENABLE_STATIC_TRUE@ libext_arpt_objs := ${pfa_objs} 74@ENABLE_STATIC_TRUE@ libext4_objs := ${pf4_objs} 75@ENABLE_STATIC_TRUE@ libext6_objs := ${pf6_objs} 76@ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs} ${pfx_symlink_files} 77@ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs} 78@ENABLE_STATIC_FALSE@ symlinks_install := ${pfx_symlink_files} 79 80.SECONDARY: 81 82.PHONY: all install uninstall clean distclean FORCE dvi check installcheck 83 84all: ${targets} 85 86install: ${targets_install} ${symlinks_install} 87 @mkdir -p "${DESTDIR}${xtlibdir}"; 88 if test -n "${targets_install}"; then \ 89 install -pm0755 ${targets_install} "${DESTDIR}${xtlibdir}/"; \ 90 fi; 91 if test -n "${symlinks_install}"; then \ 92 cp -P ${symlinks_install} "${DESTDIR}${xtlibdir}/"; \ 93 fi; 94 95uninstall: 96 dir=${DESTDIR}${xtlibdir}; { \ 97 test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \ 98 } || { \ 99 test -z "${targets_install}" || ( \ 100 cd "$$dir" && rm -f ${targets_install} \ 101 ); \ 102 test -z "${symlinks_install}" || ( \ 103 cd "$$dir" && rm -f ${symlinks_install} \ 104 ); \ 105 rmdir -p --ignore-fail-on-non-empty "$$dir"; \ 106 } 107 108clean: 109 rm -f *.o *.oo *.so *.a matches.man targets.man 110 rm -f initext.c initext4.c initext6.c initextb.c initexta.c 111 rm -f .*.d .*.dd; 112 113distclean: clean 114 115init%.o: init%.c 116 ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<; 117 118-include .*.d 119 120 121# 122# Shared libraries 123# 124lib%.so: lib%.oo 125 ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} ${LDFLAGS} -shared -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD}; 126 127lib%.oo: ${srcdir}/lib%.c 128 ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; 129 130libxt_NOTRACK.so: libxt_CT.so 131 ln -fs $< $@ 132libxt_state.so: libxt_conntrack.so 133 ln -fs $< $@ 134libxt_REDIRECT.so: libxt_NAT.so 135 ln -fs $< $@ 136libxt_MASQUERADE.so: libxt_NAT.so 137 ln -fs $< $@ 138libxt_SNAT.so: libxt_NAT.so 139 ln -fs $< $@ 140libxt_DNAT.so: libxt_NAT.so 141 ln -fs $< $@ 142 143# Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD 144xt_RATEEST_LIBADD = -lm 145xt_statistic_LIBADD = -lm 146xt_connlabel_LIBADD = @libnetfilter_conntrack_LIBS@ 147 148# 149# Static bits 150# 151# If static building is disabled, libext*.a will still be generated, 152# but will be empty. This is good since we can do with less case 153# handling code in the Makefiles. 154# 155lib%.o: ${srcdir}/lib%.c 156 ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<; 157 158libext.a: initext.o ${libext_objs} 159 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 160 161libext_ebt.a: initextb.o ${libext_ebt_objs} 162 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 163 164libext_arpt.a: initexta.o ${libext_arpt_objs} 165 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 166 167libext4.a: initext4.o ${libext4_objs} 168 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 169 170libext6.a: initext6.o ${libext6_objs} 171 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 172 173initext_func := $(addprefix xt_,${pfx_build_mod}) 174initextb_func := $(addprefix ebt_,${pfb_build_mod}) 175initexta_func := $(addprefix arpt_,${pfa_build_mod}) 176initext4_func := $(addprefix ipt_,${pf4_build_mod}) 177initext6_func := $(addprefix ip6t_,${pf6_build_mod}) 178 179initexts := ext exta extb ext4 ext6 180initext_depfiles = $(patsubst %,.init%.dd,${initexts}) 181initext_sources = $(patsubst %,init%.c,${initexts}) 182 183${initext_depfiles}: FORCE 184 @echo "$(value $(patsubst .%.dd,%,$@)_func)" >[email protected]; \ 185 cmp -s $@ [email protected] || mv [email protected] $@; \ 186 rm -f [email protected]; 187 188${initext_sources}: %.c: .%.dd 189 ${AM_VERBOSE_GEN} 190 @( \ 191 initext_func="$(value $(basename $@)_func)"; \ 192 funcname="init_extensions$(patsubst initext%.c,%,$@)"; \ 193 echo "" >$@; \ 194 for i in $${initext_func}; do \ 195 echo "extern void lib$${i}_init(void);" >>$@; \ 196 done; \ 197 echo "void $${funcname}(void);" >>$@; \ 198 echo "void $${funcname}(void)" >>$@; \ 199 echo "{" >>$@; \ 200 for i in $${initext_func}; do \ 201 echo " ""lib$${i}_init();" >>$@; \ 202 done; \ 203 echo "}" >>$@; \ 204 ); 205 206# 207# Manual pages 208# 209ex_matches = $(shell echo ${1} | LC_ALL=POSIX grep -Eo '\b[[:lower:][:digit:]_]+\b') 210ex_targets = $(shell echo ${1} | LC_ALL=POSIX grep -Eo '\b[[:upper:][:digit:]_]+\b') 211man_run = \ 212 ${AM_VERBOSE_GEN} \ 213 for ext in $(sort ${1}); do \ 214 f="${srcdir}/libxt_$$ext.man"; \ 215 if [ -f "$$f" ]; then \ 216 echo -e "\t+ $$f" >&2; \ 217 echo ".SS $$ext"; \ 218 cat "$$f" || exit $$?; \ 219 fi; \ 220 f="${srcdir}/libip6t_$$ext.man"; \ 221 if [ -f "$$f" ]; then \ 222 echo -e "\t+ $$f" >&2; \ 223 echo ".SS $$ext (IPv6-specific)"; \ 224 cat "$$f" || exit $$?; \ 225 fi; \ 226 f="${srcdir}/libipt_$$ext.man"; \ 227 if [ -f "$$f" ]; then \ 228 echo -e "\t+ $$f" >&2; \ 229 echo ".SS $$ext (IPv4-specific)"; \ 230 cat "$$f" || exit $$?; \ 231 fi; \ 232 done >$@; 233 234matches.man: ${initext_depfiles} $(wildcard ${srcdir}/lib*.man) 235 $(call man_run,$(call ex_matches,${pfx_build_mod} ${pfb_build_mod} ${pfa_build_mod} ${pf4_build_mod} ${pf6_build_mod} ${pfx_symlinks})) 236 237targets.man: ${initext_depfiles} $(wildcard ${srcdir}/lib*.man) 238 $(call man_run,$(call ex_targets,${pfx_build_mod} ${pfb_build_mod} ${pfa_build_mod} ${pf4_build_mod} ${pf6_build_mod} ${pfx_symlinks})) 239 240dist_initext_src = $(addprefix $(srcdir)/,${initext_sources}) 241dist_sources = $(filter-out ${dist_initext_src},$(wildcard $(srcdir)/*.[ch])) 242 243distdir: 244 mkdir -p $(distdir) 245 cp -p ${dist_sources} $(distdir)/ 246 cp -p $(wildcard ${srcdir}/lib*.man) $(distdir)/ 247 cp -p $(wildcard ${srcdir}/*.t ${srcdir}/*.txlate) $(distdir)/ 248 249dvi: 250check: all 251installcheck: 252