Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 1 | # -*- Makefile -*- |
| 2 | |
Jan Engelhardt | ac21a5c | 2008-05-12 10:28:34 +0200 | [diff] [blame] | 3 | top_builddir := @top_builddir@ |
| 4 | builddir := @builddir@ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 5 | top_srcdir := @top_srcdir@ |
| 6 | srcdir := @srcdir@ |
| 7 | ksourcedir := @ksourcedir@ |
| 8 | prefix := @prefix@ |
| 9 | exec_prefix := @exec_prefix@ |
| 10 | libdir := @libdir@ |
| 11 | libexecdir := @libexecdir@ |
Jan Engelhardt | 21b41ee | 2008-02-11 01:02:00 +0100 | [diff] [blame] | 12 | xtlibdir := @xtlibdir@ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 13 | |
| 14 | CC := @CC@ |
| 15 | CCLD := ${CC} |
| 16 | CFLAGS := @CFLAGS@ |
| 17 | LDFLAGS := @LDFLAGS@ |
| 18 | regular_CFLAGS := @regular_CFLAGS@ |
Jan Engelhardt | fb6209a | 2008-01-29 13:32:07 +0000 | [diff] [blame] | 19 | kinclude_CFLAGS := @kinclude_CFLAGS@ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 20 | |
Jan Engelhardt | ac21a5c | 2008-05-12 10:28:34 +0200 | [diff] [blame] | 21 | AM_CFLAGS := ${regular_CFLAGS} -I${top_builddir}/include -I${top_srcdir}/include ${kinclude_CFLAGS} |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 22 | AM_DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ |
| 23 | |
| 24 | ifeq (${V},) |
| 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 " $@; |
| 32 | endif |
| 33 | |
| 34 | # |
| 35 | # Wildcard module list |
| 36 | # |
Jan Engelhardt | ed342ed | 2008-02-13 21:35:59 +0100 | [diff] [blame] | 37 | pfx_build_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(wildcard ${srcdir}/libxt_*.c)) |
Jan Engelhardt | a094eb0 | 2009-04-03 22:37:49 +0200 | [diff] [blame] | 38 | @ENABLE_IPV4_TRUE@ pf4_build_mod := $(patsubst ${srcdir}/libipt_%.c,%,$(wildcard ${srcdir}/libipt_*.c)) |
Jan Engelhardt | 8e58613 | 2009-04-03 22:28:34 +0200 | [diff] [blame] | 39 | @ENABLE_IPV6_TRUE@ pf6_build_mod := $(patsubst ${srcdir}/libip6t_%.c,%,$(wildcard ${srcdir}/libip6t_*.c)) |
Jan Engelhardt | 2c570e7 | 2008-06-05 19:54:48 +0200 | [diff] [blame] | 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}) |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 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}) |
| 49 | |
| 50 | |
| 51 | # |
| 52 | # Building blocks |
| 53 | # |
| 54 | targets := libext4.a libext6.a matches4.man matches6.man \ |
| 55 | targets4.man targets6.man |
| 56 | targets_install := |
| 57 | @ENABLE_STATIC_TRUE@ libext4_objs := ${pfx_objs} ${pf4_objs} |
| 58 | @ENABLE_STATIC_TRUE@ libext6_objs := ${pfx_objs} ${pf6_objs} |
Jan Engelhardt | b79ec69 | 2009-07-23 17:41:21 +0200 | [diff] [blame] | 59 | @ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs} |
| 60 | @ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs} |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 61 | |
| 62 | .SECONDARY: |
| 63 | |
| 64 | .PHONY: all install clean distclean FORCE |
| 65 | |
| 66 | all: ${targets} |
| 67 | |
| 68 | install: ${targets_install} |
Jan Engelhardt | 21b41ee | 2008-02-11 01:02:00 +0100 | [diff] [blame] | 69 | @mkdir -p "${DESTDIR}${xtlibdir}"; |
Jan Engelhardt | e145621 | 2008-06-12 12:10:47 +0200 | [diff] [blame] | 70 | if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi; |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 71 | |
| 72 | clean: |
| 73 | rm -f *.o *.oo *.so *.a {matches,targets}[46].man initext4.c initext6.c; |
| 74 | |
| 75 | distclean: clean |
Jan Engelhardt | fb6209a | 2008-01-29 13:32:07 +0000 | [diff] [blame] | 76 | rm -f .*.d .*.dd; |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 77 | |
Jan Engelhardt | 7963845 | 2008-08-13 14:43:56 +0200 | [diff] [blame] | 78 | init%.o: init%.c |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 79 | ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<; |
| 80 | |
| 81 | -include .*.d |
| 82 | |
| 83 | |
| 84 | # |
| 85 | # Shared libraries |
| 86 | # |
| 87 | lib%.so: lib%.oo |
| 88 | ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $<; |
| 89 | |
| 90 | lib%.oo: ${srcdir}/lib%.c |
Jan Engelhardt | c924621 | 2008-02-11 00:29:36 +0100 | [diff] [blame] | 91 | ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 92 | |
| 93 | |
| 94 | # |
| 95 | # Static bits |
| 96 | # |
| 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. |
| 100 | # |
| 101 | lib%.o: ${srcdir}/lib%.c |
Jan Engelhardt | c924621 | 2008-02-11 00:29:36 +0100 | [diff] [blame] | 102 | ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<; |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 103 | |
| 104 | libext4.a: initext4.o ${libext4_objs} |
| 105 | ${AM_VERBOSE_AR} ${AR} crs $@ $^; |
| 106 | |
| 107 | libext6.a: initext6.o ${libext6_objs} |
| 108 | ${AM_VERBOSE_AR} ${AR} crs $@ $^; |
| 109 | |
| 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}) |
| 112 | |
| 113 | .initext4.dd: FORCE |
| 114 | @echo "${initext_func}" >$@.tmp; \ |
| 115 | cmp -s $@ $@.tmp || mv $@.tmp $@; \ |
| 116 | rm -f $@.tmp; |
| 117 | |
| 118 | .initext6.dd: FORCE |
| 119 | @echo "${initext6_func}" >$@.tmp; \ |
| 120 | cmp -s $@ $@.tmp || mv $@.tmp $@; \ |
| 121 | rm -f $@.tmp; |
| 122 | |
| 123 | initext4.c: .initext4.dd |
| 124 | ${AM_VERBOSE_GEN} |
| 125 | @( \ |
| 126 | echo "" >$@; \ |
| 127 | for i in ${initext_func}; do \ |
| 128 | echo "extern void lib$${i}_init(void);" >>$@; \ |
| 129 | done; \ |
Thomas Jacob | f858d37 | 2008-05-20 17:17:02 +0200 | [diff] [blame] | 130 | echo "void init_extensions(void);" >>$@; \ |
| 131 | echo "void init_extensions(void)" >>$@; \ |
| 132 | echo "{" >>$@; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 133 | for i in ${initext_func}; do \ |
Thomas Jacob | f858d37 | 2008-05-20 17:17:02 +0200 | [diff] [blame] | 134 | echo " ""lib$${i}_init();" >>$@; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 135 | done; \ |
| 136 | echo "}" >>$@; \ |
| 137 | ); |
| 138 | |
| 139 | initext6.c: .initext6.dd |
| 140 | ${AM_VERBOSE_GEN} |
| 141 | @( \ |
| 142 | echo "" >$@; \ |
| 143 | for i in ${initext6_func}; do \ |
| 144 | echo "extern void lib$${i}_init(void);" >>$@; \ |
| 145 | done; \ |
Thomas Jacob | f858d37 | 2008-05-20 17:17:02 +0200 | [diff] [blame] | 146 | echo "void init_extensions(void);" >>$@; \ |
| 147 | echo "void init_extensions(void)" >>$@; \ |
| 148 | echo "{" >>$@; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 149 | for i in ${initext6_func}; do \ |
Thomas Jacob | f858d37 | 2008-05-20 17:17:02 +0200 | [diff] [blame] | 150 | echo " ""lib$${i}_init();" >>$@; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 151 | done; \ |
| 152 | echo "}" >>$@; \ |
| 153 | ); |
| 154 | |
| 155 | # |
| 156 | # Manual pages |
| 157 | # |
Maciej Zenczykowski | 8d6492d | 2011-04-04 15:29:40 +0200 | [diff] [blame^] | 158 | ex_matches = $(sort $(shell echo $(1) | LC_ALL=POSIX grep -Eo '\b[[:alnum:]_]+\b')) |
| 159 | ex_targets = $(sort $(shell echo $(1) | LC_ALL=POSIX grep -Eo '\b[[:alnum:]_]+\b')) |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 160 | man_run = \ |
| 161 | ${AM_VERBOSE_GEN} \ |
| 162 | for ext in $(1); do \ |
| 163 | f="${srcdir}/libxt_$$ext.man"; \ |
Jan Engelhardt | cdcfd88 | 2009-06-01 11:52:07 +0200 | [diff] [blame] | 164 | cf="${srcdir}/libxt_$$ext.c"; \ |
| 165 | if [ -f "$$f" ] && grep -Eq "$(3)|NFPROTO_UNSPEC" "$$cf"; then \ |
| 166 | echo -e "\t+ $$f" >&2; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 167 | echo ".SS $$ext"; \ |
Jan Engelhardt | a3f1013 | 2010-12-11 03:35:48 +0100 | [diff] [blame] | 168 | cat "$$f" || exit $$?; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 169 | continue; \ |
| 170 | fi; \ |
Jan Engelhardt | 0ff6b46 | 2009-02-17 15:05:29 +0100 | [diff] [blame] | 171 | f="${srcdir}/lib$(2)t_$$ext.man"; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 172 | if [ -f "$$f" ]; then \ |
Jan Engelhardt | cdcfd88 | 2009-06-01 11:52:07 +0200 | [diff] [blame] | 173 | echo -e "\t+ $$f" >&2; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 174 | echo ".SS $$ext"; \ |
Jan Engelhardt | a3f1013 | 2010-12-11 03:35:48 +0100 | [diff] [blame] | 175 | cat "$$f" || exit $$?; \ |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 176 | continue; \ |
| 177 | fi; \ |
| 178 | done >$@; |
| 179 | |
Jan Engelhardt | a99cb44 | 2008-01-29 13:33:23 +0000 | [diff] [blame] | 180 | matches4.man: .initext4.dd $(wildcard ${srcdir}/lib*.man) |
Jan Engelhardt | c304d77 | 2009-05-26 13:21:55 +0200 | [diff] [blame] | 181 | $(call man_run,$(call ex_matches,${pfx_build_mod} ${pf4_build_mod}),ip,NFPROTO_IPV4) |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 182 | |
Jan Engelhardt | a99cb44 | 2008-01-29 13:33:23 +0000 | [diff] [blame] | 183 | matches6.man: .initext6.dd $(wildcard ${srcdir}/lib*.man) |
Jan Engelhardt | c304d77 | 2009-05-26 13:21:55 +0200 | [diff] [blame] | 184 | $(call man_run,$(call ex_matches,${pfx_build_mod} ${pf6_build_mod}),ip6,NFPROTO_IPV6) |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 185 | |
Jan Engelhardt | a99cb44 | 2008-01-29 13:33:23 +0000 | [diff] [blame] | 186 | targets4.man: .initext4.dd $(wildcard ${srcdir}/lib*.man) |
Jan Engelhardt | c304d77 | 2009-05-26 13:21:55 +0200 | [diff] [blame] | 187 | $(call man_run,$(call ex_targets,${pfx_build_mod} ${pf4_build_mod}),ip,NFPROTO_IPV4) |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 188 | |
Jan Engelhardt | a99cb44 | 2008-01-29 13:33:23 +0000 | [diff] [blame] | 189 | targets6.man: .initext6.dd $(wildcard ${srcdir}/lib*.man) |
Jan Engelhardt | c304d77 | 2009-05-26 13:21:55 +0200 | [diff] [blame] | 190 | $(call man_run,$(call ex_targets,${pfx_build_mod} ${pf6_build_mod}),ip6,NFPROTO_IPV6) |