Commit 5d31b48c authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] new kernel configuration 1/7

This adds the needed kbuild changes:
- support to compile host libraries and c++ programs
- change config calls into kconfig
parent 5e5ac463
...@@ -46,7 +46,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ ...@@ -46,7 +46,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
TOPDIR := $(CURDIR) TOPDIR := $(CURDIR)
HOSTCC = gcc HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
CROSS_COMPILE = CROSS_COMPILE =
...@@ -171,7 +173,8 @@ AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS) ...@@ -171,7 +173,8 @@ 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 GENKSYMS PERL UTS_MACHINE CPP AR NM STRIP OBJCOPY OBJDUMP MAKE GENKSYMS PERL UTS_MACHINE \
HOSTCXX HOSTCXXFLAGS
export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
...@@ -247,21 +250,7 @@ ifdef include-config ...@@ -247,21 +250,7 @@ ifdef include-config
# In this section, we need .config # In this section, we need .config
# If .config doesn't exist - tough luck -include ..config.cmd
.config: arch/$(ARCH)/config.in # FIXME $(shell find . -name Config.in)
@echo '***'
@if [ -f $@ ]; then \
echo '*** The tree was updated, so your .config may be'; \
echo '*** out of date!'; \
else \
echo '*** You have not yet configured your kernel!'; \
fi
@echo '***'
@echo '*** Please run some configurator (e.g. "make oldconfig" or'
@echo '*** "make menuconfig" or "make xconfig").'
@echo '***'
@exit 1
ifdef CONFIG_MODULES ifdef CONFIG_MODULES
export EXPORT_FLAGS := -DEXPORT_SYMTAB export EXPORT_FLAGS := -DEXPORT_SYMTAB
...@@ -429,11 +418,8 @@ include/config/MARKER: scripts/split-include include/linux/autoconf.h ...@@ -429,11 +418,8 @@ include/config/MARKER: scripts/split-include include/linux/autoconf.h
# with it and forgot to run make oldconfig # with it and forgot to run make oldconfig
include/linux/autoconf.h: .config include/linux/autoconf.h: .config
@echo '***' +@$(call descend,scripts/kconfig,scripts/kconfig/conf)
@echo '*** You changed .config w/o running make *config?' ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
@echo '*** Please run "make oldconfig"'
@echo '***'
@exit 1
# Generate some files # Generate some files
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -649,34 +635,36 @@ ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) ...@@ -649,34 +635,36 @@ ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
.PHONY: oldconfig xconfig menuconfig config \ .PHONY: oldconfig xconfig menuconfig config \
make_with_config make_with_config
xconfig: scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf: scripts/fixdep FORCE
$(Q)$(MAKE) -f scripts/Makefile.build obj=scripts scripts/kconfig.tk +@$(call descend,scripts/kconfig,$@)
wish -f scripts/kconfig.tk
xconfig: scripts/kconfig/qconf
./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
menuconfig: menuconfig: scripts/kconfig/mconf
$(Q)$(MAKE) -f scripts/Makefile.build obj=scripts lxdialog $(Q)$(MAKE) -f scripts/Makefile.build obj=scripts lxdialog
$(CONFIG_SHELL) $(src)/scripts/Menuconfig arch/$(ARCH)/config.in ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
config: config: scripts/kconfig/conf
$(CONFIG_SHELL) $(src)/scripts/Configure arch/$(ARCH)/config.in ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
oldconfig: oldconfig: scripts/kconfig/conf
$(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
randconfig: randconfig: scripts/kconfig/conf
$(CONFIG_SHELL) $(src)/scripts/Configure -r arch/$(ARCH)/config.in ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
allyesconfig: allyesconfig: scripts/kconfig/conf
$(CONFIG_SHELL) $(src)/scripts/Configure -y arch/$(ARCH)/config.in ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
allnoconfig: allnoconfig: scripts/kconfig/conf
$(CONFIG_SHELL) $(src)/scripts/Configure -n arch/$(ARCH)/config.in ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
allmodconfig: allmodconfig: scripts/kconfig/conf
$(CONFIG_SHELL) $(src)/scripts/Configure -m arch/$(ARCH)/config.in ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
defconfig: defconfig: scripts/kconfig/conf
yes '' | $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
### ###
# Cleaning is done on three levels. # Cleaning is done on three levels.
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
EXTRA_TARGETS := fixdep split-include docproc conmakehash EXTRA_TARGETS := fixdep split-include docproc conmakehash
subdir- := lxdialog subdir- := lxdialog kconfig
# Yikes. We need to build this stuff here even if the user only wants # Yikes. We need to build this stuff here even if the user only wants
# modules. # modules.
......
...@@ -171,30 +171,96 @@ targets += $(multi-used-y) $(multi-used-m) ...@@ -171,30 +171,96 @@ targets += $(multi-used-y) $(multi-used-m)
# Compile programs on the host # Compile programs on the host
# =========================================================================== # ===========================================================================
# host-progs := bin2hex
# Will compile bin2hex.c and create an executable named bin2hex
#
# host-progs := lxdialog
# lxdialog-objs := checklist.o lxdialog.o
# Will compile lxdialog.c and checklist.c, and then link the executable
# lxdialog, based on checklist.o and lxdialog.o
#
# host-progs := qconf
# qconf-cxxobjs := qconf.o
# qconf-objs := menu.o
# Will compile qconf as a C++ program, and menu as a C program.
# They are linked as C++ code to the executable qconf
# host-progs := conf
# conf-objs := conf.o libkconfig.so
# libkconfig-objs := expr.o type.o
# Will create a shared library named libkconfig.so that consist of
# expr.o and type.o (they are both compiled as C code and the object file
# are made as position independent code).
# conf.c is compiled as a c program, and conf.o is linked together with
# libkconfig.so as the executable conf.
# Note: Shared libraries consisting of C++ files are not supported
#
quiet_cmd_host_cc__c = HOSTCC $@ # Create executable from a single .c file
cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \ # host-csingle -> Executable
quiet_cmd_host-csingle = HOSTCC $@
cmd_host-csingle = $(HOSTCC) -Wp,-MD,$(depfile) \
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
$(HOST_LOADLIBES) -o $@ $< $(HOST_LOADLIBES) -o $@ $<
$(host-csingle): %: %.c FORCE
$(host-progs-single): %: %.c FORCE $(call if_changed_dep,host-csingle)
$(call if_changed_dep,host_cc__c)
# Link an executable based on list of .o files, all plain c
quiet_cmd_host_cc_o_c = HOSTCC $@ # host-cmulti -> executable
cmd_host_cc_o_c = $(HOSTCC) -Wp,-MD,$(depfile) \ quiet_cmd_host-cmulti = HOSTLD $@
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) -c -o $@ $< cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
$(addprefix $(obj)/,$($(@F)-objs)) \
$(host-progs-multi-objs): %.o: %.c FORCE $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
$(call if_changed_dep,host_cc_o_c) $(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
$(call if_changed,host-cmulti)
quiet_cmd_host_cc__o = HOSTLD $@
cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(subst $(obj)/,,$@)-objs)) \ # Create .o file from a single .c file
$(HOST_LOADLIBES) # host-cobjs -> .o
quiet_cmd_host-cobjs = HOSTCC $@
$(host-progs-multi): %: $(host-progs-multi-objs) FORCE cmd_host-cobjs = $(HOSTCC) -Wp,-MD,$(depfile) \
$(call if_changed,host_cc__o) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
$(HOSTCFLAGS_$(@F)) -c -o $@ $<
targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi) $(host-cobjs): %.o: %.c FORCE
$(call if_changed_dep,host-cobjs)
# Link an executable based on list of .o files, a mixture of .c and .cc
# host-cxxmulti -> executable
quiet_cmd_host-cxxmulti = HOSTLD $@
cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \
$(foreach o,objs cxxobjs,\
$(addprefix $(obj)/,$($(@F)-$(o)))) \
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
$(host-cxxmulti): %: $(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) -Wp,-MD,$(depfile) \
$(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
$(HOSTCXXFLAGS_$(@F)) -c -o $@ $<
$(host-cxxobjs): %.o: %.cc FORCE
$(call if_changed_dep,host-cxxobjs)
# Compile .c file, create position independent .o file
# host-cshobjs -> .o
quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
cmd_host-cshobjs = $(HOSTCC) -Wp,-MD,$(depfile) -fPIC\
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
$(HOSTCFLAGS_$(@F)) -c -o $@ $<
$(host-cshobjs): %.o: %.c FORCE
$(call if_changed_dep,host-cshobjs)
# Link a shared library, based on position independent .o files
# *.o -> .so shared library (host-cshlib)
quiet_cmd_host-cshlib = HOSTLLD -shared $@
cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
$(addprefix $(obj)/,$($(@F:.so=-objs))) \
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
$(host-cshlib): %: $(host-cshobjs) FORCE
$(call if_changed,host-cshlib)
targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
$(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
# Descending # Descending
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
...@@ -57,9 +57,33 @@ real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y) ...@@ -57,9 +57,33 @@ real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)
# Only build module versions for files which are selected to be built # Only build module versions for files which are selected to be built
export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m)) export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m))
host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m))) # C code
host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m))) # Executables compiled from a single .c file
host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs)) host-csingle := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m)))
# C executables linked based on several .o files
host-cmulti := $(foreach m,$(host-progs),\
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
# Object (.o) files compiled from .c files
host-cobjs := $(sort $(foreach m,$(host-progs),$($(m)-objs)))
# C++ code
# C++ executables compiled from at least on .cc file
# and zero or more .c files
host-cxxmulti := $(foreach m,$(host-progs),$(if $($(m)-cxxobjs),$(m)))
# C++ Object (.o) files compiled from .cc files
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
# Shared libaries (only .c supported)
# Shared libraries (.so) - all .so files referenced in "xxx-objs"
host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
# Remove .so files from "xxx-objs"
host-cobjs := $(filter-out %.so,$(host-cobjs))
#Object (.o) files used by the shared libaries
host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
# Add subdir path # Add subdir path
...@@ -76,9 +100,13 @@ multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) ...@@ -76,9 +100,13 @@ multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
host-progs := $(addprefix $(obj)/,$(host-progs)) host-progs := $(addprefix $(obj)/,$(host-progs))
host-progs-single := $(addprefix $(obj)/,$(host-progs-single)) host-csingle := $(addprefix $(obj)/,$(host-csingle))
host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs)) host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
# 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
......
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