| Submitter | Sam Ravnborg |
|---|---|
| Date | 2009-09-20 10:31:09 |
| Message ID | <20090920103108.GA26667@merkur.ravnborg.org> |
| Download | mbox | patch |
| Permalink | /patch/48894/ |
| State | New |
| Headers | show |
Comments
> So when I move that file to include/generated I will break users script > silently - sigh. It's a possibility. If so, they will probably have a far easier time handling a simple change in the location of the file than an entirely new scheme where there is no simple file that contains the same string. > Revised patch following your guidelines below. > Does this look better to you? Yes, I like it! I wonder if we might want to treat SUBARCH the same way, though. I'm not sure that matters except for the ARCH=um case, but there I have the impression it has exactly the same utility as $ARCH otherwise, so it makes sense to me to treat it similarly. Thanks, Roland -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi! > > > Another approach would be to ask kbuild for > > > this information so we do not expose various filenames to the > > > outer world. > > > > For shell scripts and makefiles, running a command like make and retrieving > > its output via pipe is de rigueur. But for some other programs it might be > > substantially less hassle to just read plain files. That's what I was > > thinking, anyway. (I only really think that $ARCH is something that anyone > > would want to fetch before they'd run make anyway, and I guess $SUBARCH in > > the case of ARCH=um, but not $CROSS_COMPILE.) > > > > > This is analogous to the way we ask for > > > kernelrelease and kernelversion these days. > > > > Except that include/config/kernel.release is there for all to see (when > > referring to /lib/modules/.../build directory, e.g.), so perhaps some > > people are in fact using that. > > So when I move that file to include/generated I will break users script silently - sigh. > > Revised patch following your guidelines below. > Does this look better to you? Well.. having that option in .config, so it can be easily transported between trees (as proposed originally) would be even nicer, but I guess this is better than nothing. Pavel
Patch
diff --git a/Makefile b/Makefile index 305d005..a45b0a2 100644 --- a/Makefile +++ b/Makefile @@ -179,9 +179,46 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ # Alternatively CROSS_COMPILE can be set in the environment. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile +# +# To force ARCH and CROSS_COMPILE settings include kernel.* files +# in the kernel tree - do not patch this file. export KBUILD_BUILDHOST := $(SUBARCH) -ARCH ?= $(SUBARCH) -CROSS_COMPILE ?= + +# Kbuild save the ARCH and CROSS_COMPILE setting in kernel.* files. +# Restore these settings and check that user did not specify +# conflicting values. + +saved_arch := $(shell cat include/generated/kernel.arch 2> /dev/null) +saved_cross := $(shell cat include/generated/kernel.cross 2> /dev/null) + +ifneq ($(CROSS_COMPILE),) + ifneq ($(saved_cross),) + ifneq ($(CROSS_COMPILE),$(saved_cross)) + $(error CROSS_COMPILE changed from \ + "$(saved_cross)" to \ + to "$(CROSS_COMPILE)". \ + Use "make mrproper" to fix it up) + endif + endif +else + CROSS_COMPILE := $(saved_cross) +endif + +ifneq ($(ARCH),) + ifneq ($(saved_arch),) + ifneq ($(saved_arch),$(ARCH)) + $(error ARCH changed from \ + "$(saved_arch)" to "$(ARCH)". \ + Use "make mrproper" to fix it up) + endif + endif +else + ifneq ($(saved_arch),) + ARCH := $(saved_arch) + else + ARCH := $(SUBARCH) + endif +endif # Architecture as present in compile.h UTS_MACHINE := $(ARCH) @@ -446,6 +483,11 @@ ifeq ($(config-targets),1) include $(srctree)/arch/$(SRCARCH)/Makefile export KBUILD_DEFCONFIG KBUILD_KCONFIG +# save ARCH & CROSS_COMPILE settings +$(shell mkdir -p include/generated && \ + echo $(ARCH) > include/generated/kernel.arch && \ + echo $(CROSS_COMPILE) > include/generated/kernel.cross) + config: scripts_basic outputmakefile FORCE $(Q)mkdir -p include/linux include/config $(Q)$(MAKE) $(build)=scripts/kconfig $@