public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] Consistently use the name asm-offsets.h
@ 2005-09-08 21:15 Sam Ravnborg
  2005-09-08 21:47 ` Sam Ravnborg
  2005-09-09 11:25 ` Jan-Benedict Glaw
  0 siblings, 2 replies; 7+ messages in thread
From: Sam Ravnborg @ 2005-09-08 21:15 UTC (permalink / raw)
  To: linux-arch, linux-kernel

Today all architectures expect 3 generate an asm-offsets.h file.
The exceptions are: frv, m32r, sparc64

Most architectures uses a name similar to asm_offsets.h with small
differences. A few uses asm-consts.h and a few uses '-' instead of '_'.

I suggest moving all the logic required to build the asm-offsets.h file
to a common places and do proper search&replace in architectures to make
the naming consitent. For frv, m32r and sparc64 we will need to create a
dummy file until they start using asm-offsets.h

The input file is consistently named asm-offsets.c so I plan to use the
name asm-offsets.h all over the place.

Sample patch for i386 (without renaming) below.
Notice that the chunk deleted from arch/i386/Makefile will be the same
for all architectures.

And as an added bonus introducing the below we finally get all
dependencies automatically tracked for the asm-offsets.h file.
This had slipped my mind for a long time but I was remineded when
I thougt about what dependencies could have been missed when using
bisect support in git.

If there is no objections I will see if I can have it ready before -rc1.
It's the dependency thing that want me to have is added soon.

The Kbuild file in the top-level directory is planned to be extended over
time. For now it contains only the asm-offsets stuff.


	Sam

	
 Kbuild             |   40 ++++++++++++++++++++++++++++++++++++++++
 Makefile           |   37 ++++++++++---------------------------
 arch/i386/Makefile |    9 ---------
 3 files changed, 50 insertions(+), 36 deletions(-)

diff --git a/Kbuild b/Kbuild
new file mode 100644
--- /dev/null
+++ b/Kbuild
@@ -0,0 +1,40 @@
+#
+# Kbuild for top-level directory of the kernel
+# This file takes care of the following:
+# 1) Generate asm-offsets.h
+
+# 1) Generate asm-offsets.h 
+#
+
+offsets-file := include/asm-$(ARCH)/asm_offsets.h
+
+always  := $(offsets-file)
+targets := $(offsets-file)
+targets += arch/$(ARCH)/kernel/asm-offsets.s
+
+quiet_cmd_offsets = GEN     $@
+define cmd_offsets
+	cat $< | \
+	(set -e; \
+	 echo "#ifndef __ASM_OFFSETS_H__"; \
+	 echo "#define __ASM_OFFSETS_H__"; \
+	 echo "/*"; \
+	 echo " * DO NOT MODIFY."; \
+	 echo " *"; \
+	 echo " * This file was generated by $(srctree)/Kbuild"; \
+	 echo " *"; \
+	 echo " */"; \
+	 echo ""; \
+	 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
+	 echo ""; \
+	 echo "#endif" ) > $@
+endef
+
+# We use internal kbuild rules to avoid the "is up to date" message from make
+arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
+	$(Q)mkdir -p $(dir $@)
+	$(call if_changed_dep,cc_s_c)
+
+$(srctree)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild
+	$(call cmd,offsets)
+
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -776,14 +776,14 @@ $(vmlinux-dirs): prepare-all scripts
 # A multi level approach is used. prepare1 is updated first, then prepare0.
 # prepare-all is the collection point for the prepare targets.
 
-.PHONY: prepare-all prepare prepare0 prepare1 prepare2
+.PHONY: prepare-all prepare prepare0 prepare1 prepare2 prepare3
 
-# prepare2 is used to check if we are building in a separate output directory,
+# preparei3 is used to check if we are building in a separate output directory,
 # and if so do:
 # 1) Check that make has not been executed in the kernel src $(srctree)
 # 2) Create the include2 directory, used for the second asm symlink
 
-prepare2:
+prepare3:
 ifneq ($(KBUILD_SRC),)
 	@echo '  Using $(srctree) as source for kernel'
 	$(Q)if [ -f $(srctree)/.config ]; then \
@@ -795,16 +795,19 @@ ifneq ($(KBUILD_SRC),)
 	$(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
 endif
 
-# prepare1 creates a makefile if using a separate output directory
-prepare1: prepare2 outputmakefile
+# prepare2 creates a makefile if using a separate output directory
+prepare2: prepare3 outputmakefile
 
-prepare0: prepare1 include/linux/version.h include/asm \
+prepare1: prepare2 include/linux/version.h include/asm \
                    include/config/MARKER
 ifneq ($(KBUILD_MODULES),)
 	$(Q)rm -rf $(MODVERDIR)
 	$(Q)mkdir -p $(MODVERDIR)
 endif
 
+prepare0: prepare1 FORCE
+	$(Q)$(MAKE) $(build)=$(srctree)
+
 # All the preparing..
 prepare-all: prepare0 prepare
 
@@ -949,26 +952,6 @@ modules modules_install: FORCE
 
 endif # CONFIG_MODULES
 
-# Generate asm-offsets.h 
-# ---------------------------------------------------------------------------
-
-define filechk_gen-asm-offsets
-	(set -e; \
-	 echo "#ifndef __ASM_OFFSETS_H__"; \
-	 echo "#define __ASM_OFFSETS_H__"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by arch/$(ARCH)/Makefile"; \
-	 echo " *"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
-	 echo ""; \
-	 echo "#endif" )
-endef
-
-
 ###
 # Cleaning is done on three levels.
 # make clean     Delete most generated files
@@ -991,7 +974,7 @@ MRPROPER_FILES += .config .config.old in
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs      := $(addprefix _clean_,$(vmlinux-alldirs))
+clean-dirs      := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
 
 .PHONY: $(clean-dirs) clean archclean
 $(clean-dirs):
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -156,15 +156,6 @@ install: vmlinux
 install kernel_install:
 	$(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
 
-prepare: include/asm-$(ARCH)/asm_offsets.h
-CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h
-
-arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
-				   include/config/MARKER
-
-include/asm-$(ARCH)/asm_offsets.h: arch/$(ARCH)/kernel/asm-offsets.s
-	$(call filechk,gen-asm-offsets)
-
 archclean:
 	$(Q)$(MAKE) $(clean)=arch/i386/boot
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [RFC] Consistently use the name asm-offsets.h
@ 2005-09-08 21:39 Luck, Tony
  2005-09-08 22:09 ` Brian Gerst
  0 siblings, 1 reply; 7+ messages in thread
From: Luck, Tony @ 2005-09-08 21:39 UTC (permalink / raw)
  To: Sam Ravnborg, linux-arch, linux-kernel

The existing ia64 specific rule to generate offsets.h
has to "echo #define IA64_TASK_SIZE 0 > include/asm-ia64/offsets.h"
before building asm-offsets.s to avoid compilation errors.

So long as you take care of this somehow in the generic version, go wild.

-Tony

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Consistently use the name asm-offsets.h
  2005-09-08 21:15 Sam Ravnborg
@ 2005-09-08 21:47 ` Sam Ravnborg
  2005-09-09 11:17   ` Ralf Baechle
  2005-09-09 11:25 ` Jan-Benedict Glaw
  1 sibling, 1 reply; 7+ messages in thread
From: Sam Ravnborg @ 2005-09-08 21:47 UTC (permalink / raw)
  To: linux-arch, linux-kernel

mips has it own private gen-asm-offset macro,

The important part being:

sed -ne "/^@@@/s///p"; \

compared to the generic one:

sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \

I wonder why the assembly for mips is so different...
So for now two architectures needs special care: mips and ia64.

	Sam

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Consistently use the name asm-offsets.h
  2005-09-08 21:39 [RFC] Consistently use the name asm-offsets.h Luck, Tony
@ 2005-09-08 22:09 ` Brian Gerst
  2005-09-09  8:04   ` Paul Jackson
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Gerst @ 2005-09-08 22:09 UTC (permalink / raw)
  To: Luck, Tony; +Cc: Sam Ravnborg, linux-arch, linux-kernel

Luck, Tony wrote:
> The existing ia64 specific rule to generate offsets.h
> has to "echo #define IA64_TASK_SIZE 0 > include/asm-ia64/offsets.h"
> before building asm-offsets.s to avoid compilation errors.
> 
> So long as you take care of this somehow in the generic version, go wild.
> 

The right fix is to get rid of that god-awful circular dependency on 
offset.h

--
				Brian Gerst

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Consistently use the name asm-offsets.h
  2005-09-08 22:09 ` Brian Gerst
@ 2005-09-09  8:04   ` Paul Jackson
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Jackson @ 2005-09-09  8:04 UTC (permalink / raw)
  To: Brian Gerst; +Cc: tony.luck, sam, linux-arch, linux-kernel

Brian wrote:
> The right fix is to get rid of that god-awful circular dependency on 
> offset.h

Just try making such a patch.  I double triple dare you.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.925.600.0401

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Consistently use the name asm-offsets.h
  2005-09-08 21:47 ` Sam Ravnborg
@ 2005-09-09 11:17   ` Ralf Baechle
  0 siblings, 0 replies; 7+ messages in thread
From: Ralf Baechle @ 2005-09-09 11:17 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-arch, linux-kernel

On Thu, Sep 08, 2005 at 11:47:42PM +0200, Sam Ravnborg wrote:

> mips has it own private gen-asm-offset macro,
> 
> The important part being:
> 
> sed -ne "/^@@@/s///p"; \
> 
> compared to the generic one:
> 
> sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
> 
> I wonder why the assembly for mips is so different...
> So for now two architectures needs special care: mips and ia64.

MIPS uses it's own rules only for readability of the generated file.

  Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Consistently use the name asm-offsets.h
  2005-09-08 21:15 Sam Ravnborg
  2005-09-08 21:47 ` Sam Ravnborg
@ 2005-09-09 11:25 ` Jan-Benedict Glaw
  1 sibling, 0 replies; 7+ messages in thread
From: Jan-Benedict Glaw @ 2005-09-09 11:25 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-arch, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1336 bytes --]

On Thu, 2005-09-08 23:15:39 +0200, Sam Ravnborg <sam@ravnborg.org> wrote:
> I suggest moving all the logic required to build the asm-offsets.h file
> to a common places and do proper search&replace in architectures to make
> the naming consitent. For frv, m32r and sparc64 we will need to create a
> dummy file until they start using asm-offsets.h

Yay! Another rule we can kill from arch-specific Makefile :-)

> --- a/Makefile
> +++ b/Makefile
> @@ -776,14 +776,14 @@ $(vmlinux-dirs): prepare-all scripts
>  # A multi level approach is used. prepare1 is updated first, then prepare0.
>  # prepare-all is the collection point for the prepare targets.
>  
> -.PHONY: prepare-all prepare prepare0 prepare1 prepare2
> +.PHONY: prepare-all prepare prepare0 prepare1 prepare2 prepare3
>  
> -# prepare2 is used to check if we are building in a separate output directory,
> +# preparei3 is used to check if we are building in a separate output directory,
           ^^^
Typo?

MfG, JBG

-- 
Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-09-09 11:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-08 21:39 [RFC] Consistently use the name asm-offsets.h Luck, Tony
2005-09-08 22:09 ` Brian Gerst
2005-09-09  8:04   ` Paul Jackson
  -- strict thread matches above, loose matches on Subject: below --
2005-09-08 21:15 Sam Ravnborg
2005-09-08 21:47 ` Sam Ravnborg
2005-09-09 11:17   ` Ralf Baechle
2005-09-09 11:25 ` Jan-Benedict Glaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox