From b06c63abed952931e633afe755b459aba18aafdb Mon Sep 17 00:00:00 2001 From: guillemj <> Date: Tue, 6 Feb 2007 04:10:21 +0000 Subject: [PATCH] * kinfo.c: Removed. * kver.c: New file. * Makefile: Include kver.mak. (KVERS): Move this variable to 'kver.mak', which is a generated file. (VERSION_HEADER): New variable to cope with UTS_RELEASE being moved from 'linux/version.h' to 'linux/utsrelease.h' in 2.6.18. (kver, kver.mak): New targets. (KBUILD): New variable. (KVER_MAJOR, KVER_MINOR, BUILD_TYPE, MODULE_TDFX): Likewise, moved from the generated file 'config'. (config, kinfo, kinfo.h): Remove targets. (modules, intstall, clean): Do not depend on config target. (modules, intstall): Depend on sanity target . --- Device3Dfx/ChangeLog | 16 +++++++++++ Device3Dfx/Makefile | 68 ++++++++++++++++++++++---------------------- Device3Dfx/kinfo.c | 67 ------------------------------------------- Device3Dfx/kver.c | 8 ++++++ 4 files changed, 58 insertions(+), 101 deletions(-) delete mode 100644 Device3Dfx/kinfo.c create mode 100644 Device3Dfx/kver.c diff --git a/Device3Dfx/ChangeLog b/Device3Dfx/ChangeLog index 33525b0..c582ebf 100644 --- a/Device3Dfx/ChangeLog +++ b/Device3Dfx/ChangeLog @@ -1,3 +1,19 @@ +2007-02-06 Guillem Jover + + * kinfo.c: Removed. + * kver.c: New file. + * Makefile: Include kver.mak. + (KVERS): Move this variable to 'kver.mak', which is a generated file. + (VERSION_HEADER): New variable to cope with UTS_RELEASE being moved + from 'linux/version.h' to 'linux/utsrelease.h' in 2.6.18. + (kver, kver.mak): New targets. + (KBUILD): New variable. + (KVER_MAJOR, KVER_MINOR, BUILD_TYPE, MODULE_TDFX): Likewise, moved + from the generated file 'config'. + (config, kinfo, kinfo.h): Remove targets. + (modules, intstall, clean): Do not depend on config target. + (modules, intstall): Depend on sanity target . + 2007-02-06 Guillem Jover * Makefile (.PHONY): Add clean_kbuild. Rename modules-legacy, diff --git a/Device3Dfx/Makefile b/Device3Dfx/Makefile index 8e372ab..6144145 100644 --- a/Device3Dfx/Makefile +++ b/Device3Dfx/Makefile @@ -17,13 +17,21 @@ endif KSRC ?= /usr/src/linux KHEADERS ?= $(KSRC)/include -KVERS ?= $(shell ./kinfo --UTS) + +-include kver.mak + MODULES_DIR = $(DESTDIR)/lib/modules/$(KVERS) ALL_CFLAGS := -DMODULE -D__KERNEL__ \ -I$(KHEADERS) -I$(KHEADERS)/asm/mach-default \ $(CFLAGS) +ifneq ($(wildcard $(KHEADERS)/linux/utsrelease.h),) +VERSION_HEADER := $(KHEADERS)/linux/utsrelease.h +else +VERSION_HEADER := $(KHEADERS)/linux/version.h +endif + ############################################################################### # You should never need to change anything below. @@ -31,6 +39,12 @@ NAME := 3dfx all: modules +kver: kver.c + $(CC) -include $(VERSION_HEADER) -x c -o $@ $< + +kver.mak: kver + ./$^ > $@ + # Sanity checks sanity: @( \ @@ -50,43 +64,30 @@ sanity: fi; \ ) -ifeq ($(wildcard config),config) +KVER_MAJOR = $(shell echo "$(KVERS)" | cut -d. -f1 ) +KVER_MINOR = $(shell echo "$(KVERS)" | cut -d. -f2 ) -config: sanity +KBUILD = $(shell [ "$(KVER_MAJOR)" = 2 ] && [ "$(KVER_MINOR)" -ge 6 ] && echo yes ) -include config +help: + echo KVER_MAJOR = $(KVER_MAJOR) + echo KVER_MINOR = $(KVER_MINOR) + echo KBUILD = $(KBUILD) + +ifeq ($(KBUILD),yes) +BUILD_TYPE = kbuild +MODULE_TDFX = kbuild/$(NAME).ko +else +BUILD_TYPE = legacy +MODULE_TDFX = $(NAME).o +endif clean_type = clean_$(BUILD_TYPE) module_type = module_$(BUILD_TYPE) -else - -config: sanity kinfo - @( \ - KVER_MAJOR=`echo $(KVERS) | cut -d. -f1`; \ - KVER_MINOR=`echo $(KVERS) | cut -d. -f2`; \ - if [ $$KVER_MAJOR = 2 -a $$KVER_MINOR -ge 6 ]; then \ - echo BUILD_TYPE = kbuild; \ - echo MODULE_TDFX = kbuild/$(NAME).ko; \ - else \ - echo BUILD_TYPE = legacy; \ - echo MODULE_TDFX = $(NAME).o; \ - fi; \ - ) > config - @$(MAKE) $(MAKECMDGOALS) - -endif - -kinfo: kinfo.c - $(CC) -I$(KHEADERS) -o kinfo kinfo.c - -kinfo.h: kinfo - @echo Generating kernel information header. - @./kinfo - ############################################################################### -modules: config $(module_type) +modules: sanity $(module_type) module_legacy: $(NAME).o @@ -98,7 +99,7 @@ module_kbuild: ############################################################################### -install: config install_modules +install: sanity install_modules @( \ if [ -e $(MODULES_DIR)/modules.dep ]; then \ indep=`grep '$(NAME)/$(MODULE_TDFX):' $(MODULES_DIR)/modules.dep`; \ @@ -128,9 +129,8 @@ install_modules: modules ############################################################################### # This is for debugging purposes by the developers: -clean: config $(clean_type) - rm -f kinfo kinfo.h - rm -f config +clean: $(clean_type) + rm -f kver.mak kver clean_legacy: rm -f *.ko *.o *.mod.* .*.mod.* .*.cmd diff --git a/Device3Dfx/kinfo.c b/Device3Dfx/kinfo.c deleted file mode 100644 index 908c65c..0000000 --- a/Device3Dfx/kinfo.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - kinfo.c: A small program that includes several kernel heades - and builds a header defining options for 3dfx_driver.c. - - 1999/12/22 Joseph Kain - - * Initial version -*/ - -#include - -/* These include files will bring in the information we need */ -#include -#include - - -int -main (int argc, char **argv) -{ - /* Here is the strategy. The old Makefile would have grepped the kernel - * headers and put these defines on the command line. Now we include - * the kernel headers and extract the information. Then we create a - * new header with all of the options we need. */ - - if (argc == 1) - { - FILE *f = fopen ("kinfo.h", "w"); - FILE *p = NULL; - int result; - char temp[1000]; - -#ifdef CONFIG_MTRR - /* It is not enough to just check if the kernel supports MTRRs, if the - * processor doesn't have MTRRs then its possible (and likely) that - * the kernel was still compiled with MTRR support. So we also have to - * check the processor has MTRRs. */ - - result = system ("grep mtrr /proc/cpuinfo > /dev/null"); - - /* See if grep found anything */ - if (result == 0) /* Grep reported a match */ - { - fprintf (f, "#define HAVE_MTRR\n"); - } - -#endif - -#ifdef CONFIG_SMP - fprintf (f, "#define __SMP__\n"); -#endif - -#ifdef CONFIG_MODVERSIONS - fprintf (f, "#define MODVERSIONS\n"); -#endif - - fclose (f); - } - else - { - if (strcmp (argv[1], "--UTS") == 0) - { - printf ("%s", UTS_RELEASE); - } - } -} - - diff --git a/Device3Dfx/kver.c b/Device3Dfx/kver.c new file mode 100644 index 0000000..c51a7d5 --- /dev/null +++ b/Device3Dfx/kver.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + printf("KVERS = %s\n", UTS_RELEASE); + return 0; +} +