diff --git a/INSTALL b/INSTALL index 4bb442c..818d8ba 100644 --- a/INSTALL +++ b/INSTALL @@ -17,6 +17,13 @@ Prerequirements * kernel-source >= 2.6.19 with prepared output directory +Selecting extensions +==================== + +You can edit the "mconfig" file to select what modules to build and +install. By default, all modules are enabled. + + Configuring and compiling ========================= diff --git a/configure.ac b/configure.ac index 5e3a3a3..567b1de 100644 --- a/configure.ac +++ b/configure.ac @@ -64,4 +64,4 @@ AC_SUBST([regular_CFLAGS xtables_CFLAGS kinclude_CFLAGS]) AC_SUBST([kbuilddir]) AC_SUBST([ksourcedir]) AC_SUBST([xtlibdir]) -AC_OUTPUT([Makefile extensions/Makefile]) +AC_OUTPUT([Makefile extensions/GNUmakefile]) diff --git a/extensions/GNUmakefile.in b/extensions/GNUmakefile.in new file mode 100644 index 0000000..ea48696 --- /dev/null +++ b/extensions/GNUmakefile.in @@ -0,0 +1,90 @@ +# -*- Makefile -*- + +top_srcdir := @top_srcdir@ +srcdir := @srcdir@ +abstop_srcdir := $(realpath ${top_srcdir}) +abssrcdir := $(realpath ${srcdir}) +prefix := @prefix@ +exec_prefix := @exec_prefix@ +libdir := @libdir@ +libexecdir := @libexecdir@ +xtlibdir := @xtlibdir@ +kbuilddir := @kbuilddir@ + +CC := @CC@ +CCLD := ${CC} +CFLAGS := @CFLAGS@ +LDFLAGS := @LDFLAGS@ +regular_CFLAGS := @regular_CFLAGS@ +kinclude_CFLAGS := @kinclude_CFLAGS@ + +AM_CFLAGS := ${regular_CFLAGS} -I${top_srcdir}/include ${kinclude_CFLAGS} +AM_DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ + +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 +# +include ${top_srcdir}/mconfig +pfx_all_mod := $(patsubst ${srcdir}/libxt_%.c,%,$(wildcard ${srcdir}/libxt_*.c)) +pfx_build_mod := $(foreach i,${pfx_all_mod},$(if ${build_${i}},${i},)) +pfx_solibs := $(patsubst %,libxt_%.so,${pfx_build_mod}) + + +# +# Building blocks +# +targets := ${pfx_solibs} +targets_install := ${pfx_solibs} + +.SECONDARY: + +.PHONY: all install clean distclean FORCE + +all: modules ${targets} + +install: modules_install ${targets_install} + @mkdir -p "${DESTDIR}${xtlibdir}"; + install -pm0755 ${targets_install} "${DESTDIR}${xtlibdir}/"; + +clean: clean_modules + rm -f *.oo *.so; + +distclean: clean + rm -f .*.d; + +-include .*.d + + +# +# Call out to kbuild +# +.PHONY: modules modules_install clean_modules + +modules: + make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} modules; + +modules_install: + make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} INSTALL_MOD_PATH=${DESTDIR} modules_install; + +clean_modules: + make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} clean; + + +# +# Shared libraries +# +lib%.so: lib%.oo + ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $<; + +lib%.oo: ${srcdir}/lib%.c + ${AM_VERBOSE_CC} ${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; diff --git a/extensions/Kbuild b/extensions/Kbuild index 8662717..eeb94fa 100644 --- a/extensions/Kbuild +++ b/extensions/Kbuild @@ -1,6 +1,9 @@ # -*- Makefile -*- -obj-m += xt_LOGMARK.o -obj-m += xt_TARPIT.o -obj-m += xt_TEE.o -obj-m += compat_xtables.o +include ${XA_TOPSRCDIR}/mconfig + +obj-m += compat_xtables.o + +obj-${build_LOGMARK} += xt_LOGMARK.o +obj-${build_TARPIT} += xt_TARPIT.o +obj-${build_TEE} += xt_TEE.o diff --git a/extensions/Makefile.am b/extensions/Makefile.am deleted file mode 100644 index df3bf14..0000000 --- a/extensions/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -# -*- Makefile -*- - -AUTOMAKE_OPTIONS = foreign subdir-objects -abssrcdir = $(shell readlink -f ${srcdir}) - -regular_CFLAGS := @regular_CFLAGS@ -xtables_CFLAGS := @xtables_CFLAGS@ -kinclude_CFLAGS := @kinclude_CFLAGS@ -AM_CFLAGS = ${regular_CFLAGS} -I ${top_srcdir}/include \ - ${xtables_CFLAGS} ${kinclude_CFLAGS} \ - -D_INIT=$*_init -AM_LDFLAGS = -module -avoid-version -xtlib_LTLIBRARIES = \ - libxt_LOGMARK.la \ - libxt_TARPIT.la \ - libxt_TEE.la - -# -# Call out to kbuild -# -.PHONY: modules modules_install clean_modules - -all-local: modules - -install-exec-local: modules_install - -clean-local: clean_modules - -modules: - make -C ${kbuilddir} M=${abssrcdir} modules; - -modules_install: - make -C ${kbuilddir} M=${abssrcdir} INSTALL_MOD_PATH=${DESTDIR} modules_install; - -clean_modules: - make -C ${kbuilddir} M=${abssrcdir} clean; diff --git a/mconfig b/mconfig new file mode 100644 index 0000000..fa29bfc --- /dev/null +++ b/mconfig @@ -0,0 +1,8 @@ +# -*- Makefile -*- +# +# Only "build_${name}=m" (build extensions) or "build_${name}=" +# (do not build) are valid! +# +build_LOGMARK=m +build_TARPIT=m +build_TEE=m