[kbuild-devel] [PATCH 1/2] kbuild: prepare for using code from different dir

2007-05-05 Thread Sam Ravnborg
To introduce support for source in one directory but output files
in another directory during a non O= build prefix all paths
with $(src) repsectively $(obj).

Signed-off-by: Sam Ravnborg [EMAIL PROTECTED]
---

This will likely appear in my kbuild.git tree but only
when next mergewindow opens I think.
My current batch (35 commits) has not yet been pulled
and this would no see exposure in -mm first.

I have compiled i386 + x86_64 in an allmodconfig with
no problems so the common stuff works.

Sam

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e2ad2dc..a525112 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -131,13 +131,13 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
 quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
 cmd_cc_s_c   = $(CC) $(c_flags) -fverbose-asm -S -o $@ $
 
-%.s: %.c FORCE
+$(obj)/%.s: $(src)/%.c FORCE
$(call if_changed_dep,cc_s_c)
 
 quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
 cmd_cc_i_c   = $(CPP) $(c_flags)   -o $@ $
 
-%.i: %.c FORCE
+$(obj)/%.i: $(src)/%.c FORCE
$(call if_changed_dep,cc_i_c)
 
 quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
@@ -146,7 +146,7 @@ cmd_cc_symtypes_c  = \
| $(GENKSYMS) -T $@ /dev/null; \
test -s $@ || rm -f $@
 
-%.symtypes : %.c FORCE
+$(obj)/%.symtypes : $(src)/%.c FORCE
$(call if_changed_dep,cc_symtypes_c)
 
 # C (.c) files
@@ -198,14 +198,13 @@ define rule_cc_o_c
 endef
 
 # Built-in and composite module parts
-
-%.o: %.c FORCE
+$(obj)/%.o: $(src)/%.c FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
 
 # Single-part modules are special since we need to mark them in $(MODVERDIR)
 
-$(single-used-m): %.o: %.c FORCE
+$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
@{ echo $(@:.o=.ko); echo $@; }  $(MODVERDIR)/$(@F:.o=.mod)
@@ -215,7 +214,7 @@ quiet_cmd_cc_lst_c = MKLST   $@
 $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
 System.map $(OBJDUMP)  $@
 
-%.lst: %.c FORCE
+$(obj)/%.lst: $(src)/%.c FORCE
$(call if_changed_dep,cc_lst_c)
 
 # Compile assembler sources (.S)
@@ -229,13 +228,13 @@ $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
 quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
 cmd_as_s_S   = $(CPP) $(a_flags)   -o $@ $ 
 
-%.s: %.S FORCE
+$(obj)/%.s: $(src)/%.S FORCE
$(call if_changed_dep,as_s_S)
 
 quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
 cmd_as_o_S   = $(CC) $(a_flags) -c -o $@ $
 
-%.o: %.S FORCE
+$(obj)/%.o: $(src)/%.S FORCE
$(call if_changed_dep,as_o_S)
 
 targets += $(real-objs-y) $(real-objs-m) $(lib-y)
@@ -246,7 +245,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
 quiet_cmd_cpp_lds_S = LDS $@
   cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $
 
-%.lds: %.lds.S FORCE
+$(obj)/%.lds: $(src)/%.lds.S FORCE
$(call if_changed_dep,cpp_lds_S)
 
 # Build the compiled-in targets
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 575afbe..6943a7a 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -114,7 +114,7 @@ hostcxx_flags  = -Wp,-MD,$(depfile) $(__hostcxx_flags)
 quiet_cmd_host-csingle = HOSTCC  $@
   cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $ \
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
-$(host-csingle): %: %.c FORCE
+$(host-csingle): $(obj)/%: $(src)/%.c FORCE
$(call if_changed_dep,host-csingle)
 
 # Link an executable based on list of .o files, all plain c
@@ -123,14 +123,14 @@ quiet_cmd_host-cmulti = HOSTLD  $@
   cmd_host-cmulti  = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
  $(addprefix $(obj)/,$($(@F)-objs)) \
  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
-$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
+$(host-cmulti): $(obj)/%: $(host-cobjs) $(host-cshlib) FORCE
$(call if_changed,host-cmulti)
 
 # Create .o file from a single .c file
 # host-cobjs - .o
 quiet_cmd_host-cobjs   = HOSTCC  $@
   cmd_host-cobjs   = $(HOSTCC) $(hostc_flags) -c -o $@ $
-$(host-cobjs): %.o: %.c FORCE
+$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
$(call if_changed_dep,host-cobjs)
 
 # Link an executable based on list of .o files, a mixture of .c and .cc
@@ -140,20 +140,20 @@ quiet_cmd_host-cxxmulti   = HOSTLD  $@
  $(foreach o,objs cxxobjs,\
  $(addprefix $(obj)/,$($(@F)-$(o \
  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
-$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
+$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
$(call if_changed,host-cxxmulti)
 
 # Create .o file from a single .cc (C++) file
 quiet_cmd_host-cxxobjs = HOSTCXX $@
   cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $
-$(host-cxxobjs): 

[kbuild-devel] [PATCH 2/2] newsetup: let x86_64 and i386 share same Makefile

2007-05-05 Thread Sam Ravnborg
Using the possibility to assing src to another dir we can now
share the same code for i386 and x86_64 with output files
located in the dir of the architecture.

Signed-off-by: Sam Ravnborg [EMAIL PROTECTED]
---

We could have avoided the arch/x86_64/boot/Makefile
by changes all $(MAKE) invocations from
arch/x86_64/Makefile but addind an almost empty
Makefile seemed to be less 'magic'.

Sam


 i386/boot/Makefile   |   23 +++
 x86_64/boot/Makefile |  163 +--
 3 files changed, 18 insertions(+), 172 deletions(-)


diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index 4ebdc68..0a812ef 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -1,9 +1,5 @@
 #
-# arch/i386/boot/Makefile
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file COPYING in the main directory of this archive
-# for more details.
+# Makefile for boot part of x86
 #
 # Copyright (C) 1994 by Linus Torvalds
 #
@@ -37,7 +33,10 @@ setup-y  += printf.o string.o tty.o video.o 
version.o voyager.o
 setup-y+= video-vga.o
 setup-y+= video-vesa.o
 
-hostprogs-y:= tools/build
+targets += $(setup-y)
+
+buildtool  := tools/build
+hostprogs-y:= $(buildtool)
 
 HOSTCFLAGS_build.o := $(LINUXINCLUDE)
 
@@ -46,8 +45,9 @@ HOSTCFLAGS_build.o := $(LINUXINCLUDE)
 # How to compile the 16-bit code.  Note we always compile for -march=i386,
 # that way we can complain to the user if the CPU is insufficient.
 CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP \
-  -march=i386 -mregparm=3 -fno-strict-aliasing \
-  $(call cc-option, -ffreestanding)
+  -m32 -march=i386 -mregparm=3 -fno-strict-aliasing \
+  $(call cc-option, -ffreestanding) \
+   $(call cc-option, -fno-stack-protector)
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
 $(obj)/zImage:  IMAGE_OFFSET := 0x1000
@@ -57,11 +57,11 @@ $(obj)/bzImage: EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK) 
-D__BIG_KERNEL__
 $(obj)/bzImage: BUILDFLAGS   := -b
 
 quiet_cmd_image = BUILD   $@
-cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/setup.bin \
+cmd_image = $(obj)/$(buildtool) $(BUILDFLAGS) $(obj)/setup.bin \
$(obj)/vmlinux.bin $(ROOT_DEV)  $@
 
 $(obj)/zImage $(obj)/bzImage: $(obj)/setup.bin \
- $(obj)/vmlinux.bin $(obj)/tools/build FORCE
+ $(obj)/vmlinux.bin $(obj)/$(buildtool) FORCE
$(call if_changed,image)
@echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
 
@@ -154,4 +154,5 @@ zlilo: $(BOOTIMAGE)
if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
 
 install:
-   sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) 
System.map $(INSTALL_PATH)
+   sh $(srctree)/$(src)/install.sh \
+   $(KERNELRELEASE) $(BOOTIMAGE) System.map $(INSTALL_PATH)
diff --git a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile
index f5c500d..6d8afcb 100644
--- a/arch/x86_64/boot/Makefile
+++ b/arch/x86_64/boot/Makefile
@@ -1,161 +1,6 @@
 #
-# arch/x86_64/boot/Makefile
+# boot infrastructure shared with i386
+# Use src from i386 but locate all object files here
 #
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file COPYING in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1994 by Linus Torvalds
-#
-
-# ROOT_DEV specifies the default root-device when making the image.
-# This can be either FLOPPY, CURRENT, /dev/ or empty, in which case
-# the default of FLOPPY is used by 'build'.
-
-ROOT_DEV := CURRENT
-
-# If you want to preset the SVGA mode, uncomment the next line and
-# set SVGA_MODE to whatever number you want.
-# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
-# The number is the same as you would ordinarily press at bootup.
-
-SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
-
-# If you want the RAM disk device, define this to be the size in blocks.
-
-#RAMDISK := -DRAMDISK=512
-
-targets:= vmlinux.bin setup.bin setup.elf zImage bzImage
-subdir-:= compressed
-
-Setup-y+= a20.o apm.o cmdline.o copy.o cpu.o edd.o
-Setup-y+= header.o main.o mca.o memory.o pm.o pmjump.o
-Setup-y+= printf.o string.o tty.o video.o version.o voyager.o
-
-# The link order of the video-*.o modules can matter.  In particular,
-# video-vga.o *must* be listed first.
-Setup-y+= video-vga.o
-Setup-y+= video-vesa.o
-
-setup-y= $(addprefix ../../i386/boot/, $(Setup-y))
-
-buildtool  := ../../i386/boot/tools/build
-hostprogs-y:= $(buildtool)
-
-HOSTCFLAGS_build.o := $(LINUXINCLUDE)
-
-# ---
-
-# How to compile the 16-bit code.  Note we always compile for -march=i386,

Re: [kbuild-devel] [PATCH 1/2] kbuild: prepare for using code from different dir

2007-05-05 Thread H. Peter Anvin
Sam Ravnborg wrote:
 
 This will likely appear in my kbuild.git tree but only
 when next mergewindow opens I think.
 My current batch (35 commits) has not yet been pulled
 and this would no see exposure in -mm first.
 

Cool.  I have a workaround (the old trick of building sideways objects
as used by for example oprofile) for the moment.  It turns out Andi has
changes in his tree which means boot/compressed cannot be unified, so
this works for me for the time being, and we can clean it up later.

-hpa


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel


[kbuild-devel] [PATCH] Fix mconf segmentation fault

2007-05-05 Thread Marcin Garski

Hi,

I have found small bug in mconf, when you run it without any argument it 
will sigsegv.


Without patch:
$ scripts/kconfig/mconf
Segmentation fault

With patch:
$ scripts/kconfig/mconf
can't find file (null)

Signed-off-by: Marcin Garski [EMAIL PROTECTED]

--
Best Regards
Marcin Garski
diff -urp linux-2.6.21.1.orig/scripts/kconfig/lex.zconf.c_shipped 
linux-2.6.21.1/scripts/kconfig/lex.zconf.c_shipped
--- linux-2.6.21.1.orig/scripts/kconfig/lex.zconf.c_shipped 2007-04-27 
23:49:26.0 +0200
+++ linux-2.6.21.1/scripts/kconfig/lex.zconf.c_shipped  2007-05-05 
22:35:35.0 +0200
@@ -2264,7 +2264,7 @@ FILE *zconf_fopen(const char *name)
FILE *f;
 
f = fopen(name, r);
-   if (!f  name[0] != '/') {
+   if (!f  name != NULL  name[0] != '/') {
env = getenv(SRCTREE);
if (env) {
sprintf(fullname, %s/%s, env, name);
diff -urp linux-2.6.21.1.orig/scripts/kconfig/zconf.l 
linux-2.6.21.1/scripts/kconfig/zconf.l
--- linux-2.6.21.1.orig/scripts/kconfig/zconf.l 2007-04-27 23:49:26.0 
+0200
+++ linux-2.6.21.1/scripts/kconfig/zconf.l  2007-05-05 22:35:24.0 
+0200
@@ -265,7 +265,7 @@ FILE *zconf_fopen(const char *name)
FILE *f;
 
f = fopen(name, r);
-   if (!f  name[0] != '/') {
+   if (!f  name != NULL  name[0] != '/') {
env = getenv(SRCTREE);
if (env) {
sprintf(fullname, %s/%s, env, name);
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel