]> git.pld-linux.org Git - packages/kernel.git/blame - kbuild-out-of-tree.diff
- update for cset 20040707_...
[packages/kernel.git] / kbuild-out-of-tree.diff
CommitLineData
a494c824 1Index: linux-2.6.1/Makefile
2===================================================================
3--- linux-2.6.1.orig/Makefile
4+++ linux-2.6.1/Makefile
5@@ -289,7 +289,10 @@ export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFL
6 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
7 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
8
9-export MODVERDIR := .tmp_versions
10+# When compiling out-of-tree modules, put MODVERDIR in the module source
11+# tree rather than in the kernel source tree. The kernel source tree might
12+# even be read-only.
13+export MODVERDIR := $(patsubst %,%/,$(firstword $(filter ../% /%,$(SUBDIRS)))).tmp_versions
14
15 # The temporary file to save gcc -MD generated dependencies must not
16 # contain a comma
17@@ -748,6 +751,9 @@ endif
18 _modinst_post: _modinst_
19 if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
20
21+modules_add:
22+ $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
23+
24 else # CONFIG_MODULES
25
26 # Modules not configured
27@@ -819,11 +825,28 @@ clean-dirs += $(addprefix _clean_,$(ALL_
28 $(clean-dirs):
29 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
30
31+.PHONY: _clean _mrproper
32+ifeq ($(filter ../% /%,$(SUBDIRS)),)
33+
34+clean_subdirs := .
35+clean: _clean archclean $(clean-dirs)
36+ $(call cmd,rmclean)
37+mrproper distclean: clean _mrproper archmrproper
38+ $(call cmd,mrproper)
39+
40+else
41+
42+clean_subdirs := $(filter ../% /%,$(SUBDIRS))
43+clean: _clean
44+mrproper distclean: _mrproper
45+ $(Q)rm -rf $(MODVERDIR)
46+
47+endif
48+
49 quiet_cmd_rmclean = RM $$(CLEAN_FILES)
50 cmd_rmclean = rm -f $(CLEAN_FILES)
51-clean: archclean $(clean-dirs)
52- $(call cmd,rmclean)
53- @find . $(RCS_FIND_IGNORE) \
54+_clean:
55+ @find $(clean_subdirs) $(RCS_FIND_IGNORE) \
56 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
57 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
58 -type f -print | xargs rm -f
59@@ -832,15 +855,13 @@ clean: archclean $(clean-dirs)
60 #
61 quiet_cmd_mrproper = RM $$(MRPROPER_DIRS) + $$(MRPROPER_FILES)
62 cmd_mrproper = rm -rf $(MRPROPER_DIRS) && rm -f $(MRPROPER_FILES)
63-mrproper distclean: clean archmrproper
64- @echo ' Making $@ in the srctree'
65- @find . $(RCS_FIND_IGNORE) \
66+_mrproper:
67+ @find $(clean_subdirs) $(RCS_FIND_IGNORE) \
68 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
69 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
70 -o -name '.*.rej' -o -size 0 \
71 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
72 -type f -print | xargs rm -f
73- $(call cmd,mrproper)
74
75 # Generate tags for editors
76 # ---------------------------------------------------------------------------
77@@ -1045,12 +1066,13 @@ define filechk
78 @set -e; \
79 echo ' CHK $@'; \
80 mkdir -p $(dir $@); \
81- $(filechk_$(1)) < $< > $@.tmp; \
82- if [ -r $@ ] && cmp -s $@ $@.tmp; then \
83- rm -f $@.tmp; \
84+ tmp=$$(/bin/mktemp /tmp/kbuild.XXXXXX); \
85+ $(filechk_$(1)) < $< > $$tmp; \
86+ if [ -r $@ ] && cmp -s $@ $$tmp; then \
87+ rm -f $$tmp; \
88 else \
89 echo ' UPD $@'; \
90- mv -f $@.tmp $@; \
91+ mv -f $$tmp $@; \
92 fi
93 endef
94
95Index: linux-2.6.1/scripts/modpost.c
96===================================================================
97--- linux-2.6.1.orig/scripts/modpost.c
98+++ linux-2.6.1/scripts/modpost.c
99@@ -15,7 +15,7 @@
100
101 /* Are we using CONFIG_MODVERSIONS? */
102 int modversions = 0;
103-/* Do we have vmlinux? */
104+/* Warn about undefined symbols? (do so if we have vmlinux) */
105 int have_vmlinux = 0;
106
107 void
108@@ -60,6 +60,17 @@ void *do_nofail(void *ptr, const char *f
109 static struct module *modules;
110
111 struct module *
112+find_module(char *modname)
113+{
114+ struct module *mod;
115+
116+ for (mod = modules; mod; mod = mod->next)
117+ if (strcmp(mod->name, modname) == 0)
118+ break;
119+ return mod;
120+}
121+
122+struct module *
123 new_module(char *modname)
124 {
125 struct module *mod;
126@@ -165,7 +176,7 @@ add_exported_symbol(const char *name, st
127 struct symbol *s = find_symbol(name);
128
129 if (!s) {
130- new_symbol(name, modules, crc);
131+ new_symbol(name, module, crc);
132 return;
133 }
134 if (crc) {
135@@ -346,14 +357,17 @@ read_symbols(char *modname)
136 struct symbol *s;
137 Elf_Sym *sym;
138
139- /* When there's no vmlinux, don't print warnings about
140- * unresolved symbols (since there'll be too many ;) */
141- have_vmlinux = is_vmlinux(modname);
142-
143 parse_elf(&info, modname);
144
145 mod = new_module(modname);
146
147+ /* When we have vmlinux, print warnings about unresolved
148+ * symbols. (Otherwise, there might be too many). */
149+ if (strcmp(modname, "vmlinux") == 0) {
150+ have_vmlinux = 1;
151+ mod->skip = 1;
152+ }
153+
154 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
155 symname = info.strtab + sym->st_name;
156
157@@ -541,19 +555,91 @@ write_if_changed(struct buffer *b, const
158 fclose(file);
159 }
160
161+void
162+read_dump(FILE *file)
163+{
164+ unsigned int crc;
165+ char symname[128], modname[4096];
166+
167+ while (fscanf(file, "%x %128s %4096s", &crc, symname, modname) == 3) {
168+ struct module *mod;
169+ if (!(mod = find_module(modname))) {
170+ mod = new_module(NOFAIL(strdup(modname)));
171+ mod->skip = 1;
172+ }
173+ add_exported_symbol(symname, mod, &crc);
174+ }
175+ if (!feof(file)) {
176+ fatal("parse error in symbol dump file\n");
177+ }
178+}
179+
180+void
181+write_dump(FILE *file)
182+{
183+ struct symbol *symbol;
184+ int n;
185+
186+ for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
187+ symbol = symbolhash[n];
188+ while (symbol) {
189+ symbol = symbol->next;
190+ }
191+ }
192+
193+ for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
194+ symbol = symbolhash[n];
195+ while (symbol) {
196+ fprintf(file, "0x%08x\t%s\t%s\n", symbol->crc,
197+ symbol->name, symbol->module->name);
198+ symbol = symbol->next;
199+ }
200+ }
201+}
202+
203 int
204 main(int argc, char **argv)
205 {
206 struct module *mod;
207 struct buffer buf = { };
208 char fname[SZ];
209+ char *read_dumpfile = NULL, *write_dumpfile = NULL;
210+ int opt;
211+
212+ while ((opt = getopt(argc, argv, "i:o:")) != -1) {
213+ switch(opt) {
214+ case 'i':
215+ read_dumpfile = optarg;
216+ modversions = 1;
217+ have_vmlinux = 1;
218+ break;
219+ case 'o':
220+ write_dumpfile = optarg;
221+ break;
222+ default:
223+ exit(1);
224+ }
225+ }
226+
227+ if (read_dumpfile) {
228+ FILE *file = fopen(read_dumpfile, "r");
229+ if (!file) {
230+ perror(read_dumpfile);
231+ exit(1);
232+ }
233+ read_dump(file);
234+ if (fclose(file) != 0) {
235+ perror(read_dumpfile);
236+ exit(1);
237+ }
238+ }
239
240- for (; argv[1]; argv++) {
241- read_symbols(argv[1]);
242+ while (optind < argc) {
243+ read_symbols(argv[optind++]);
244 }
245
246 for (mod = modules; mod; mod = mod->next) {
247- if (is_vmlinux(mod->name))
248+ if (mod->skip)
249 continue;
250
251 buf.pos = 0;
252@@ -566,6 +652,20 @@ main(int argc, char **argv)
253 sprintf(fname, "%s.mod.c", mod->name);
254 write_if_changed(&buf, fname);
255 }
256+
257+ if (write_dumpfile) {
258+ FILE *file = fopen(write_dumpfile, "w");
259+ if (!file) {
260+ perror(write_dumpfile);
261+ exit(1);
262+ }
263+ write_dump(file);
264+ if (fclose(file) != 0) {
265+ perror(write_dumpfile);
266+ exit(1);
267+ }
268+ }
269+
270 return 0;
271 }
272
273Index: linux-2.6.1/scripts/modpost.h
274===================================================================
275--- linux-2.6.1.orig/scripts/modpost.h
276+++ linux-2.6.1/scripts/modpost.h
277@@ -70,6 +70,7 @@ struct module {
278 const char *name;
279 struct symbol *unres;
280 int seen;
281+ int skip;
282 struct buffer dev_table_buf;
283 };
284
285Index: linux-2.6.1/scripts/Makefile.modinst
286===================================================================
287--- linux-2.6.1.orig/scripts/Makefile.modinst
288+++ linux-2.6.1/scripts/Makefile.modinst
289@@ -29,11 +29,13 @@ quiet_cmd_modules_install = INSTALL $@
290 $(filter-out ../% /%,$(modules)):
291 $(call cmd,modules_install)
292
293-# Modules built outside just go into extra
294+# Modules built outside go into extra by default
295
296-quiet_cmd_modules_install_extra = INSTALL $(obj-m:.o=.ko)
297- cmd_modules_install_extra = mkdir -p $(MODLIB)/extra; \
298- cp $@ $(MODLIB)/extra
299+MOD_DIR ?= extra
300+
301+quiet_cmd_modules_install_extra = INSTALL $(@F)
302+ cmd_modules_install_extra = mkdir -p $(MODLIB)/$(MOD_DIR); \
303+ cp $@ $(MODLIB)/$(MOD_DIR)
304
305 $(filter ../% /%,$(modules)):
306 $(call cmd,modules_install_extra)
307Index: linux-2.6.1/scripts/Makefile.modpost
308===================================================================
309--- linux-2.6.1.orig/scripts/Makefile.modpost
310+++ linux-2.6.1/scripts/Makefile.modpost
311@@ -51,11 +51,21 @@ $(modules:.ko=.mod.c): __modpost ;
312
313 # Extract all checksums for all exported symbols
314
315-quiet_cmd_modpost = MODPOST
316- cmd_modpost = scripts/modpost $(filter-out FORCE,$^)
317+# Are we building out-of-tree modules?
318
319+ifeq ($(filter ../% /%,$(SUBDIRS)),)
320+modver_file := modversions
321+quiet_cmd_modpost = MODPOST
322+ cmd_modpost = scripts/modpost $(filter-out FORCE,$^) -o $(modver_file)
323 __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
324 $(call if_changed,modpost)
325+else
326+modver_file := $(wildcard modversions)
327+quiet_cmd_modpost = MODPOST
328+ cmd_modpost = scripts/modpost $^ $(if $(modver_file),-i $(modver_file))
329+__modpost: $(modules:.ko=.o)
330+ $(call cmd,modpost)
331+endif
332
333 targets += __modpost
334
This page took 0.086681 seconds and 4 git commands to generate.