Commit 09384ba9 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: include arch-Makefile in common place

The top-level Makefile is separated into two parts, one which does
include .config, so it can access CONFIG_FOO, and one which does not,
since it may not even exist yet (make *config).

However, both parts need to include arch/$(ARCH)/Makefile, be it for 
arch-specific settings or just for archclean/archmrproper.

So we now include arch/$(ARCH)/Makefile before the config/noconfig split,
which also has the advantage of giving us the arch-specific build dirs
(e.g. arch/i386/{kernel,mm,lib}) in both cases.

In addition, fix a couple of small glitches (make menuconfig, make 
modules_install, proper output when descending)
parent dc5b8833
...@@ -104,12 +104,13 @@ ifndef KBUILD_VERBOSE ...@@ -104,12 +104,13 @@ ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 1 KBUILD_VERBOSE = 1
endif endif
MAKEFLAGS += --no-print-directory
# If the user wants quiet mode, echo short versions of the commands # If the user wants quiet mode, echo short versions of the commands
# only and suppress the 'Entering/Leaving directory' messages # only
ifneq ($(KBUILD_VERBOSE),1) ifneq ($(KBUILD_VERBOSE),1)
quiet=quiet_ quiet=quiet_
MAKEFLAGS += --no-print-directory
endif endif
# If the user is running make -s (silent mode), suppress echoing of # If the user is running make -s (silent mode), suppress echoing of
...@@ -121,9 +122,16 @@ endif ...@@ -121,9 +122,16 @@ endif
export quiet KBUILD_VERBOSE export quiet KBUILD_VERBOSE
# # Paths to obj / src tree
# Include the make variables (CC, etc...)
# src := .
obj := .
srctree := .
objtree := .
export srctree objtree
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld LD = $(CROSS_COMPILE)ld
...@@ -144,24 +152,21 @@ CFLAGS_MODULE = $(MODFLAGS) ...@@ -144,24 +152,21 @@ CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE = $(MODFLAGS) AFLAGS_MODULE = $(MODFLAGS)
CFLAGS_KERNEL = CFLAGS_KERNEL =
AFLAGS_KERNEL = AFLAGS_KERNEL =
EXPORT_FLAGS =
NOSTDINC_FLAGS = -nostdinc -iwithprefix include NOSTDINC_FLAGS = -nostdinc -iwithprefix include
CPPFLAGS := -D__KERNEL__ -Iinclude
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
-fomit-frame-pointer -fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CONFIG_SHELL TOPDIR HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL CPP AR NM STRIP OBJCOPY OBJDUMP MAKE MAKEFILES GENKSYMS PERL
export CPPFLAGS EXPORT_FLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
src := .
obj := .
srctree := $(TOPDIR)
objtree := $(TOPDIR)
export srctree objtree
# The temporary file to save gcc -MD generated dependencies must not # The temporary file to save gcc -MD generated dependencies must not
# contain a comma # contain a comma
depfile = $(subst $(comma),_,$(@D)/.$(@F).d) depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
...@@ -184,8 +189,44 @@ scripts/docproc scripts/fixdep scripts/split-include : scripts ; ...@@ -184,8 +189,44 @@ scripts/docproc scripts/fixdep scripts/split-include : scripts ;
scripts: scripts:
@$(call descend,scripts,) @$(call descend,scripts,)
# Objects we will link into vmlinux / subdirs we need to visit
# ---------------------------------------------------------------------------
init-y := init/
drivers-y := drivers/ sound/
net-y := net/
libs-y := lib/
core-y :=
SUBDIRS :=
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
include-config := 1
-include .config
endif
include arch/$(ARCH)/Makefile
core-y += kernel/ mm/ fs/ ipc/ security/
SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
$(net-y) $(net-m) $(libs-y) $(libs-m)))
ALL_SUBDIRS := $(SUBDIRS) $(patsubst %/,%,$(filter %/, $(init-n) $(init-) \
$(core-n) $(core-) $(drivers-n) $(drivers-) \
$(net-n) $(net-) $(libs-n) $(libs-)))
init-y := $(patsubst %/, %/built-in.o, $(init-y))
core-y := $(patsubst %/, %/built-in.o, $(core-y))
drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
net-y := $(patsubst %/, %/built-in.o, $(net-y))
libs-y := $(patsubst %/, %/lib.a, $(libs-y))
ifdef include-config
# Here goes the main Makefile # Here goes the main Makefile
# =========================================================================== # ===========================================================================
# #
...@@ -196,8 +237,6 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -196,8 +237,6 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
# In this section, we need .config # In this section, we need .config
-include .config
# If .config doesn't exist - tough luck # If .config doesn't exist - tough luck
.config: arch/$(ARCH)/config.in $(shell find . -name Config.in) .config: arch/$(ARCH)/config.in $(shell find . -name Config.in)
...@@ -214,6 +253,10 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -214,6 +253,10 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
@echo '***' @echo '***'
@exit 1 @exit 1
ifdef CONFIG_MODULES
export EXPORT_FLAGS := -DEXPORT_SYMTAB
endif
# #
# INSTALL_PATH specifies where to place the updated kernel and system map # INSTALL_PATH specifies where to place the updated kernel and system map
# images. Uncomment if you want to place them anywhere other than root. # images. Uncomment if you want to place them anywhere other than root.
...@@ -230,45 +273,6 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -230,45 +273,6 @@ ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
export MODLIB export MODLIB
#
# standard CFLAGS
#
CPPFLAGS := -D__KERNEL__ -I$(objtree)/include
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
-fomit-frame-pointer -fno-strict-aliasing -fno-common
AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
ifdef CONFIG_MODULES
EXPORT_FLAGS := -DEXPORT_SYMTAB
endif
# Link components for vmlinux
# ---------------------------------------------------------------------------
init-y := init/
drivers-y := drivers/ sound/
net-y := net/
libs-y := lib/
core-y :=
SUBDIRS :=
include arch/$(ARCH)/Makefile
core-y += kernel/ mm/ fs/ ipc/ security/
SUBDIRS += $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
$(net-y) $(net-m) $(libs-y) $(libs-m)))
init-y := $(patsubst %/, %/built-in.o, $(init-y))
core-y := $(patsubst %/, %/built-in.o, $(core-y))
drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
net-y := $(patsubst %/, %/built-in.o, $(net-y))
libs-y := $(patsubst %/, %/lib.a, $(libs-y))
$(warning $(SUBDIRS))
# Build vmlinux # Build vmlinux
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -364,7 +368,7 @@ prepare: include/linux/version.h include/asm include/config/MARKER ...@@ -364,7 +368,7 @@ prepare: include/linux/version.h include/asm include/config/MARKER
AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH) AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
arch/$(ARCH)/vmlinux.lds.s: arch/$(ARCH)/vmlinux.lds.S scripts FORCE arch/$(ARCH)/vmlinux.lds.s: %.s: %.S scripts FORCE
$(call if_changed_dep,as_s_S) $(call if_changed_dep,as_s_S)
targets += arch/$(ARCH)/vmlinux.lds.s targets += arch/$(ARCH)/vmlinux.lds.s
...@@ -486,7 +490,7 @@ ifdef CONFIG_MODULES ...@@ -486,7 +490,7 @@ ifdef CONFIG_MODULES
# Build modules # Build modules
ifdef CONFIG_MODVERSIONS ifdef CONFIG_MODVERSIONS
MODFLAGS += -include $(objtree)/include/linux/modversions.h MODFLAGS += -include include/linux/modversions.h
endif endif
.PHONY: modules .PHONY: modules
...@@ -520,7 +524,7 @@ _modinst_post: ...@@ -520,7 +524,7 @@ _modinst_post:
.PHONY: $(patsubst %, _modinst_%, $(SUBDIRS)) .PHONY: $(patsubst %, _modinst_%, $(SUBDIRS))
$(patsubst %, _modinst_%, $(SUBDIRS)) : $(patsubst %, _modinst_%, $(SUBDIRS)) :
$(descend,$(patsubst _modinst_%,%,$@),modules_install) @$(call descend,$(patsubst _modinst_%,%,$@),modules_install)
else # CONFIG_MODULES else # CONFIG_MODULES
...@@ -584,7 +588,7 @@ rpm: clean spec ...@@ -584,7 +588,7 @@ rpm: clean spec
rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \ rpm -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \
rm $(TOPDIR)/../$(KERNELPATH).tar.gz rm $(TOPDIR)/../$(KERNELPATH).tar.gz
else # ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) else # ifdef include-config
ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
...@@ -691,7 +695,7 @@ MRPROPER_FILES += \ ...@@ -691,7 +695,7 @@ MRPROPER_FILES += \
.version .config* config.in config.old \ .version .config* config.in config.old \
.menuconfig.log \ .menuconfig.log \
include/asm \ include/asm \
.hdepend $(TOPDIR)/include/linux/modversions.h \ .hdepend include/linux/modversions.h \
tags TAGS kernel.spec \ tags TAGS kernel.spec \
.tmp* .tmp*
...@@ -699,11 +703,7 @@ MRPROPER_FILES += \ ...@@ -699,11 +703,7 @@ MRPROPER_FILES += \
MRPROPER_DIRS += \ MRPROPER_DIRS += \
.tmp_export-objs \ .tmp_export-objs \
include/config \ include/config \
$(TOPDIR)/include/linux/modules include/linux/modules
# That's our way to know about arch specific cleanup.
include arch/$(ARCH)/Makefile
clean: archclean clean: archclean
@echo 'Cleaning up' @echo 'Cleaning up'
...@@ -839,10 +839,11 @@ else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -839,10 +839,11 @@ else # ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
$(MAKE) $@ $(MAKE) $@
endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
endif # ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) endif # ifdef include-config
# FIXME Should go into a make.lib or something # FIXME Should go into a make.lib or something
# =========================================================================== # ===========================================================================
echo_target = $@ echo_target = $@
a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \ a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \
...@@ -899,6 +900,9 @@ endef ...@@ -899,6 +900,9 @@ endef
# $(call descend,<dir>,<target>) # $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target> # Recursively call a sub-make in <dir> with target <target>
descend = $(MAKE) -C $(1) $(2) ifeq ($(KBUILD_VERBOSE),1)
descend = echo '$(MAKE) -f $(1)/Makefile $(2)';
endif
descend += $(MAKE) -f $(1)/Makefile obj=$(1) $(2)
FORCE: FORCE:
...@@ -51,7 +51,7 @@ $(obj)/kconfig.tk: $(srctree)/arch/$(ARCH)/config.in $(obj)/tkparse FORCE ...@@ -51,7 +51,7 @@ $(obj)/kconfig.tk: $(srctree)/arch/$(ARCH)/config.in $(obj)/tkparse FORCE
# Targets hardcoded and wellknow in top-level makefile # Targets hardcoded and wellknow in top-level makefile
.PHONY: lxdialog .PHONY: lxdialog
lxdialog: lxdialog:
$(call descend,lxdialog,) $(call descend,scripts/lxdialog,)
# fixdep is needed to compile other host programs # fixdep is needed to compile other host programs
$(obj)/split-include $(obj)/docproc $(addprefix $(obj)/,$(tkparse-objs)) \ $(obj)/split-include $(obj)/docproc $(addprefix $(obj)/,$(tkparse-objs)) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment