]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
build: enable automake for extensions/ directory
authorJan Engelhardt <jengelh@medozas.de>
Sun, 20 Sep 2009 16:55:16 +0000 (18:55 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Wed, 23 Sep 2009 22:59:59 +0000 (00:59 +0200)
Because we are likely to be having more userspace programs soon, and
reproducing manual makefiles is a bad idea, make extensions/ ready
for automake traversal. The build pattern now is:

1.  toplevel Makefile.am starts off with extensions/Makefile.am

2.  Makefile.am

    a.  builds programs in current directory

    b.  runs Kbuild
        - only from extensions/Makefile.am
          (so it does not get reinvoked from case 2cII)
        - Kbuild recurses on its own

    c.  runs Mbuild
        I.  builds iptables shared libraries in current directory
        II. runs Makefile.am in each subdir (goto step 2.)

13 files changed:
.gitignore
INSTALL
Makefile.am
Makefile.extra [new file with mode: 0644]
Makefile.iptrules.in [new file with mode: 0644]
Makefile.mans.in [new file with mode: 0644]
configure.ac
extensions/GNUmakefile.in [deleted file]
extensions/Kbuild
extensions/Makefile.am [new file with mode: 0644]
extensions/Mbuild
extensions/ipset/Makefile.am
extensions/ipset/Mbuild [new file with mode: 0644]

index 37ce3168f4511ba4cc54d7e069299c26dd770686..13da62fd35572621393df49e02bb7b5fb55f2620 100644 (file)
@@ -10,6 +10,12 @@ GNUmakefile
 
 /downloads
 
+/Makefile.iptrules
+/Makefile.mans
+/.*.lst
+/matches.man
+/targets.man
+
 /aclocal.m4
 /autom4te*.cache
 /compile
diff --git a/INSTALL b/INSTALL
index 483d52631e0cc1d0a7b5ef543ffefff0d697df6c..0b30e0626973cd37994eebb8e26c5c3935140279 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -46,6 +46,9 @@ Configuring and compiling
        /lib/modules/$(running version)/build, which usually points to
        the right directory. (If not, you need to install something.)
 
+       For RPM building, it should be /usr/src/linux-obj/...
+       or whatever location the distro makes use of.
+
 --with-xtables=
 
        Specifies the path to the directory where we may find
@@ -55,11 +58,11 @@ Configuring and compiling
        include/xtables.h. (The latter to support both standard
        /usr/include and the iptables source root.)
 
---with-libxtdir=
+--with-xtlibdir=
 
        Specifies the path to where the newly built extensions should
        be installed when `make install` is run. It uses the same
-       default as the Xtables package, ${libexecdir}/xtables.
+       default as the Xtables/iptables package, ${libexecdir}/xtables.
 
 If you want to enable debugging, use
 
@@ -72,15 +75,10 @@ much easier.)
 Build-time options
 ==================
 
-V= controls the kernel's make verbosity.
+V= controls the verbosity of make commands.
 V=0    "silent" (output filename)
 V=1    "verbose" (entire gcc command line)
 
-VU= controls the Xt-a make verbosity.
-VU=0   output filename
-VU=1   output filename and source file
-VU=2   entire gcc command line
-
 
 Note to distribution packagers
 ==============================
index f03174ac7d7fcc5d5c05918237bc4278cb64f923..de6fb6bbaea9840b145a6c48c6fd5888e92981e5 100644 (file)
@@ -5,16 +5,16 @@ SUBDIRS          = extensions
 
 man_MANS := xtables-addons.8
 
-xtables-addons.8: ${srcdir}/xtables-addons.8.in extensions/matches.man extensions/targets.man
-       ${am__verbose_GEN}sed -e '/@MATCHES@/ r extensions/matches.man' -e '/@TARGET@/ r extensions/targets.man' $< >$@;
+.PHONY: FORCE
+FORCE:
 
-extensions/%:
-       ${MAKE} ${AM_MAKEFLAGS} -C $(@D) $(@F)
+xtables-addons.8: FORCE
+       ${MAKE} -f Makefile.mans all;
 
-install-exec-local:
+install-exec-hook:
        depmod -a || :;
 
-config.status: extensions/GNUmakefile.in
+config.status: Makefile.iptrules.in
 
 .PHONY: tarball
 tarball:
diff --git a/Makefile.extra b/Makefile.extra
new file mode 100644 (file)
index 0000000..f689774
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- Makefile -*-
+# AUTOMAKE
+
+XA_SRCDIR = ${srcdir}
+XA_TOPSRCDIR = ${top_srcdir}
+XA_ABSTOPSRCDIR = ${abs_top_srcdir}
+export XA_SRCDIR
+export XA_TOPSRCDIR
+export XA_ABSTOPSRCDIR
+
+_mcall = ${MAKE} -f ${top_builddir}/Makefile.iptrules
+
+all-local: user-all-local
+
+install-exec-local: user-install-local
+
+clean-local: user-clean-local
+
+user-all-local:
+       ${_mcall} all;
+
+# Have no user-install-data-local ATM
+user-install-local: user-install-exec-local
+
+user-install-exec-local:
+       ${_mcall} install;
+
+user-clean-local:
+       ${_mcall} clean;
diff --git a/Makefile.iptrules.in b/Makefile.iptrules.in
new file mode 100644 (file)
index 0000000..4fcdd02
--- /dev/null
@@ -0,0 +1,59 @@
+# -*- Makefile -*-
+# MANUAL
+
+prefix          = @prefix@
+exec_prefix     = @exec_prefix@
+libexecdir      = @libexecdir@
+xtlibdir        = @xtlibdir@
+
+CC              = @CC@
+CCLD            = ${CC}
+
+regular_CFLAGS  = @regular_CFLAGS@
+xtables_CFLAGS  = @xtables_CFLAGS@
+AM_CFLAGS       = ${regular_CFLAGS} ${xtables_CFLAGS}
+AM_DEPFLAGS     = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
+
+AM_DEFAULT_VERBOSITY = 0
+am__v_CC_0           = @echo "  CC    " $@;
+am__v_CCLD_0         = @echo "  CCLD  " $@;
+am__v_GEN_0          = @echo "  GEN   " $@;
+am__v_SILENT_0       = @
+am__v_CC_            = ${am__v_CC_${AM_DEFAULT_VERBOSITY}}
+am__v_CCLD_          = ${am__v_CCLD_${AM_DEFAULT_VERBOSITY}}
+am__v_GEN_           = ${am__v_GEN_${AM_DEFAULT_VERBOSITY}}
+am__v_SILENT_        = ${am__v_SILENT_${AM_DEFAULT_VERBOSITY}}
+AM_V_CC              = ${am__v_CC_${V}}
+AM_V_CCLD            = ${am__v_CCLD_${V}}
+AM_V_GEN             = ${am__v_GEN_${V}}
+AM_V_silent          = ${am__v_GEN_${V}}
+
+include ${XA_TOPSRCDIR}/mconfig
+-include ${XA_TOPSRCDIR}/mconfig.*
+include ${XA_SRCDIR}/Mbuild
+-include ${XA_SRCDIR}/Mbuild.*
+
+targets := $(filter-out %/,${obj-m})
+subdirs_list := $(filter %/,${obj-m})
+
+.SECONDARY:
+
+.PHONY: all install clean
+
+all: ${targets}
+       @for i in ${subdirs_list}; do ${MAKE} -C $$i; done;
+
+install: ${targets}
+       @for i in ${subdirs_list}; do ${MAKE} -C $$i $@; done;
+       install -dm0755 "${DESTDIR}/${xtlibdir}";
+       install -pm0755 $^ "${DESTDIR}/${xtlibdir}";
+
+clean:
+       @for i in ${subdirs_list}; do ${MAKE} -C $$i $@; done;
+       rm -f *.oo *.so;
+
+lib%.so: lib%.oo
+       ${AM_V_CCLD}${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $<;
+
+%.oo: ${XA_SRCDIR}/%.c
+       ${AM_V_CC}${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
diff --git a/Makefile.mans.in b/Makefile.mans.in
new file mode 100644 (file)
index 0000000..49f447a
--- /dev/null
@@ -0,0 +1,40 @@
+# -*- Makefile -*-
+# MANUAL
+
+srcdir := @srcdir@
+
+wcman_matches := $(shell find "${srcdir}" -name 'libxt_[a-z]*.man')
+wcman_targets := $(shell find "${srcdir}" -name 'libxt_[A-Z]*.man')
+wlist_matches := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_matches})
+wlist_targets := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_targets})
+
+.PHONY: FORCE
+
+FORCE:
+
+.manpages.lst: FORCE
+       @echo "${wlist_targets} ${wlist_matches}" >$@.tmp; \
+       cmp -s $@ $@.tmp || mv $@.tmp $@; \
+       rm -f $@.tmp;
+
+man_run = \
+       ${AM_V_GEN}for ext in $(1); do \
+               name="$${ext%.man}"; \
+               name="$${name\#\#*/libxt_}"; \
+               if [ -f "$$ext" ]; then \
+                       echo ".SS $$name"; \
+                       cat "$$ext"; \
+                       continue; \
+               fi; \
+       done >$@;
+
+all: xtables-addons.8
+
+xtables-addons.8: ${srcdir}/xtables-addons.8.in matches.man targets.man
+       ${AM_V_GEN}sed -e '/@MATCHES@/ r matches.man' -e '/@TARGET@/ r targets.man' $< >$@;
+
+matches.man: .manpages.lst ${wcman_matches}
+       $(call man_run,${wlist_matches})
+
+targets.man: .manpages.lst ${wcman_targets}
+       $(call man_run,${wlist_targets})
index 513fe21a12328f4165f5a55b6bd6e1614bc2f62a..72ba18c94a181fcca062cb6b814c83e092f1f627 100644 (file)
@@ -103,5 +103,6 @@ AC_SUBST([kinclude_CFLAGS])
 AC_SUBST([kbuilddir])
 AC_SUBST([ksourcedir])
 AC_SUBST([xtlibdir])
-AC_CONFIG_FILES([Makefile extensions/GNUmakefile extensions/ipset/Makefile])
+AC_CONFIG_FILES([Makefile Makefile.iptrules Makefile.mans
+       extensions/Makefile extensions/ipset/Makefile])
 AC_OUTPUT
diff --git a/extensions/GNUmakefile.in b/extensions/GNUmakefile.in
deleted file mode 100644 (file)
index c603f0b..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-# -*- Makefile -*-
-
-top_srcdir      := @top_srcdir@
-srcdir          := @srcdir@
-abstop_srcdir   := $(shell readlink -f ${top_srcdir})
-abssrcdir       := $(shell readlink -f ${srcdir})
-
-ifeq (${abstop_srcdir},)
-$(error Path resolution of ${top_srcdir} failed)
-endif
-ifeq (${abssrcdir},)
-$(error Path resolution of ${srcdir} failed)
-endif
-
-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@
-xtables_CFLAGS  := @xtables_CFLAGS@
-
-AM_CFLAGS      := ${regular_CFLAGS} -I${top_srcdir}/include ${xtables_CFLAGS} ${kinclude_CFLAGS}
-AM_DEPFLAGS     = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
-
-VU := 0
-am__v_CC_0     = @echo "  CC      " $@;
-am__v_CCLD_0   = @echo "  CCLD    " $@;
-am__v_GEN_0    = @echo "  GEN     " $@;
-am__v_SILENT_0 = @
-AM_V_CC        = ${am__v_CC_${VU}}
-AM_V_CCLD      = ${am__v_CCLD_${VU}}
-AM_V_GEN       = ${am__v_GEN_${VU}}
-AM_V_silent    = ${am__v_GEN_${VU}}
-
-
-#
-#      Wildcard module list
-#
-include ${top_srcdir}/mconfig
--include ${top_srcdir}/mconfig.*
-include ${srcdir}/Mbuild
--include ${srcdir}/Mbuild.*
--include ${srcdir}/*.Mbuild
-
-
-#
-#      Building blocks
-#
-targets := $(filter-out %/,${obj-m})
-targets_install := ${targets}
-subdirs_list := $(filter %/,${obj-m})
-
-.SECONDARY:
-
-.PHONY: all install clean distclean FORCE
-
-all: subdirs modules user matches.man targets.man
-
-subdirs:
-       @for i in ${subdirs_list}; do ${MAKE} -C $$i; done;
-
-subdirs-install:
-       @for i in ${subdirs_list}; do ${MAKE} -C $$i install; done;
-
-user: ${targets}
-
-install: modules_install subdirs-install ${targets_install}
-       @mkdir -p "${DESTDIR}${xtlibdir}";
-       install -pm0755 ${targets_install} "${DESTDIR}${xtlibdir}/";
-
-clean: clean_modules
-       @for i in ${subdirs_list}; do ${MAKE} -C $$i clean; done;
-       rm -f *.oo *.so;
-
-distclean: clean
-       rm -f .*.d .manpages.lst;
-
--include .*.d
-
-
-#
-#      Call out to kbuild
-#
-.PHONY: modules modules_install clean_modules
-
-modules:
-       ${AM_V_silent}if [ -n "${kbuilddir}" ]; then ${MAKE} -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} modules; fi;
-
-modules_install:
-       ${AM_V_silent}if [ -n "${kbuilddir}" ]; then ${MAKE} -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} INSTALL_MOD_PATH=${DESTDIR} modules_install; fi;
-
-clean_modules:
-       ${AM_V_silent}if [ -n "${kbuilddir}" ]; then ${MAKE} -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} clean; fi;
-
-
-#
-#      Shared libraries
-#
-lib%.so: lib%.oo
-       ${AM_V_CCLD}${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $<;
-
-lib%.oo: ${srcdir}/lib%.c
-       ${AM_V_CC}${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
-
-
-#
-#      Manpages
-#
-wcman_matches := $(wildcard ${srcdir}/libxt_[a-z]*.man)
-wcman_targets := $(wildcard ${srcdir}/libxt_[A-Z]*.man)
-wlist_matches := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_matches})
-wlist_targets := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_targets})
-
-.manpages.lst: FORCE
-       @echo "${wlist_targets} ${wlist_matches}" >$@.tmp; \
-       cmp -s $@ $@.tmp || mv $@.tmp $@; \
-       rm -f $@.tmp;
-
-man_run    = \
-       ${AM_V_GEN}for ext in $(1); do \
-               f="${srcdir}/libxt_$$ext.man"; \
-               if [ -f "$$f" ]; then \
-                       echo ".SS $$ext"; \
-                       cat "$$f"; \
-                       continue; \
-               fi; \
-       done >$@;
-
-matches.man: .manpages.lst ${wcman_matches}
-       $(call man_run,${wlist_matches})
-
-targets.man: .manpages.lst ${wcman_targets}
-       $(call man_run,${wlist_targets})
index 8a2095d8ab7a239363b847101ec74758880d28d0..4ff2ed96f8eb3485ca5452f9c1e5225443b549c0 100644 (file)
@@ -1,7 +1,7 @@
 # -*- Makefile -*-
 
-include ${XA_TOPSRCDIR}/mconfig
--include ${XA_TOPSRCDIR}/mconfig.*
+include ${XA_ABSTOPSRCDIR}/mconfig
+-include ${XA_ABSTOPSRCDIR}/mconfig.*
 
 obj-m                    += compat_xtables.o
 
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
new file mode 100644 (file)
index 0000000..ea56f2c
--- /dev/null
@@ -0,0 +1,24 @@
+# -*- Makefile -*-
+# AUTOMAKE
+
+# Not having Kbuild in Makefile.extra because it will already recurse
+.PHONY: modules modules_install clean_modules
+
+_kcall = ${MAKE} -C ${kbuilddir} M=${abs_srcdir}
+
+modules:
+       ${AM_V_silent}if [ -n "${kbuilddir}" ]; then ${_kcall} modules; fi;
+
+modules_install:
+       ${AM_V_silent}if [ -n "${kbuilddir}" ]; then ${_kcall} INSTALL_MOD_PATH=${DESTDIR} modules_install; fi;
+
+clean_modules:
+       ${AM_V_silent}if [ -n "${kbuilddir}" ]; then ${_kcall} clean; fi;
+
+all-local: modules
+
+install-exec-local: modules_install
+
+clean-local: clean_modules
+
+include ../Makefile.extra
index 21aed3347b68d5e1ea725b9b927ff43c8a3de343..a1fb90100014e80791f2eadc71aa7fec42b39184 100644 (file)
@@ -1,3 +1,5 @@
+# -*- Makefile -*-
+
 obj-${build_ACCOUNT}     += libxt_ACCOUNT.so
 obj-${build_CHAOS}       += libxt_CHAOS.so
 obj-${build_DELUDE}      += libxt_DELUDE.so
index c9607e489bf4c6bfdf1b1f51ee1862c960ef7884..0b2bec9575f0f87d29ef35bd21f4b6926944e5af 100644 (file)
@@ -1,45 +1,9 @@
 # -*- Makefile -*-
 
-AM_CFLAGS       = ${regular_CFLAGS} -DIPSET_LIB_DIR=\"${xtlibdir}\"
+AM_CFLAGS = ${regular_CFLAGS} -DIPSET_LIB_DIR=\"${xtlibdir}\"
 
-sbin_PROGRAMS = ipset
-pkglibexec_LTLIBRARIES = \
-       libipset_iphash.la \
-       libipset_ipmap.la \
-       libipset_ipporthash.la \
-       libipset_ipportiphash.la \
-       libipset_ipportnethash.la \
-       libipset_iptree.la \
-       libipset_iptreemap.la \
-       libipset_macipmap.la \
-       libipset_nethash.la \
-       libipset_portmap.la \
-       libipset_setlist.la
+include ../../Makefile.extra
 
+sbin_PROGRAMS = ipset
 ipset_LDADD   = -ldl
 ipset_LDFLAGS = -rdynamic
-
-module_flags = -avoid-version -module
-
-libipset_iphash_la_SOURCES        = ipset_iphash.c
-libipset_iphash_la_LDFLAGS        = ${module_flags}
-libipset_ipmap_la_SOURCES         = ipset_ipmap.c
-libipset_ipmap_la_LDFLAGS         = ${module_flags}
-libipset_ipporthash_la_SOURCES    = ipset_ipporthash.c
-libipset_ipporthash_la_LDFLAGS    = ${module_flags}
-libipset_ipportiphash_la_SOURCES  = ipset_ipportiphash.c
-libipset_ipportiphash_la_LDFLAGS  = ${module_flags}
-libipset_ipportnethash_la_SOURCES = ipset_ipportnethash.c
-libipset_ipportnethash_la_LDFLAGS = ${module_flags}
-libipset_iptree_la_SOURCES        = ipset_iptree.c
-libipset_iptree_la_LDFLAGS        = ${module_flags}
-libipset_iptreemap_la_SOURCES     = ipset_iptreemap.c
-libipset_iptreemap_la_LDFLAGS     = ${module_flags}
-libipset_macipmap_la_SOURCES      = ipset_macipmap.c
-libipset_macipmap_la_LDFLAGS      = ${module_flags}
-libipset_nethash_la_SOURCES       = ipset_nethash.c
-libipset_nethash_la_LDFLAGS       = ${module_flags}
-libipset_portmap_la_SOURCES       = ipset_portmap.c
-libipset_portmap_la_LDFLAGS       = ${module_flags}
-libipset_setlist_la_SOURCES       = ipset_setlist.c
-libipset_setlist_la_LDFLAGS       = ${module_flags}
diff --git a/extensions/ipset/Mbuild b/extensions/ipset/Mbuild
new file mode 100644 (file)
index 0000000..40c70c2
--- /dev/null
@@ -0,0 +1,7 @@
+# -*- Makefile -*-
+
+obj-m += $(addprefix lib,$(patsubst %.c,%.so,$(notdir \
+       $(wildcard ${XA_SRCDIR}/ipset_*.c))))
+
+libipset_%.oo: ${XA_SRCDIR}/ipset_%.c
+       ${AM_V_CC}${CC} ${AM_DEPFLAGS} ${AM_CFLAGS} -DPIC -fPIC ${CFLAGS} -o $@ -c $<;