From d545384a2b719f84a9a27ca7502f05325a49e646 Mon Sep 17 00:00:00 2001 From: Rik Faith Date: Mon, 17 Jan 2000 10:27:29 +0000 Subject: Try a more complex (and more correct?) method for finding kernel inlcude files --- linux/Makefile.linux | 50 +++++++++++++++++++++++++++++++------------------- linux/picker.c | 2 ++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/linux/Makefile.linux b/linux/Makefile.linux index b91d5984..63092770 100644 --- a/linux/Makefile.linux +++ b/linux/Makefile.linux @@ -1,6 +1,6 @@ # Makefile -- For the Direct Rendering Manager module (drm) # Created: Mon Jan 4 09:26:53 1999 by faith@precisioninsight.com -# Revised: Thu Jan 13 09:53:33 2000 by faith@precisioninsight.com +# Revised: Mon Jan 17 05:25:12 2000 by faith@precisioninsight.com # # Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. # All rights reserved. @@ -70,27 +70,39 @@ VERSION := $(shell uname -r) A := /usr/src/linux-$(VERSION)/include B := /usr/src/linux/include C := /usr/include -# This detection seems to be broken. -#TREE := $(shell \ -# if grep -q $(VERSION) $A/linux/version.h; then echo $A; \ -# elif grep -q $(VERSION) $B/linux/version.h; then echo $B; \ -# elif grep -q $(VERSION) $C/linux/version.h; then echo $C; \ -# else echo 0; fi) -# I'm simplifying it -TREE := $(shell \ - if [ -d $A ] ; then echo $A; \ - elif [ -d $B ] ; then echo $B; \ - elif [ -d $C ] ; then echo $C; \ - else echo 0; fi) - - -ifeq "$TREE" "0" -all:; echo Error: Could not locate kernel tree + +V := $(shell gcc -E -nostdinc -I$A picker.c 2>/dev/null \ + | grep -s 'RELEASE = ' | cut -d' ' -f3) +ifeq ($(V),"$(VERSION)") +TREE := $A +else + V := $(shell gcc -E -nostdinc -I$B picker.c 2>/dev/null \ + | grep -s 'RELEASE = ' | cut -d' ' -f3) +ifeq ($(V),"$(VERSION)") + TREE := $B +else + V := $(shell gcc -E -nostdinc -I$C picker.c 2>/dev/null \ + | grep -s 'RELEASE = ' | cut -d' ' -f3) +ifeq ($(V),"$(VERSION)") + TREE := $C +else + TREE := 0 +endif +endif +endif + +# To override this determination, pass the path on the make command line: +# make TREE=/usr/my-kernel-tree/include +# or hardcode a value for TREE here: +# TREE:=/usr/include + +ifeq ($(TREE),0) +all:; @echo Error: Could not locate kernel tree in $A $B $C else SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ - | grep 'SMP = ' | cut -d' ' -f3) + | grep -s 'SMP = ' | cut -d' ' -f3) MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \ - | grep 'MODVERSIONS = ' | cut -d' ' -f3) + | grep -s 'MODVERSIONS = ' | cut -d' ' -f3) all::;@echo KERNEL HEADERS IN $(TREE): SMP=${SMP} MODVERSIONS=${MODVERSIONS} all:: $(LIBS) $(MODS) $(PROGS) endif diff --git a/linux/picker.c b/linux/picker.c index 186f28b2..ecdb2c15 100644 --- a/linux/picker.c +++ b/linux/picker.c @@ -1,4 +1,5 @@ #include +#include #ifndef CONFIG_SMP #define CONFIG_SMP 0 @@ -10,3 +11,4 @@ SMP = CONFIG_SMP MODVERSIONS = CONFIG_MODVERSIONS +RELEASE = UTS_RELEASE -- cgit v1.2.3