Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6

* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6:
initramfs: Fix build break on symbol-prefixed archs
initramfs: fix initramfs size calculation
initramfs: generalize initramfs_data.xxx.S variants
scripts/kallsyms: Enable error messages while hush up unnecessary warnings
scripts/setlocalversion: update comment
kbuild: Use a single clean rule for kernel and external modules
kbuild: Do not run make clean in $(srctree)
scripts/mod/modpost.c: fix commentary accordingly to last changes
kbuild: Really don't clean bounds.h and asm-offsets.h

+61 -163
+7
Documentation/kbuild/makefiles.txt
··· 776 776 Kbuild will assume the directories to be in the same relative path as the 777 777 Makefile if no absolute path is specified (path does not start with '/'). 778 778 779 + To exclude certain files from make clean, use the $(no-clean-files) variable. 780 + This is only a special case used in the top level Kbuild file: 781 + 782 + Example: 783 + #Kbuild 784 + no-clean-files := $(bounds-file) $(offsets-file) 785 + 779 786 Usually kbuild descends down in subdirectories due to "obj-* := dir/", 780 787 but in the architecture makefiles where the kbuild infrastructure 781 788 is not sufficient this sometimes needs to be explicit.
+2 -2
Kbuild
··· 95 95 missing-syscalls: scripts/checksyscalls.sh FORCE 96 96 $(call cmd,syscalls) 97 97 98 - # Delete all targets during make clean 99 - clean-files := $(addprefix $(objtree)/,$(filter-out $(bounds-file) $(offsets-file),$(targets))) 98 + # Keep these two files during make clean 99 + no-clean-files := $(bounds-file) $(offsets-file)
+13 -20
Makefile
··· 1137 1137 # 1138 1138 clean: rm-dirs := $(CLEAN_DIRS) 1139 1139 clean: rm-files := $(CLEAN_FILES) 1140 - clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation) 1140 + clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation) 1141 1141 1142 1142 PHONY += $(clean-dirs) clean archclean 1143 1143 $(clean-dirs): 1144 1144 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1145 1145 1146 - clean: archclean $(clean-dirs) 1147 - $(call cmd,rmdirs) 1148 - $(call cmd,rmfiles) 1149 - @find . $(RCS_FIND_IGNORE) \ 1150 - \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1151 - -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1152 - -o -name '*.symtypes' -o -name 'modules.order' \ 1153 - -o -name modules.builtin -o -name '.tmp_*.o.*' \ 1154 - -o -name '*.gcno' \) -type f -print | xargs rm -f 1146 + clean: archclean 1155 1147 1156 1148 # mrproper - Delete all generated files, including .config 1157 1149 # ··· 1344 1352 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1345 1353 1346 1354 clean: rm-dirs := $(MODVERDIR) 1347 - clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \ 1348 - $(KBUILD_EXTMOD)/modules.order \ 1349 - $(KBUILD_EXTMOD)/modules.builtin 1350 - clean: $(clean-dirs) 1351 - $(call cmd,rmdirs) 1352 - $(call cmd,rmfiles) 1353 - @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ 1354 - \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1355 - -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1356 - -o -name '*.gcno' \) -type f -print | xargs rm -f 1355 + clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers 1357 1356 1358 1357 help: 1359 1358 @echo ' Building external modules.' ··· 1360 1377 prepare: ; 1361 1378 scripts: ; 1362 1379 endif # KBUILD_EXTMOD 1380 + 1381 + clean: $(clean-dirs) 1382 + $(call cmd,rmdirs) 1383 + $(call cmd,rmfiles) 1384 + @find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1385 + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1386 + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1387 + -o -name '*.symtypes' -o -name 'modules.order' \ 1388 + -o -name modules.builtin -o -name '.tmp_*.o.*' \ 1389 + -o -name '*.gcno' \) -type f -print | xargs rm -f 1363 1390 1364 1391 # Generate tags for editors 1365 1392 # ---------------------------------------------------------------------------
+2 -1
include/asm-generic/vmlinux.lds.h
··· 640 640 . = ALIGN(4); \ 641 641 VMLINUX_SYMBOL(__initramfs_start) = .; \ 642 642 *(.init.ramfs) \ 643 - VMLINUX_SYMBOL(__initramfs_end) = .; 643 + . = ALIGN(8); \ 644 + *(.init.ramfs.info) 644 645 #else 645 646 #define INIT_RAM_FS 646 647 #endif
+4 -5
init/initramfs.c
··· 483 483 } 484 484 __setup("retain_initrd", retain_initrd_param); 485 485 486 - extern char __initramfs_start[], __initramfs_end[]; 486 + extern char __initramfs_start[]; 487 + extern unsigned long __initramfs_size; 487 488 #include <linux/initrd.h> 488 489 #include <linux/kexec.h> 489 490 ··· 571 570 572 571 static int __init populate_rootfs(void) 573 572 { 574 - char *err = unpack_to_rootfs(__initramfs_start, 575 - __initramfs_end - __initramfs_start); 573 + char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size); 576 574 if (err) 577 575 panic(err); /* Failed to decompress INTERNAL initramfs */ 578 576 if (initrd_start) { ··· 585 585 return 0; 586 586 } else { 587 587 clean_rootfs(); 588 - unpack_to_rootfs(__initramfs_start, 589 - __initramfs_end - __initramfs_start); 588 + unpack_to_rootfs(__initramfs_start, __initramfs_size); 590 589 } 591 590 printk(KERN_INFO "rootfs image is not initramfs (%s)" 592 591 "; looks like an initrd\n", err);
+2
scripts/Makefile.clean
··· 45 45 $(host-progs) \ 46 46 $(hostprogs-y) $(hostprogs-m) $(hostprogs-) 47 47 48 + __clean-files := $(filter-out $(no-clean-files), $(__clean-files)) 49 + 48 50 # as clean-files is given relative to the current directory, this adds 49 51 # a $(obj) prefix, except for absolute paths 50 52
+3 -1
scripts/Makefile.lib
··· 120 120 endif 121 121 122 122 ifdef CONFIG_SYMBOL_PREFIX 123 - _cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) 123 + _sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) 124 + _cpp_flags += $(_sym_flags) 125 + _a_flags += $(_sym_flags) 124 126 endif 125 127 126 128
+2 -6
scripts/kallsyms.c
··· 107 107 108 108 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); 109 109 if (rc != 3) { 110 - if (rc != EOF) { 111 - /* skip line. sym is used as dummy to 112 - * shut of "warn_unused_result" warning. 113 - */ 114 - sym = fgets(str, 500, in); 115 - } 110 + if (rc != EOF && fgets(str, 500, in) == NULL) 111 + fprintf(stderr, "Read error or end of file.\n"); 116 112 return -1; 117 113 } 118 114
+4 -1
scripts/mod/modpost.c
··· 1208 1208 * .cpuinit.data => __cpudata 1209 1209 * .memexitconst => __memconst 1210 1210 * etc. 1211 + * 1212 + * The memory of returned value has been allocated on a heap. The user of this 1213 + * method should free it after usage. 1211 1214 */ 1212 1215 static char *sec2annotation(const char *s) 1213 1216 { ··· 1233 1230 strcat(p, "data "); 1234 1231 else 1235 1232 strcat(p, " "); 1236 - return r; /* we leak her but we do not care */ 1233 + return r; 1237 1234 } else { 1238 1235 return strdup(""); 1239 1236 }
+4 -2
scripts/setlocalversion
··· 160 160 # full scm version string 161 161 res="$res$(scm_version)" 162 162 else 163 - # apped a plus sign if the repository is not in a clean tagged 164 - # state and LOCALVERSION= is not specified 163 + # append a plus sign if the repository is not in a clean 164 + # annotated or signed tagged state (as git describe only 165 + # looks at signed or annotated tags - git tag -a/-s) and 166 + # LOCALVERSION= is not specified 165 167 if test "${LOCALVERSION+set}" != "set"; then 166 168 scm=$(scm_version --short) 167 169 res="$res${scm:++}"
+4 -2
usr/Makefile
··· 18 18 # Lzo 19 19 suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo 20 20 21 + AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)" 22 + 21 23 # Generate builtin.o based on initramfs_data.o 22 - obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o 24 + obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o 23 25 24 26 # initramfs_data.o contains the compressed initramfs_data.cpio image. 25 27 # The image is included using .incbin, a dependency which is not 26 28 # tracked automatically. 27 - $(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE 29 + $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE 28 30 29 31 ##### 30 32 # Generate the initramfs cpio archive
+14 -7
usr/initramfs_data.S
··· 11 11 -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o 12 12 ld -m elf_i386 -r -o built-in.o initramfs_data.o 13 13 14 - initramfs_data.scr looks like this: 15 - SECTIONS 16 - { 17 - .init.ramfs : { *(.data) } 18 - } 14 + For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds. 19 15 20 16 The above example is for i386 - the parameters vary from architectures. 21 17 Eventually look up LDFLAGS_BLOB in an older version of the ··· 21 25 in the ELF header, as required by certain architectures. 22 26 */ 23 27 24 - .section .init.ramfs,"a" 25 - .incbin "usr/initramfs_data.cpio" 28 + #include <linux/stringify.h> 26 29 30 + .section .init.ramfs,"a" 31 + __irf_start: 32 + .incbin __stringify(INITRAMFS_IMAGE) 33 + __irf_end: 34 + .section .init.ramfs.info,"a" 35 + .globl __initramfs_size 36 + __initramfs_size: 37 + #ifdef CONFIG_32BIT 38 + .long __irf_end - __irf_start 39 + #else 40 + .quad __irf_end - __irf_start 41 + #endif
-29
usr/initramfs_data.bz2.S
··· 1 - /* 2 - initramfs_data includes the compressed binary that is the 3 - filesystem used for early user space. 4 - Note: Older versions of "as" (prior to binutils 2.11.90.0.23 5 - released on 2001-07-14) dit not support .incbin. 6 - If you are forced to use older binutils than that then the 7 - following trick can be applied to create the resulting binary: 8 - 9 - 10 - ld -m elf_i386 --format binary --oformat elf32-i386 -r \ 11 - -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o 12 - ld -m elf_i386 -r -o built-in.o initramfs_data.o 13 - 14 - initramfs_data.scr looks like this: 15 - SECTIONS 16 - { 17 - .init.ramfs : { *(.data) } 18 - } 19 - 20 - The above example is for i386 - the parameters vary from architectures. 21 - Eventually look up LDFLAGS_BLOB in an older version of the 22 - arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. 23 - 24 - Using .incbin has the advantage over ld that the correct flags are set 25 - in the ELF header, as required by certain architectures. 26 - */ 27 - 28 - .section .init.ramfs,"a" 29 - .incbin "usr/initramfs_data.cpio.bz2"
-29
usr/initramfs_data.gz.S
··· 1 - /* 2 - initramfs_data includes the compressed binary that is the 3 - filesystem used for early user space. 4 - Note: Older versions of "as" (prior to binutils 2.11.90.0.23 5 - released on 2001-07-14) dit not support .incbin. 6 - If you are forced to use older binutils than that then the 7 - following trick can be applied to create the resulting binary: 8 - 9 - 10 - ld -m elf_i386 --format binary --oformat elf32-i386 -r \ 11 - -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o 12 - ld -m elf_i386 -r -o built-in.o initramfs_data.o 13 - 14 - initramfs_data.scr looks like this: 15 - SECTIONS 16 - { 17 - .init.ramfs : { *(.data) } 18 - } 19 - 20 - The above example is for i386 - the parameters vary from architectures. 21 - Eventually look up LDFLAGS_BLOB in an older version of the 22 - arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. 23 - 24 - Using .incbin has the advantage over ld that the correct flags are set 25 - in the ELF header, as required by certain architectures. 26 - */ 27 - 28 - .section .init.ramfs,"a" 29 - .incbin "usr/initramfs_data.cpio.gz"
-29
usr/initramfs_data.lzma.S
··· 1 - /* 2 - initramfs_data includes the compressed binary that is the 3 - filesystem used for early user space. 4 - Note: Older versions of "as" (prior to binutils 2.11.90.0.23 5 - released on 2001-07-14) dit not support .incbin. 6 - If you are forced to use older binutils than that then the 7 - following trick can be applied to create the resulting binary: 8 - 9 - 10 - ld -m elf_i386 --format binary --oformat elf32-i386 -r \ 11 - -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o 12 - ld -m elf_i386 -r -o built-in.o initramfs_data.o 13 - 14 - initramfs_data.scr looks like this: 15 - SECTIONS 16 - { 17 - .init.ramfs : { *(.data) } 18 - } 19 - 20 - The above example is for i386 - the parameters vary from architectures. 21 - Eventually look up LDFLAGS_BLOB in an older version of the 22 - arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. 23 - 24 - Using .incbin has the advantage over ld that the correct flags are set 25 - in the ELF header, as required by certain architectures. 26 - */ 27 - 28 - .section .init.ramfs,"a" 29 - .incbin "usr/initramfs_data.cpio.lzma"
-29
usr/initramfs_data.lzo.S
··· 1 - /* 2 - initramfs_data includes the compressed binary that is the 3 - filesystem used for early user space. 4 - Note: Older versions of "as" (prior to binutils 2.11.90.0.23 5 - released on 2001-07-14) dit not support .incbin. 6 - If you are forced to use older binutils than that then the 7 - following trick can be applied to create the resulting binary: 8 - 9 - 10 - ld -m elf_i386 --format binary --oformat elf32-i386 -r \ 11 - -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o 12 - ld -m elf_i386 -r -o built-in.o initramfs_data.o 13 - 14 - initramfs_data.scr looks like this: 15 - SECTIONS 16 - { 17 - .init.ramfs : { *(.data) } 18 - } 19 - 20 - The above example is for i386 - the parameters vary from architectures. 21 - Eventually look up LDFLAGS_BLOB in an older version of the 22 - arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. 23 - 24 - Using .incbin has the advantage over ld that the correct flags are set 25 - in the ELF header, as required by certain architectures. 26 - */ 27 - 28 - .section .init.ramfs,"a" 29 - .incbin "usr/initramfs_data.cpio.lzo"