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@ 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))) 43pfb_build_mod := $(patsubst ${srcdir}/libebt_%.c,%,$(sort $(wildcard ${srcdir}/libebt_*.c))) 44pfa_build_mod := $(patsubst ${srcdir}/libarpt_%.c,%,$(sort $(wildcard ${srcdir}/libarpt_*.c))) 45pfx_symlinks := NOTRACK state 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} ${pfx_symlinks}) 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}) 63 64 65# 66# Building blocks 67# 68targets := libext.a libext4.a libext6.a libext_ebt.a libext_arpt.a matches.man targets.man 69targets_install := 70@ENABLE_STATIC_TRUE@ libext_objs := ${pfx_objs} 71@ENABLE_STATIC_TRUE@ libext_ebt_objs := ${pfb_objs} 72@ENABLE_STATIC_TRUE@ libext_arpt_objs := ${pfa_objs} 73@ENABLE_STATIC_TRUE@ libext4_objs := ${pf4_objs} 74@ENABLE_STATIC_TRUE@ libext6_objs := ${pf6_objs} 75@ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs} 76@ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs} 77 78.SECONDARY: 79 80.PHONY: all install clean distclean FORCE 81 82all: ${targets} 83 84install: ${targets_install} 85 @mkdir -p "${DESTDIR}${xtlibdir}"; 86 if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi; 87 88clean: 89 rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c initextb.c initexta.c; 90 rm -f .*.d .*.dd; 91 92distclean: clean 93 94init%.o: init%.c 95 ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<; 96 97-include .*.d 98 99 100# 101# Shared libraries 102# 103lib%.so: lib%.oo 104 ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD}; 105 106lib%.oo: ${srcdir}/lib%.c 107 ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; 108 109libxt_NOTRACK.so: libxt_CT.so 110 ln -fs $< $@ 111libxt_state.so: libxt_conntrack.so 112 ln -fs $< $@ 113 114# Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD 115xt_RATEEST_LIBADD = -lm 116xt_statistic_LIBADD = -lm 117xt_connlabel_LIBADD = @libnetfilter_conntrack_LIBS@ 118 119# 120# Static bits 121# 122# If static building is disabled, libext*.a will still be generated, 123# but will be empty. This is good since we can do with less case 124# handling code in the Makefiles. 125# 126lib%.o: ${srcdir}/lib%.c 127 ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<; 128 129libext.a: initext.o ${libext_objs} 130 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 131 132libext_ebt.a: initextb.o ${libext_ebt_objs} 133 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 134 135libext_arpt.a: initexta.o ${libext_arpt_objs} 136 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 137 138libext4.a: initext4.o ${libext4_objs} 139 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 140 141libext6.a: initext6.o ${libext6_objs} 142 ${AM_VERBOSE_AR} ${AR} crs $@ $^; 143 144initext_func := $(addprefix xt_,${pfx_build_mod}) 145initextb_func := $(addprefix ebt_,${pfb_build_mod}) 146initexta_func := $(addprefix arpt_,${pfa_build_mod}) 147initext4_func := $(addprefix ipt_,${pf4_build_mod}) 148initext6_func := $(addprefix ip6t_,${pf6_build_mod}) 149 150.initext.dd: FORCE 151 @echo "${initext_func}" >$@.tmp; \ 152 cmp -s $@ $@.tmp || mv $@.tmp $@; \ 153 rm -f $@.tmp; 154 155.initextb.dd: FORCE 156 @echo "${initextb_func}" >$@.tmp; \ 157 cmp -s $@ $@.tmp || mv $@.tmp $@; \ 158 rm -f $@.tmp; 159 160.initexta.dd: FORCE 161 @echo "${initexta_func}" >$@.tmp; \ 162 cmp -s $@ $@.tmp || mv $@.tmp $@; \ 163 rm -f $@.tmp; 164 165.initext4.dd: FORCE 166 @echo "${initext4_func}" >$@.tmp; \ 167 cmp -s $@ $@.tmp || mv $@.tmp $@; \ 168 rm -f $@.tmp; 169 170.initext6.dd: FORCE 171 @echo "${initext6_func}" >$@.tmp; \ 172 cmp -s $@ $@.tmp || mv $@.tmp $@; \ 173 rm -f $@.tmp; 174 175initext.c: .initext.dd 176 ${AM_VERBOSE_GEN} 177 @( \ 178 echo "" >$@; \ 179 for i in ${initext_func}; do \ 180 echo "extern void lib$${i}_init(void);" >>$@; \ 181 done; \ 182 echo "void init_extensions(void);" >>$@; \ 183 echo "void init_extensions(void)" >>$@; \ 184 echo "{" >>$@; \ 185 for i in ${initext_func}; do \ 186 echo " ""lib$${i}_init();" >>$@; \ 187 done; \ 188 echo "}" >>$@; \ 189 ); 190 191initextb.c: .initextb.dd 192 ${AM_VERBOSE_GEN} 193 @( \ 194 echo "" >$@; \ 195 for i in ${initextb_func}; do \ 196 echo "extern void lib$${i}_init(void);" >>$@; \ 197 done; \ 198 echo "void init_extensionsb(void);" >>$@; \ 199 echo "void init_extensionsb(void)" >>$@; \ 200 echo "{" >>$@; \ 201 for i in ${initextb_func}; do \ 202 echo " ""lib$${i}_init();" >>$@; \ 203 done; \ 204 echo "}" >>$@; \ 205 ); 206 207initexta.c: .initexta.dd 208 ${AM_VERBOSE_GEN} 209 @( \ 210 echo "" >$@; \ 211 for i in ${initexta_func}; do \ 212 echo "extern void lib$${i}_init(void);" >>$@; \ 213 done; \ 214 echo "void init_extensionsa(void);" >>$@; \ 215 echo "void init_extensionsa(void)" >>$@; \ 216 echo "{" >>$@; \ 217 for i in ${initexta_func}; do \ 218 echo " ""lib$${i}_init();" >>$@; \ 219 done; \ 220 echo "}" >>$@; \ 221 ); 222 223initext4.c: .initext4.dd 224 ${AM_VERBOSE_GEN} 225 @( \ 226 echo "" >$@; \ 227 for i in ${initext4_func}; do \ 228 echo "extern void lib$${i}_init(void);" >>$@; \ 229 done; \ 230 echo "void init_extensions4(void);" >>$@; \ 231 echo "void init_extensions4(void)" >>$@; \ 232 echo "{" >>$@; \ 233 for i in ${initext4_func}; do \ 234 echo " ""lib$${i}_init();" >>$@; \ 235 done; \ 236 echo "}" >>$@; \ 237 ); 238 239initext6.c: .initext6.dd 240 ${AM_VERBOSE_GEN} 241 @( \ 242 echo "" >$@; \ 243 for i in ${initext6_func}; do \ 244 echo "extern void lib$${i}_init(void);" >>$@; \ 245 done; \ 246 echo "void init_extensions6(void);" >>$@; \ 247 echo "void init_extensions6(void)" >>$@; \ 248 echo "{" >>$@; \ 249 for i in ${initext6_func}; do \ 250 echo " ""lib$${i}_init();" >>$@; \ 251 done; \ 252 echo "}" >>$@; \ 253 ); 254 255# 256# Manual pages 257# 258ex_matches = $(shell echo ${1} | LC_ALL=POSIX grep -Eo '\b[[:lower:][:digit:]_]+\b') 259ex_targets = $(shell echo ${1} | LC_ALL=POSIX grep -Eo '\b[[:upper:][:digit:]_]+\b') 260man_run = \ 261 ${AM_VERBOSE_GEN} \ 262 for ext in $(sort ${1}); do \ 263 f="${srcdir}/libxt_$$ext.man"; \ 264 if [ -f "$$f" ]; then \ 265 echo -e "\t+ $$f" >&2; \ 266 echo ".SS $$ext"; \ 267 cat "$$f" || exit $$?; \ 268 fi; \ 269 f="${srcdir}/libip6t_$$ext.man"; \ 270 if [ -f "$$f" ]; then \ 271 echo -e "\t+ $$f" >&2; \ 272 echo ".SS $$ext (IPv6-specific)"; \ 273 cat "$$f" || exit $$?; \ 274 fi; \ 275 f="${srcdir}/libipt_$$ext.man"; \ 276 if [ -f "$$f" ]; then \ 277 echo -e "\t+ $$f" >&2; \ 278 echo ".SS $$ext (IPv4-specific)"; \ 279 cat "$$f" || exit $$?; \ 280 fi; \ 281 done >$@; 282 283matches.man: .initext.dd .initextb.dd .initexta.dd .initext4.dd .initext6.dd $(wildcard ${srcdir}/lib*.man) 284 $(call man_run,$(call ex_matches,${pfx_build_mod} ${pfb_build_mod} ${pfa_build_mod} ${pf4_build_mod} ${pf6_build_mod} ${pfx_symlinks})) 285 286targets.man: .initext.dd .initextb.dd .initexta.dd .initext4.dd .initext6.dd $(wildcard ${srcdir}/lib*.man) 287 $(call man_run,$(call ex_targets,${pfx_build_mod} ${pfb_build_mod} ${pfa_build_mod} ${pf4_build_mod} ${pf6_build_mod} ${pfx_symlinks})) 288