summaryrefslogtreecommitdiff
blob: bc688bc3661b9cf85f3fefb0fa7811582f06570f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--- /var/tmp/portage/lcd-linux-0.12.0/work/lcd-linux-0.12.0/Makefile	2007-01-09 15:43:24.000000000 +0100
+++ lcd_Makefile	2007-02-05 21:57:14.000000000 +0100
@@ -11,7 +11,11 @@
 	then echo "/usr/src/linux-$(KERNEL_VERSION)"; \
 	else echo "/usr/src/linux"; fi)
 
-DESTDIR := /lib/modules/$(KERNEL_VERSION)/misc
+DESTROOT := /
+
+KERNEL_SRC_DEST := $(DESTROOT)/$(KERNEL_SRC_DIR)
+
+DESTDIR := $(DESTROOT)/lib/modules/$(KERNEL_VERSION)/misc
 
 MODULES_CONF := $(shell if [ -f /etc/conf.modules ]; \
 	then echo "/etc/conf.modules"; \
@@ -20,7 +24,7 @@
 CC := gcc
 
 CPPFLAGS := -D__KERNEL__ -DMODULE
-CPPFLAGS += -I$(KERNEL_SRC_DIR)/include -I$(TOPDIR)/include
+CPPFLAGS += -I$(KERNEL_SRC_DEST)/include -I$(TOPDIR)/include
 
 CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
 	  -fno-common -fomit-frame-pointer -pipe
@@ -45,14 +49,15 @@
 
 %.ko: %.c
 	@echo "obj-m := `basename $@ .ko`.o" > Makefile
-	@cp -f $(TOPDIR)/include/linux/lcd-linux.h $(KERNEL_SRC_DIR)/include/linux
+	@mkdir -p $(KERNEL_SRC_DEST)/include/linux
+	@cp -f $(TOPDIR)/include/linux/lcd-linux.h $(KERNEL_SRC_DEST)/include/linux
 	@if [ -f $(TOPDIR)/include/linux/`basename $@ .ko`.h ]; then \
-		cp -f $(TOPDIR)/include/linux/`basename $@ .ko`.h $(KERNEL_SRC_DIR)/include/linux; \
+		cp -f $(TOPDIR)/include/linux/`basename $@ .ko`.h $(KERNEL_SRC_DEST)/include/linux; \
 	fi
-	$(MAKE) -C $(KERNEL_SRC_DIR) M=`pwd` modules
+	$(MAKE) -C $(KERNEL_SRC_DIR) CFLAGS="-I$(KERNEL_SRC_DEST)/include" M=`pwd` INSTALL_MOD_PATH=$(DESTROOT) modules
 	@mv $@ $(TOPDIR)/modules
-	@rm -f $(KERNEL_SRC_DIR)/include/linux/lcd-linux.h
-	@rm -f $(KERNEL_SRC_DIR)/include/linux/`basename $@ .ko`.h
+	@rm -f $(KERNEL_SRC_DEST)/include/linux/lcd-linux.h
+	@rm -f $(KERNEL_SRC_DEST)/include/linux/`basename $@ .ko`.h
 
 %.ver: %.c
 ifeq (foo$(MODFLAGS), foo)
@@ -72,18 +77,11 @@
 	@echo "- KERNEL_SRC_DIR: $(KERNEL_SRC_DIR)"
 	@echo "- DESTDIR: $(DESTDIR)"
 ifeq ($(KERNEL_LEVEL), 2.6)
+	@echo $(CPPFLAGS)
 	$(MAKE) TOPDIR=`pwd` -f `pwd`/Makefile -C lcd-linux lcd-linux.ko
-	@if [ -f $(KERNEL_SRC_DIR)/Module.symvers ]; then \
-		cp $(KERNEL_SRC_DIR)/Module.symvers $(KERNEL_SRC_DIR)/Module.symvers.bak; \
-		cat lcd-linux/Module.symvers >> $(KERNEL_SRC_DIR)/Module.symvers; \
-		cp -f lcd-linux/Module.symvers examples; \
-	fi
 	for i in $(DRIVERS); do \
 		$(MAKE) TOPDIR=`pwd` -f `pwd`/Makefile -C drivers/$$i $$i.ko; \
 	done
-	@if [ -f $(KERNEL_SRC_DIR)/Module.symvers.bak ]; then \
-		mv $(KERNEL_SRC_DIR)/Module.symvers.bak $(KERNEL_SRC_DIR)/Module.symvers; \
-	fi
 else
 	$(MAKE) TOPDIR=`pwd` -f `pwd`/Makefile -C lcd-linux lcd-linux.o
 	for i in $(DRIVERS); do \
@@ -114,7 +112,7 @@
 		echo "alias char-major-120 lcd-linux" >> $(MODULES_CONF); \
 		echo "- entry \"alias char-major-120 lcd-linux\" added in $(MODULES_CONF)"; \
 	fi
-	/sbin/depmod -a
+# 	/sbin/depmod -a
 
 uninstall:
 	rm -f $(DESTDIR)/lcd-linux.*;
@@ -139,11 +137,11 @@
 	$(CC) -Wall -O2 test_write.c -o ../test_write
 	$(CC) -Wall -O2 -I$(TOPDIR)/include test_ioctl.c -o ../test_ioctl
 ifeq ($(KERNEL_LEVEL), 2.6)
-	cp -f $(TOPDIR)/include/linux/hd44780.h $(KERNEL_SRC_DIR)/include/linux
+	cp -f $(TOPDIR)/include/linux/hd44780.h $(KERNEL_SRC_DEST)/include/linux
 	touch $(TOPDIR)/include/linux/test_module.h
 	$(MAKE) -f $(TOPDIR)/Makefile test_module.ko
 	rm -f $(TOPDIR)/include/linux/test_module.h
-	rm -f $(KERNEL_SRC_DIR)/include/linux/hd44780.h
+	rm -f $(KERNEL_SRC_DEST)/include/linux/hd44780.h
 else
 	$(CC) $(CFLAGS) $(MODFLAGS) -include "$(TOPDIR)/include/lcd-linux.ver" -c test_module.c -o ../modules/test_module.o
 endif
@@ -155,13 +153,13 @@
 
 clean:
 ifeq ($(KERNEL_LEVEL), 2.6)
-	@if [ -f lcd-linux/Makefile ]; then $(MAKE) -C $(KERNEL_SRC_DIR) M=`pwd`/lcd-linux clean; fi
+	@if [ -f lcd-linux/Makefile ]; then $(MAKE) -C $(KERNEL_SRC_DEST) M=`pwd`/lcd-linux INSTALL_MOD_PATH=$(DESTROOT) clean; fi
 	@for i in $(DRIVERS); do \
 		if [ -f drivers/$$i/Makefile ]; then \
-			$(MAKE) -C $(KERNEL_SRC_DIR) M=`pwd`/drivers/$$i clean; \
+			$(MAKE) -C $(KERNEL_SRC_DIR) M=`pwd`/drivers/$$i INSTALL_MOD_PATH=$(DESTROOT) clean; \
 		fi; \
 	done
-	@if [ -f examples/Makefile ]; then $(MAKE) -C $(KERNEL_SRC_DIR) M=`pwd`/examples clean; fi
+	@if [ -f examples/Makefile ]; then $(MAKE) -C $(KERNEL_SRC_DIR) INSTALL_MOD_PATH=$(DESTROOT) M=`pwd`/examples clean; fi
 	rm -f examples/Makefile lcd-linux/Makefile drivers/*/Makefile modules/*.ko test_* lcd-console
 	find . -name "*symvers" -exec rm {} \;
 else
@@ -202,13 +200,13 @@
 	mv lcd-linux-$(LCD_LINUX_VER) $(SRC_DIR)
 
 source_install:
-	@if [ ! -d $(KERNEL_SRC_DIR)/drivers/lcd-linux ]; then \
-		mkdir -p $(KERNEL_SRC_DIR)/drivers/lcd-linux; \
-		echo -e "- created directory \"$(KERNEL_SRC_DIR)/drivers/lcd-linux\""; \
-	fi
-	cp -f include/linux/*.h $(KERNEL_SRC_DIR)/include/linux
-	cp -rf lcd-linux/* $(KERNEL_SRC_DIR)/drivers/lcd-linux
-	cp -rf drivers/hd44780/* $(KERNEL_SRC_DIR)/drivers/lcd-linux
+	@if [ ! -d $(KERNEL_SRC_DEST)/drivers/lcd-linux ]; then \
+		mkdir -p $(KERNEL_SRC_DEST)/drivers/lcd-linux; \
+		echo -e "- created directory \"$(KERNEL_SRC_DEST)/drivers/lcd-linux\""; \
+	fi
+	cp -f include/linux/*.h $(KERNEL_SRC_DEST)/include/linux
+	cp -rf lcd-linux/* $(KERNEL_SRC_DEST)/drivers/lcd-linux
+	cp -rf drivers/hd44780/* $(KERNEL_SRC_DEST)/drivers/lcd-linux
 
 headers_install:
 	rm -f .installed_headers.txt