GNUmakefile.in 9.59 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
# -*- Makefile -*-

top_builddir = @top_builddir@
builddir     = @builddir@
top_srcdir   = @top_srcdir@
srcdir       = @srcdir@
ksourcedir   = @ksourcedir@
prefix       = @prefix@
exec_prefix  = @exec_prefix@
libdir       = @libdir@
libexecdir   = @libexecdir@
xtlibdir     = @xtlibdir@

14
AR                 = @AR@
15
16
17
18
19
20
21
22
23
24
CC                 = @CC@
CCLD               = ${CC}
CFLAGS             = @CFLAGS@
CPPFLAGS           = @CPPFLAGS@
LDFLAGS            = @LDFLAGS@
regular_CFLAGS     = @regular_CFLAGS@
regular_CPPFLAGS   = @regular_CPPFLAGS@
kinclude_CPPFLAGS  = @kinclude_CPPFLAGS@

AM_CFLAGS       = ${regular_CFLAGS}
25
AM_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@
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
AM_DEPFLAGS     = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
AM_LDFLAGS      = @noundef_LDFLAGS@

ifeq (${V},)
AM_LIBTOOL_SILENT = --silent
AM_VERBOSE_CC     = @echo "  CC      " $@;
AM_VERBOSE_CCLD   = @echo "  CCLD    " $@;
AM_VERBOSE_CXX    = @echo "  CXX     " $@;
AM_VERBOSE_CXXLD  = @echo "  CXXLD   " $@;
AM_VERBOSE_AR     = @echo "  AR      " $@;
AM_VERBOSE_GEN    = @echo "  GEN     " $@;
endif

#
#	Wildcard module list
#
pfx_build_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(sort $(wildcard ${srcdir}/libxt_*.c)))
43
44
@ENABLE_NFTABLES_TRUE@ pfb_build_mod := $(patsubst ${srcdir}/libebt_%.c,%,$(sort $(wildcard ${srcdir}/libebt_*.c)))
@ENABLE_NFTABLES_TRUE@ pfa_build_mod := $(patsubst ${srcdir}/libarpt_%.c,%,$(sort $(wildcard ${srcdir}/libarpt_*.c)))
45
46
47
pfx_symlinks  := NOTRACK state
@ENABLE_IPV4_TRUE@ pf4_build_mod := $(patsubst ${srcdir}/libipt_%.c,%,$(sort $(wildcard ${srcdir}/libipt_*.c)))
@ENABLE_IPV6_TRUE@ pf6_build_mod := $(patsubst ${srcdir}/libip6t_%.c,%,$(sort $(wildcard ${srcdir}/libip6t_*.c)))
48
49
50
51
52
pfx_build_mod := $(filter-out @blacklist_modules@ @blacklist_x_modules@,${pfx_build_mod})
pfb_build_mod := $(filter-out @blacklist_modules@ @blacklist_b_modules@,${pfb_build_mod})
pfa_build_mod := $(filter-out @blacklist_modules@ @blacklist_a_modules@,${pfa_build_mod})
pf4_build_mod := $(filter-out @blacklist_modules@ @blacklist_4_modules@,${pf4_build_mod})
pf6_build_mod := $(filter-out @blacklist_modules@ @blacklist_6_modules@,${pf6_build_mod})
53
pfx_objs      := $(patsubst %,libxt_%.o,${pfx_build_mod})
54
55
pfb_objs      := $(patsubst %,libebt_%.o,${pfb_build_mod})
pfa_objs      := $(patsubst %,libarpt_%.o,${pfa_build_mod})
56
57
pf4_objs      := $(patsubst %,libipt_%.o,${pf4_build_mod})
pf6_objs      := $(patsubst %,libip6t_%.o,${pf6_build_mod})
58
pfx_solibs    := $(patsubst %,libxt_%.so,${pfx_build_mod})
59
60
pfb_solibs    := $(patsubst %,libebt_%.so,${pfb_build_mod})
pfa_solibs    := $(patsubst %,libarpt_%.so,${pfa_build_mod})
61
62
pf4_solibs    := $(patsubst %,libipt_%.so,${pf4_build_mod})
pf6_solibs    := $(patsubst %,libip6t_%.so,${pf6_build_mod})
63
pfx_symlink_files := $(patsubst %,libxt_%.so,${pfx_symlinks})
64
65
66
67
68


#
# Building blocks
#
69
targets := libext.a libext4.a libext6.a libext_ebt.a libext_arpt.a matches.man targets.man
70
71
targets_install :=
@ENABLE_STATIC_TRUE@ libext_objs := ${pfx_objs}
72
73
@ENABLE_STATIC_TRUE@ libext_ebt_objs := ${pfb_objs}
@ENABLE_STATIC_TRUE@ libext_arpt_objs := ${pfa_objs}
74
75
@ENABLE_STATIC_TRUE@ libext4_objs := ${pf4_objs}
@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
81

.SECONDARY:

82
.PHONY: all install uninstall clean distclean FORCE
83
84
85

all: ${targets}

86
install: ${targets_install} ${symlinks_install}
87
	@mkdir -p "${DESTDIR}${xtlibdir}";
88
89
90
91
92
93
	if test -n "${targets_install}"; then \
		install -pm0755 ${targets_install} "${DESTDIR}${xtlibdir}/"; \
	fi;
	if test -n "${symlinks_install}"; then \
		cp -P ${symlinks_install} "${DESTDIR}${xtlibdir}/"; \
	fi;
94

95
96
97
98
99
100
101
102
103
104
105
106
107
uninstall:
	dir=${DESTDIR}${xtlibdir}; { \
		test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
	} || { \
		test -z "${targets_install}" || ( \
			cd "$$dir" && rm -f ${targets_install} \
		); \
		test -z "${symlinks_install}" || ( \
			cd "$$dir" && rm -f ${symlinks_install} \
		); \
		rmdir -p --ignore-fail-on-non-empty "$$dir"; \
	}

108
clean:
109
	rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c initextb.c initexta.c;
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	rm -f .*.d .*.dd;

distclean: clean

init%.o: init%.c
	${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<;

-include .*.d


#
#	Shared libraries
#
lib%.so: lib%.oo
124
	${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} ${LDFLAGS} -shared -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD};
125
126

lib%.oo: ${srcdir}/lib%.c
127
	${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
128
129
130
131
132
133
134
135
136

libxt_NOTRACK.so: libxt_CT.so
	ln -fs $< $@
libxt_state.so: libxt_conntrack.so
	ln -fs $< $@

# Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD
xt_RATEEST_LIBADD   = -lm
xt_statistic_LIBADD = -lm
137
xt_connlabel_LIBADD = @libnetfilter_conntrack_LIBS@
138
139
140
141
142
143
144
145
146
147
148
149
150
151

#
#	Static bits
#
#	If static building is disabled, libext*.a will still be generated,
#	but will be empty. This is good since we can do with less case
#	handling code in the Makefiles.
#
lib%.o: ${srcdir}/lib%.c
	${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<;

libext.a: initext.o ${libext_objs}
	${AM_VERBOSE_AR} ${AR} crs $@ $^;

152
153
154
155
156
157
libext_ebt.a: initextb.o ${libext_ebt_objs}
	${AM_VERBOSE_AR} ${AR} crs $@ $^;

libext_arpt.a: initexta.o ${libext_arpt_objs}
	${AM_VERBOSE_AR} ${AR} crs $@ $^;

158
159
160
161
162
163
164
libext4.a: initext4.o ${libext4_objs}
	${AM_VERBOSE_AR} ${AR} crs $@ $^;

libext6.a: initext6.o ${libext6_objs}
	${AM_VERBOSE_AR} ${AR} crs $@ $^;

initext_func  := $(addprefix xt_,${pfx_build_mod})
165
166
initextb_func := $(addprefix ebt_,${pfb_build_mod})
initexta_func := $(addprefix arpt_,${pfa_build_mod})
167
168
169
170
171
172
173
174
initext4_func := $(addprefix ipt_,${pf4_build_mod})
initext6_func := $(addprefix ip6t_,${pf6_build_mod})

.initext.dd: FORCE
	@echo "${initext_func}" >$@.tmp; \
	cmp -s $@ $@.tmp || mv $@.tmp $@; \
	rm -f $@.tmp;

175
176
177
178
179
180
181
182
183
184
.initextb.dd: FORCE
	@echo "${initextb_func}" >$@.tmp; \
	cmp -s $@ $@.tmp || mv $@.tmp $@; \
	rm -f $@.tmp;

.initexta.dd: FORCE
	@echo "${initexta_func}" >$@.tmp; \
	cmp -s $@ $@.tmp || mv $@.tmp $@; \
	rm -f $@.tmp;

185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
.initext4.dd: FORCE
	@echo "${initext4_func}" >$@.tmp; \
	cmp -s $@ $@.tmp || mv $@.tmp $@; \
	rm -f $@.tmp;

.initext6.dd: FORCE
	@echo "${initext6_func}" >$@.tmp; \
	cmp -s $@ $@.tmp || mv $@.tmp $@; \
	rm -f $@.tmp;

initext.c: .initext.dd
	${AM_VERBOSE_GEN}
	@( \
	echo "" >$@; \
	for i in ${initext_func}; do \
		echo "extern void lib$${i}_init(void);" >>$@; \
	done; \
	echo "void init_extensions(void);" >>$@; \
	echo "void init_extensions(void)" >>$@; \
	echo "{" >>$@; \
	for i in ${initext_func}; do \
		echo  " ""lib$${i}_init();" >>$@; \
	done; \
	echo "}" >>$@; \
	);

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
initextb.c: .initextb.dd
	${AM_VERBOSE_GEN}
	@( \
	echo "" >$@; \
	for i in ${initextb_func}; do \
		echo "extern void lib$${i}_init(void);" >>$@; \
	done; \
	echo "void init_extensionsb(void);" >>$@; \
	echo "void init_extensionsb(void)" >>$@; \
	echo "{" >>$@; \
	for i in ${initextb_func}; do \
		echo  " ""lib$${i}_init();" >>$@; \
	done; \
	echo "}" >>$@; \
	);

initexta.c: .initexta.dd
	${AM_VERBOSE_GEN}
	@( \
	echo "" >$@; \
	for i in ${initexta_func}; do \
		echo "extern void lib$${i}_init(void);" >>$@; \
	done; \
	echo "void init_extensionsa(void);" >>$@; \
	echo "void init_extensionsa(void)" >>$@; \
	echo "{" >>$@; \
	for i in ${initexta_func}; do \
		echo  " ""lib$${i}_init();" >>$@; \
	done; \
	echo "}" >>$@; \
	);

243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
initext4.c: .initext4.dd
	${AM_VERBOSE_GEN}
	@( \
	echo "" >$@; \
	for i in ${initext4_func}; do \
		echo "extern void lib$${i}_init(void);" >>$@; \
	done; \
	echo "void init_extensions4(void);" >>$@; \
	echo "void init_extensions4(void)" >>$@; \
	echo "{" >>$@; \
	for i in ${initext4_func}; do \
		echo  " ""lib$${i}_init();" >>$@; \
	done; \
	echo "}" >>$@; \
	);

initext6.c: .initext6.dd
	${AM_VERBOSE_GEN}
	@( \
	echo "" >$@; \
	for i in ${initext6_func}; do \
		echo "extern void lib$${i}_init(void);" >>$@; \
	done; \
	echo "void init_extensions6(void);" >>$@; \
	echo "void init_extensions6(void)" >>$@; \
	echo "{" >>$@; \
	for i in ${initext6_func}; do \
		echo " ""lib$${i}_init();" >>$@; \
	done; \
	echo "}" >>$@; \
	);

#
#	Manual pages
#
ex_matches = $(shell echo ${1} | LC_ALL=POSIX grep -Eo '\b[[:lower:][:digit:]_]+\b')
ex_targets = $(shell echo ${1} | LC_ALL=POSIX grep -Eo '\b[[:upper:][:digit:]_]+\b')
man_run    = \
	${AM_VERBOSE_GEN} \
	for ext in $(sort ${1}); do \
		f="${srcdir}/libxt_$$ext.man"; \
		if [ -f "$$f" ]; then \
			echo -e "\t+ $$f" >&2; \
			echo ".SS $$ext"; \
			cat "$$f" || exit $$?; \
		fi; \
		f="${srcdir}/libip6t_$$ext.man"; \
		if [ -f "$$f" ]; then \
			echo -e "\t+ $$f" >&2; \
			echo ".SS $$ext (IPv6-specific)"; \
			cat "$$f" || exit $$?; \
		fi; \
		f="${srcdir}/libipt_$$ext.man"; \
		if [ -f "$$f" ]; then \
			echo -e "\t+ $$f" >&2; \
			echo ".SS $$ext (IPv4-specific)"; \
			cat "$$f" || exit $$?; \
		fi; \
	done >$@;

303
304
matches.man: .initext.dd .initextb.dd .initexta.dd .initext4.dd .initext6.dd $(wildcard ${srcdir}/lib*.man)
	$(call man_run,$(call ex_matches,${pfx_build_mod} ${pfb_build_mod} ${pfa_build_mod} ${pf4_build_mod} ${pf6_build_mod} ${pfx_symlinks}))
305

306
307
targets.man: .initext.dd .initextb.dd .initexta.dd .initext4.dd .initext6.dd $(wildcard ${srcdir}/lib*.man)
	$(call man_run,$(call ex_targets,${pfx_build_mod} ${pfb_build_mod} ${pfa_build_mod} ${pf4_build_mod} ${pf6_build_mod} ${pfx_symlinks}))