3 top_builddir := @top_builddir@
5 top_srcdir := @top_srcdir@
7 ksourcedir := @ksourcedir@
9 exec_prefix := @exec_prefix@
11 libexecdir := @libexecdir@
12 xtlibdir := @xtlibdir@
18 regular_CFLAGS := @regular_CFLAGS@
19 kinclude_CFLAGS := @kinclude_CFLAGS@
21 AM_CFLAGS := ${regular_CFLAGS} -I${top_builddir}/include -I${top_srcdir}/include ${kinclude_CFLAGS}
22 AM_DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
25 AM_LIBTOOL_SILENT = --silent
26 AM_VERBOSE_CC = @echo " CC " $@;
27 AM_VERBOSE_CCLD = @echo " CCLD " $@;
28 AM_VERBOSE_CXX = @echo " CXX " $@;
29 AM_VERBOSE_CXXLD = @echo " CXXLD " $@;
30 AM_VERBOSE_AR = @echo " AR " $@;
31 AM_VERBOSE_GEN = @echo " GEN " $@;
35 # Wildcard module list
37 pfx_build_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(wildcard ${srcdir}/libxt_*.c))
38 pf4_build_mod := $(patsubst ${srcdir}/libipt_%.c,%,$(wildcard ${srcdir}/libipt_*.c))
39 pf6_build_mod := $(patsubst ${srcdir}/libip6t_%.c,%,$(wildcard ${srcdir}/libip6t_*.c))
40 pfx_build_mod := $(filter-out @blacklist_modules@,${pfx_build_mod})
41 pf4_build_mod := $(filter-out @blacklist_modules@,${pf4_build_mod})
42 pf6_build_mod := $(filter-out @blacklist_modules@,${pf6_build_mod})
43 pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_mod})
44 pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_mod})
45 pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_mod})
46 pfx_solibs := $(patsubst %,libxt_%.so,${pfx_build_mod})
47 pf4_solibs := $(patsubst %,libipt_%.so,${pf4_build_mod})
48 pf6_solibs := $(patsubst %,libip6t_%.so,${pf6_build_mod})
54 targets := libext4.a libext6.a matches4.man matches6.man \
55 targets4.man targets6.man
57 @ENABLE_STATIC_TRUE@ libext4_objs := ${pfx_objs} ${pf4_objs}
58 @ENABLE_STATIC_TRUE@ libext6_objs := ${pfx_objs} ${pf6_objs}
59 @ENABLE_SHARED_TRUE@ targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
60 @ENABLE_SHARED_TRUE@ targets_install += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
64 .PHONY: all install clean distclean FORCE
68 install: ${targets_install}
69 @mkdir -p "${DESTDIR}${xtlibdir}";
70 if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
73 rm -f *.o *.oo *.so *.a {matches,targets}[46].man initext4.c initext6.c;
78 init%.o: ${srcdir}/init%.c
79 ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<;
88 ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $<;
90 lib%.oo: ${srcdir}/lib%.c
91 ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
97 # If static building is disabled, libext*.a will still be generated,
98 # but will be empty. This is good since we can do with less case
99 # handling code in the Makefiles.
101 lib%.o: ${srcdir}/lib%.c
102 ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<;
104 libext4.a: initext4.o ${libext4_objs}
105 ${AM_VERBOSE_AR} ${AR} crs $@ $^;
107 libext6.a: initext6.o ${libext6_objs}
108 ${AM_VERBOSE_AR} ${AR} crs $@ $^;
110 initext_func := $(addprefix xt_,${pfx_build_mod}) $(addprefix ipt_,${pf4_build_mod})
111 initext6_func := $(addprefix xt_,${pfx_build_mod}) $(addprefix ip6t_,${pf6_build_mod})
114 @echo "${initext_func}" >$@.tmp; \
115 cmp -s $@ $@.tmp || mv $@.tmp $@; \
119 @echo "${initext6_func}" >$@.tmp; \
120 cmp -s $@ $@.tmp || mv $@.tmp $@; \
123 initext4.c: .initext4.dd
127 for i in ${initext_func}; do \
128 echo "extern void lib$${i}_init(void);" >>$@; \
130 echo "void init_extensions(void);" >>$@; \
131 echo "void init_extensions(void)" >>$@; \
133 for i in ${initext_func}; do \
134 echo " ""lib$${i}_init();" >>$@; \
139 initext6.c: .initext6.dd
143 for i in ${initext6_func}; do \
144 echo "extern void lib$${i}_init(void);" >>$@; \
146 echo "void init_extensions(void);" >>$@; \
147 echo "void init_extensions(void)" >>$@; \
149 for i in ${initext6_func}; do \
150 echo " ""lib$${i}_init();" >>$@; \
158 ex_matches = $(sort $(shell echo $(1) | grep -Eo '\b[a-z0-9]+\b'))
159 ex_targets = $(sort $(shell echo $(1) | grep -Eo '\b[A-Z0-9]+\b'))
162 for ext in $(1); do \
163 f="${srcdir}/libxt_$$ext.man"; \
164 if [ -f "$$f" ]; then \
169 f="${srcdir}/libipt_$$ext.man"; \
170 if [ -f "$$f" ]; then \
175 f="${srcdir}/libip6t_$$ext.man"; \
176 if [ -f "$$f" ]; then \
183 matches4.man: .initext4.dd $(wildcard ${srcdir}/lib*.man)
184 $(call man_run,$(call ex_matches,${pfx_build_mod} ${pf4_build_mod}))
186 matches6.man: .initext6.dd $(wildcard ${srcdir}/lib*.man)
187 $(call man_run,$(call ex_matches,${pfx_build_mod} ${pf6_build_mod}))
189 targets4.man: .initext4.dd $(wildcard ${srcdir}/lib*.man)
190 $(call man_run,$(call ex_targets,${pfx_build_mod} ${pf4_build_mod}))
192 targets6.man: .initext6.dd $(wildcard ${srcdir}/lib*.man)
193 $(call man_run,$(call ex_targets,${pfx_build_mod} ${pf6_build_mod}))