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; \
TOPDIR := $(CURDIR)
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
CROSS_COMPILE =
......@@ -171,7 +173,8 @@ AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
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 CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
......@@ -247,21 +250,7 @@ ifdef include-config
# In this section, we need .config
# If .config doesn't exist - tough luck
.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
-include ..config.cmd
ifdef CONFIG_MODULES
export EXPORT_FLAGS := -DEXPORT_SYMTAB
......@@ -429,11 +418,8 @@ include/config/MARKER: scripts/split-include include/linux/autoconf.h
# with it and forgot to run make oldconfig
include/linux/autoconf.h: .config
@echo '***'
@echo '*** You changed .config w/o running make *config?'
@echo '*** Please run "make oldconfig"'
@echo '***'
@exit 1
+@$(call descend,scripts/kconfig,scripts/kconfig/conf)
./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
# Generate some files
# ---------------------------------------------------------------------------
......@@ -649,34 +635,36 @@ ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
.PHONY: oldconfig xconfig menuconfig config \
make_with_config
xconfig:
$(Q)$(MAKE) -f scripts/Makefile.build obj=scripts scripts/kconfig.tk
wish -f scripts/kconfig.tk
scripts/kconfig/conf scripts/kconfig/mconf scripts/kconfig/qconf: scripts/fixdep FORCE
+@$(call descend,scripts/kconfig,$@)
xconfig: scripts/kconfig/qconf
./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
menuconfig:
menuconfig: scripts/kconfig/mconf
$(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_SHELL) $(src)/scripts/Configure arch/$(ARCH)/config.in
config: scripts/kconfig/conf
./scripts/kconfig/conf arch/$(ARCH)/Kconfig
oldconfig:
$(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in
oldconfig: scripts/kconfig/conf
./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
randconfig:
$(CONFIG_SHELL) $(src)/scripts/Configure -r arch/$(ARCH)/config.in
randconfig: scripts/kconfig/conf
./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
allyesconfig:
$(CONFIG_SHELL) $(src)/scripts/Configure -y arch/$(ARCH)/config.in
allyesconfig: scripts/kconfig/conf
./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
allnoconfig:
$(CONFIG_SHELL) $(src)/scripts/Configure -n arch/$(ARCH)/config.in
allnoconfig: scripts/kconfig/conf
./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
allmodconfig:
$(CONFIG_SHELL) $(src)/scripts/Configure -m arch/$(ARCH)/config.in
allmodconfig: scripts/kconfig/conf
./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
defconfig:
yes '' | $(CONFIG_SHELL) $(src)/scripts/Configure -d arch/$(ARCH)/config.in
defconfig: scripts/kconfig/conf
./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
###
# Cleaning is done on three levels.
......
......@@ -11,7 +11,7 @@
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
# modules.
......
......@@ -171,30 +171,96 @@ targets += $(multi-used-y) $(multi-used-m)
# 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 $@
cmd_host_cc__c = $(HOSTCC) -Wp,-MD,$(depfile) \
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
$(HOST_LOADLIBES) -o $@ $<
$(host-progs-single): %: %.c FORCE
$(call if_changed_dep,host_cc__c)
quiet_cmd_host_cc_o_c = HOSTCC $@
cmd_host_cc_o_c = $(HOSTCC) -Wp,-MD,$(depfile) \
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) -c -o $@ $<
$(host-progs-multi-objs): %.o: %.c FORCE
$(call if_changed_dep,host_cc_o_c)
quiet_cmd_host_cc__o = HOSTLD $@
cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(subst $(obj)/,,$@)-objs)) \
$(HOST_LOADLIBES)
$(host-progs-multi): %: $(host-progs-multi-objs) FORCE
$(call if_changed,host_cc__o)
targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi)
# Create executable from a single .c file
# host-csingle -> Executable
quiet_cmd_host-csingle = HOSTCC $@
cmd_host-csingle = $(HOSTCC) -Wp,-MD,$(depfile) \
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
$(HOST_LOADLIBES) -o $@ $<
$(host-csingle): %: %.c FORCE
$(call if_changed_dep,host-csingle)
# Link an executable based on list of .o files, all plain c
# host-cmulti -> executable
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
$(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) -Wp,-MD,$(depfile) \
$(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
$(HOSTCFLAGS_$(@F)) -c -o $@ $<
$(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
# ---------------------------------------------------------------------------
......
......@@ -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
export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m))
host-progs-single := $(foreach m,$(host-progs),$(if $($(m)-objs),,$(m)))
host-progs-multi := $(foreach m,$(host-progs),$(if $($(m)-objs),$(m)))
host-progs-multi-objs := $(foreach m,$(host-progs-multi),$($(m)-objs))
# C code
# Executables compiled from a single .c file
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
......@@ -75,10 +99,14 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
host-progs := $(addprefix $(obj)/,$(host-progs))
host-progs-single := $(addprefix $(obj)/,$(host-progs-single))
host-progs-multi := $(addprefix $(obj)/,$(host-progs-multi))
host-progs-multi-objs := $(addprefix $(obj)/,$(host-progs-multi-objs))
host-progs := $(addprefix $(obj)/,$(host-progs))
host-csingle := $(addprefix $(obj)/,$(host-csingle))
host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
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
# 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