From ca2d92df5649c3233ccf5bb3f92d621e461728db Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 10 Dec 2009 13:38:29 -0800 Subject: [PATCH] Rearrange module order for easy placement on external builds You will typically cp -a compat/ to your own build and then cp include/linux/*.h to your own header space on your build as well. Provided on this Makefile is also a hack to let you use include/linux without having to add or mucking the user's header files or directory. Example compat autoconf is also provided. Signed-off-by: Luis R. Rodriguez --- Makefile | 27 ++++---------- compat.h | 28 -------------- compat/Makefile | 21 +++++++++++ compat-2.6.14.c => compat/compat-2.6.14.c | 0 compat-2.6.18.c => compat/compat-2.6.18.c | 0 compat-2.6.19.c => compat/compat-2.6.19.c | 0 compat-2.6.21.c => compat/compat-2.6.21.c | 0 compat-2.6.22.c => compat/compat-2.6.22.c | 0 compat-2.6.23.c => compat/compat-2.6.23.c | 0 compat-2.6.24.c => compat/compat-2.6.24.c | 0 compat-2.6.25.c => compat/compat-2.6.25.c | 0 compat-2.6.26.c => compat/compat-2.6.26.c | 0 compat-2.6.27.c => compat/compat-2.6.27.c | 2 +- compat-2.6.28.c => compat/compat-2.6.28.c | 2 +- compat-2.6.29.c => compat/compat-2.6.29.c | 2 +- compat-2.6.30.c => compat/compat-2.6.30.c | 2 +- compat-2.6.31.c => compat/compat-2.6.31.c | 2 +- compat-2.6.32.c => compat/compat-2.6.32.c | 2 +- main.c => compat/main.c | 0 .../linux/compat-2.6.14.h | 0 .../linux/compat-2.6.18.h | 0 .../linux/compat-2.6.19.h | 0 .../linux/compat-2.6.21.h | 0 .../linux/compat-2.6.22.h | 0 .../linux/compat-2.6.23.h | 0 .../linux/compat-2.6.24.h | 0 .../linux/compat-2.6.25.h | 0 .../linux/compat-2.6.26.h | 0 .../linux/compat-2.6.27.h | 0 .../linux/compat-2.6.28.h | 0 .../linux/compat-2.6.29.h | 0 .../linux/compat-2.6.30.h | 0 .../linux/compat-2.6.31.h | 0 .../linux/compat-2.6.32.h | 0 include/linux/compat-2.6.33.h | 15 ++++++++ include/linux/compat.h | 26 +++++++++++++ include/linux/compat_autoconf.h | 37 +++++++++++++++++++ 37 files changed, 112 insertions(+), 54 deletions(-) delete mode 100644 compat.h create mode 100644 compat/Makefile rename compat-2.6.14.c => compat/compat-2.6.14.c (100%) rename compat-2.6.18.c => compat/compat-2.6.18.c (100%) rename compat-2.6.19.c => compat/compat-2.6.19.c (100%) rename compat-2.6.21.c => compat/compat-2.6.21.c (100%) rename compat-2.6.22.c => compat/compat-2.6.22.c (100%) rename compat-2.6.23.c => compat/compat-2.6.23.c (100%) rename compat-2.6.24.c => compat/compat-2.6.24.c (100%) rename compat-2.6.25.c => compat/compat-2.6.25.c (100%) rename compat-2.6.26.c => compat/compat-2.6.26.c (100%) rename compat-2.6.27.c => compat/compat-2.6.27.c (99%) rename compat-2.6.28.c => compat/compat-2.6.28.c (99%) rename compat-2.6.29.c => compat/compat-2.6.29.c (97%) rename compat-2.6.30.c => compat/compat-2.6.30.c (94%) rename compat-2.6.31.c => compat/compat-2.6.31.c (98%) rename compat-2.6.32.c => compat/compat-2.6.32.c (99%) rename main.c => compat/main.c (100%) rename compat-2.6.14.h => include/linux/compat-2.6.14.h (100%) rename compat-2.6.18.h => include/linux/compat-2.6.18.h (100%) rename compat-2.6.19.h => include/linux/compat-2.6.19.h (100%) rename compat-2.6.21.h => include/linux/compat-2.6.21.h (100%) rename compat-2.6.22.h => include/linux/compat-2.6.22.h (100%) rename compat-2.6.23.h => include/linux/compat-2.6.23.h (100%) rename compat-2.6.24.h => include/linux/compat-2.6.24.h (100%) rename compat-2.6.25.h => include/linux/compat-2.6.25.h (100%) rename compat-2.6.26.h => include/linux/compat-2.6.26.h (100%) rename compat-2.6.27.h => include/linux/compat-2.6.27.h (100%) rename compat-2.6.28.h => include/linux/compat-2.6.28.h (100%) rename compat-2.6.29.h => include/linux/compat-2.6.29.h (100%) rename compat-2.6.30.h => include/linux/compat-2.6.30.h (100%) rename compat-2.6.31.h => include/linux/compat-2.6.31.h (100%) rename compat-2.6.32.h => include/linux/compat-2.6.32.h (100%) create mode 100644 include/linux/compat-2.6.33.h create mode 100644 include/linux/compat.h create mode 100644 include/linux/compat_autoconf.h diff --git a/Makefile b/Makefile index d2c08d1..0433a14 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ export KLIB_BUILD ?= $(KLIB)/build export PWD := $(shell pwd) +# This generates a bunch of CONFIG_COMPAT_KERNEL_22 CONFIG_COMPAT_KERNEL_23 .. etc for +# each kernel release you need an object for. ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) COMPAT_LATEST_VERSION = 32 KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') @@ -16,27 +18,12 @@ COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNE $(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_$(ver)=y)) endif -obj-m += compat.o -#compat-objs := +obj-y += compat/ -compat-y += main.o - -# Compat kernel compatibility code -compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o -compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o -compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o -compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o -compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o -compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o -compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o -compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o -compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o -compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o -compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o -compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o -compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o -compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o -compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o +# This hack lets us put our include path first than the kernel's +# when building our compat modules. Your own makefile would look +# the same. +NOSTDINC_FLAGS := -I$(M)/include/ -include $(M)/include/linux/compat.h $(CFLAGS) modules: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules diff --git a/compat.h b/compat.h deleted file mode 100644 index ceedc47..0000000 --- a/compat.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef LINUX_26_COMPAT_H -#define LINUX_26_COMPAT_H - -#include -#include - -/* - * Each compat file represents compatibility code for new kernel - * code introduced for *that* kernel revision. - */ - -#include "compat-2.6.14.h" -#include "compat-2.6.18.h" -#include "compat-2.6.19.h" -#include "compat-2.6.21.h" -#include "compat-2.6.22.h" -#include "compat-2.6.23.h" -#include "compat-2.6.24.h" -#include "compat-2.6.25.h" -#include "compat-2.6.26.h" -#include "compat-2.6.27.h" -#include "compat-2.6.28.h" -#include "compat-2.6.29.h" -#include "compat-2.6.30.h" -#include "compat-2.6.31.h" -#include "compat-2.6.32.h" - -#endif /* LINUX_26_COMPAT_H */ diff --git a/compat/Makefile b/compat/Makefile new file mode 100644 index 0000000..20d80e2 --- /dev/null +++ b/compat/Makefile @@ -0,0 +1,21 @@ +obj-m += compat.o +#compat-objs := + +compat-y += main.o + +# Compat kernel compatibility code +compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o +compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o +compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o +compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o +compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o +compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o +compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o +compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o +compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o +compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o +compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o +compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o +compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o +compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o +compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o diff --git a/compat-2.6.14.c b/compat/compat-2.6.14.c similarity index 100% rename from compat-2.6.14.c rename to compat/compat-2.6.14.c diff --git a/compat-2.6.18.c b/compat/compat-2.6.18.c similarity index 100% rename from compat-2.6.18.c rename to compat/compat-2.6.18.c diff --git a/compat-2.6.19.c b/compat/compat-2.6.19.c similarity index 100% rename from compat-2.6.19.c rename to compat/compat-2.6.19.c diff --git a/compat-2.6.21.c b/compat/compat-2.6.21.c similarity index 100% rename from compat-2.6.21.c rename to compat/compat-2.6.21.c diff --git a/compat-2.6.22.c b/compat/compat-2.6.22.c similarity index 100% rename from compat-2.6.22.c rename to compat/compat-2.6.22.c diff --git a/compat-2.6.23.c b/compat/compat-2.6.23.c similarity index 100% rename from compat-2.6.23.c rename to compat/compat-2.6.23.c diff --git a/compat-2.6.24.c b/compat/compat-2.6.24.c similarity index 100% rename from compat-2.6.24.c rename to compat/compat-2.6.24.c diff --git a/compat-2.6.25.c b/compat/compat-2.6.25.c similarity index 100% rename from compat-2.6.25.c rename to compat/compat-2.6.25.c diff --git a/compat-2.6.26.c b/compat/compat-2.6.26.c similarity index 100% rename from compat-2.6.26.c rename to compat/compat-2.6.26.c diff --git a/compat-2.6.27.c b/compat/compat-2.6.27.c similarity index 99% rename from compat-2.6.27.c rename to compat/compat-2.6.27.c index 996aab5..7fffe8e 100644 --- a/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -8,7 +8,7 @@ * Compatibility file for Linux wireless for kernels 2.6.27 */ -#include "compat.h" +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) diff --git a/compat-2.6.28.c b/compat/compat-2.6.28.c similarity index 99% rename from compat-2.6.28.c rename to compat/compat-2.6.28.c index a8dfcbb..959a429 100644 --- a/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -8,7 +8,7 @@ * Compatibility file for Linux wireless for kernels 2.6.28. */ -#include "compat.h" +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) diff --git a/compat-2.6.29.c b/compat/compat-2.6.29.c similarity index 97% rename from compat-2.6.29.c rename to compat/compat-2.6.29.c index 664be92..669ad35 100644 --- a/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -8,7 +8,7 @@ * Compatibility file for Linux wireless for kernels 2.6.29. */ -#include "compat.h" +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) diff --git a/compat-2.6.30.c b/compat/compat-2.6.30.c similarity index 94% rename from compat-2.6.30.c rename to compat/compat-2.6.30.c index 6e0d69c..f821918 100644 --- a/compat-2.6.30.c +++ b/compat/compat-2.6.30.c @@ -8,7 +8,7 @@ * Compatibility file for Linux wireless for kernels 2.6.30. */ -#include "compat.h" +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) diff --git a/compat-2.6.31.c b/compat/compat-2.6.31.c similarity index 98% rename from compat-2.6.31.c rename to compat/compat-2.6.31.c index 90b6a41..dc8588f 100644 --- a/compat-2.6.31.c +++ b/compat/compat-2.6.31.c @@ -8,7 +8,7 @@ * Compatibility file for Linux wireless for kernels 2.6.31. */ -#include "compat.h" +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) diff --git a/compat-2.6.32.c b/compat/compat-2.6.32.c similarity index 99% rename from compat-2.6.32.c rename to compat/compat-2.6.32.c index 5d085e6..22c2c19 100644 --- a/compat-2.6.32.c +++ b/compat/compat-2.6.32.c @@ -8,7 +8,7 @@ * Compatibility file for Linux wireless for kernels 2.6.32. */ -#include "compat.h" +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) diff --git a/main.c b/compat/main.c similarity index 100% rename from main.c rename to compat/main.c diff --git a/compat-2.6.14.h b/include/linux/compat-2.6.14.h similarity index 100% rename from compat-2.6.14.h rename to include/linux/compat-2.6.14.h diff --git a/compat-2.6.18.h b/include/linux/compat-2.6.18.h similarity index 100% rename from compat-2.6.18.h rename to include/linux/compat-2.6.18.h diff --git a/compat-2.6.19.h b/include/linux/compat-2.6.19.h similarity index 100% rename from compat-2.6.19.h rename to include/linux/compat-2.6.19.h diff --git a/compat-2.6.21.h b/include/linux/compat-2.6.21.h similarity index 100% rename from compat-2.6.21.h rename to include/linux/compat-2.6.21.h diff --git a/compat-2.6.22.h b/include/linux/compat-2.6.22.h similarity index 100% rename from compat-2.6.22.h rename to include/linux/compat-2.6.22.h diff --git a/compat-2.6.23.h b/include/linux/compat-2.6.23.h similarity index 100% rename from compat-2.6.23.h rename to include/linux/compat-2.6.23.h diff --git a/compat-2.6.24.h b/include/linux/compat-2.6.24.h similarity index 100% rename from compat-2.6.24.h rename to include/linux/compat-2.6.24.h diff --git a/compat-2.6.25.h b/include/linux/compat-2.6.25.h similarity index 100% rename from compat-2.6.25.h rename to include/linux/compat-2.6.25.h diff --git a/compat-2.6.26.h b/include/linux/compat-2.6.26.h similarity index 100% rename from compat-2.6.26.h rename to include/linux/compat-2.6.26.h diff --git a/compat-2.6.27.h b/include/linux/compat-2.6.27.h similarity index 100% rename from compat-2.6.27.h rename to include/linux/compat-2.6.27.h diff --git a/compat-2.6.28.h b/include/linux/compat-2.6.28.h similarity index 100% rename from compat-2.6.28.h rename to include/linux/compat-2.6.28.h diff --git a/compat-2.6.29.h b/include/linux/compat-2.6.29.h similarity index 100% rename from compat-2.6.29.h rename to include/linux/compat-2.6.29.h diff --git a/compat-2.6.30.h b/include/linux/compat-2.6.30.h similarity index 100% rename from compat-2.6.30.h rename to include/linux/compat-2.6.30.h diff --git a/compat-2.6.31.h b/include/linux/compat-2.6.31.h similarity index 100% rename from compat-2.6.31.h rename to include/linux/compat-2.6.31.h diff --git a/compat-2.6.32.h b/include/linux/compat-2.6.32.h similarity index 100% rename from compat-2.6.32.h rename to include/linux/compat-2.6.32.h diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h new file mode 100644 index 0000000..528627e --- /dev/null +++ b/include/linux/compat-2.6.33.h @@ -0,0 +1,15 @@ +#ifndef LINUX_26_33_COMPAT_H +#define LINUX_26_33_COMPAT_H + +#include +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) + +#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ +/* source: include/linux/if.h */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ + +#endif /* LINUX_26_33_COMPAT_H */ diff --git a/include/linux/compat.h b/include/linux/compat.h new file mode 100644 index 0000000..bea00c9 --- /dev/null +++ b/include/linux/compat.h @@ -0,0 +1,26 @@ +#ifndef LINUX_26_COMPAT_H +#define LINUX_26_COMPAT_H + +#include +#include +#include + +/* + * Each compat file represents compatibility code for new kernel + * code introduced for *that* kernel revision. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat_autoconf.h b/include/linux/compat_autoconf.h new file mode 100644 index 0000000..813755c --- /dev/null +++ b/include/linux/compat_autoconf.h @@ -0,0 +1,37 @@ +#ifndef COMPAT_AUTOCONF_INCLUDED +#define COMPAT_AUTOCONF_INCLUDED + +/* + * This is an example of a compat autconf header file that gets + * automatically generated by your projet. You will only need this + * if you are working with a lot of config options. + * + * Your project will likely just override this, or leave this as-is. + */ + +/* + * Example automatically generated C config: don't edit + * Thu Dec 10 10:34:11 PST 2009 + * compat-wireless-2.6: master-2009-11-19-5-gb4fd4dd + * linux-2.6: next-20091208 + */ +//#define COMPAT_PROJECT_FOO_RELEASE "master-2009-11-19-5-gb4fd4dd" +//#define COMPAT_UPSTREAM_FOO_KERNEL_RELEASE "next-20091208" + +/* Example kernel version minimum requirement */ +//#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) +//#error Compat-wireless requirement: Linux >= 2,6,10 +//#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) */ + +/* Example hard requirement */ +//#error Compat-wireless requirement: CONFIG_WIRELESS_EXT must be enabled in your kernel +//#endif /* CONFIG_WIRELESS_EXT */ + +/* + * Example of how to match your external modules kconfig options into this. + * You'll need something to generate this for you. + */ +//#ifndef CONFIG_FOO_BAR +//#define CONFIG_FOO_BAR 1 + +#endif /* COMPAT_AUTOCONF_INCLUDED */ -- 2.41.0