aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.osdl.org>2003-09-21 18:37:14 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-09-21 18:37:14 -0700
commitefe775ab6d8ecd198295d9c138c2044605d3d47b (patch)
tree5ea7ea4c24f29203bc53c3338233656a71509e8a /scripts
parent1c20618e2767bdcbe27e331a118a6f0e58eb64d2 (diff)
parent9bb8df1d7a1b8d655e71dd42a7921497168cb7a1 (diff)
downloadhistory-efe775ab6d8ecd198295d9c138c2044605d3d47b.tar.gz
Merge bk://linux-sam.bkbits.net/kbuild
into home.osdl.org:/home/torvalds/v2.5/linux
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build10
-rw-r--r--scripts/Makefile.clean2
-rw-r--r--scripts/Makefile.lib61
-rw-r--r--scripts/Makefile.modpost2
-rw-r--r--scripts/kconfig/Makefile3
-rw-r--r--scripts/kconfig/conf.c30
-rwxr-xr-xscripts/mkspec4
7 files changed, 88 insertions, 24 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 6cbff76b23ef9..fe35136409979 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -14,6 +14,16 @@ include $(obj)/Makefile
include scripts/Makefile.lib
+ifneq ($(KBUILD_SRC),)
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+# Create directories for object files if directory does not exist
+# Needed when obj-y := dir/file.o syntax is used
+_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
+endif
+
+
ifdef EXTRA_TARGETS
$(warning kbuild: $(obj)/Makefile - Usage of EXTRA_TARGETS is obsolete in 2.5. Please fix!)
endif
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index dc734426699f3..7277dd208ead7 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -63,4 +63,4 @@ cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
# Usage:
# $(Q)$(MAKE) $(clean)=dir
-clean := -f scripts/Makefile.clean obj
+clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 398114524818c..badd18666b4ac 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -58,6 +58,11 @@ multi-objs := $(multi-objs-y) $(multi-objs-m)
# in the local directory
subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
+# $(obj-dirs) is a list of directories that contain object files
+obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
+obj-dirs += $(foreach f,$(host-progs), $(if $(dir $(f)),$(dir $(f))))
+obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs))))
+
# Replace multi-part objects by their individual parts, look at local dir only
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
@@ -107,6 +112,7 @@ 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))
+obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
host-progs := $(addprefix $(obj)/,$(host-progs))
host-csingle := $(addprefix $(obj)/,$(host-csingle))
host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
@@ -129,15 +135,46 @@ depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
# where foo and bar are the name of the modules.
basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F)))
modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname))))
-c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
- $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
- $(basename_flags) $(modname_flags)
-a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS)\
- $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
-hostc_flags = -Wp,-MD,$(depfile) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS)\
- $(HOSTCFLAGS_$(*F).o)
-hostcxx_flags = -Wp,-MD,$(depfile) $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS)\
- $(HOSTCXXFLAGS_$(*F).o)
+
+
+_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
+_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
+_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o)
+_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o)
+
+
+# If building the kernel in a separate objtree expand all occurrences
+# of -Idir to -Idir -I$(srctree)/dir.
+# hereby allowing gcc to locate files in both trees. Local tree first.
+
+ifeq ($(KBUILD_SRC),)
+__c_flags = $(_c_flags)
+__a_flags = $(_a_flags)
+__hostc_flags = $(_hostc_flags)
+__hostcxx_flags = $(_hostcxx_flags)
+else
+flags = $(foreach o,$($(1)),\
+ $(if $(filter -I%,$(o)),$(patsubst -I%,-I$(srctree)/%,$(o)),$(o)))
+
+# -I$(obj) locate generated .h files
+# -I$(srctree)/$(src) locate .h files in srctree, from generated .c files
+# FIXME: Replace both with specific EXTRA_CFLAGS statements
+__c_flags = -I$(obj) -I$(srctree)/$(src) $(call flags,_c_flags)
+__a_flags = $(call flags,_a_flags)
+__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
+__hostcxx_flags = $(call flags,_hostcxx_flags)
+endif
+
+c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+ $(__c_flags) $(modkern_cflags) \
+ $(basename_flags) $(modname_flags)
+
+a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+ $(__a_flags) $(modkern_aflags)
+
+hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
+hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
+
ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS)
# Finds the multi-part object the current object will be linked into
@@ -225,14 +262,14 @@ if_changed_rule = $(if $(strip $? \
# If quiet is set, only print short version of command
-cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
+cmd = @$(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
# $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target>
# Usage is deprecated, because make do not see this as an invocation of make.
-descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)
+descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj=$(1) $(2)
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
# Usage:
# $(Q)$(MAKE) $(build)=dir
-build := -f scripts/Makefile.build obj
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 9416ae154422d..f1867d3a71187 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -35,7 +35,7 @@ targets += $(modules)
# Compile version info for unresolved symbols
quiet_cmd_cc_o_c = CC $@
- cmd_cc_o_c = $(CC) -Wp,-MD,$(depfile) $(CFLAGS) $(CFLAGS_MODULE) \
+ cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
-c -o $@ $<
$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 2189c334ad37d..99d4ac48efc61 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -40,6 +40,9 @@ allmodconfig: $(obj)/conf
defconfig: $(obj)/conf
$< -d arch/$(ARCH)/Kconfig
+%_defconfig: $(obj)/conf
+ $(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig
+
# Help text used by make help
help:
@echo ' oldconfig - Update current config utilising a line-oriented program'
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fa320f79a5da5..08da496f83690 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -26,6 +26,7 @@ enum {
set_no,
set_random
} input_mode = ask_all;
+char *defconfig_file;
static int indent = 1;
static int valid_stdin = 1;
@@ -483,11 +484,12 @@ static void check_conf(struct menu *menu)
int main(int ac, char **av)
{
+ int i = 1;
const char *name;
struct stat tmpstat;
- if (ac > 1 && av[1][0] == '-') {
- switch (av[1][1]) {
+ if (ac > i && av[i][0] == '-') {
+ switch (av[i++][1]) {
case 'o':
input_mode = ask_new;
break;
@@ -498,6 +500,15 @@ int main(int ac, char **av)
case 'd':
input_mode = set_default;
break;
+ case 'D':
+ input_mode = set_default;
+ defconfig_file = av[i++];
+ if (!defconfig_file) {
+ printf("%s: No default config file specified\n",
+ av[0]);
+ exit(1);
+ }
+ break;
case 'n':
input_mode = set_no;
break;
@@ -516,18 +527,21 @@ int main(int ac, char **av)
printf("%s [-o|-s] config\n", av[0]);
exit(0);
}
- name = av[2];
- } else
- name = av[1];
+ }
+ name = av[i];
+ if (!name) {
+ printf("%s: Kconfig file missing\n", av[0]);
+ }
conf_parse(name);
//zconfdump(stdout);
switch (input_mode) {
case set_default:
- name = conf_get_default_confname();
- if (conf_read(name)) {
+ if (!defconfig_file)
+ defconfig_file = conf_get_default_confname();
+ if (conf_read(defconfig_file)) {
printf("***\n"
"*** Can't find default configuration \"%s\"!\n"
- "***\n", name);
+ "***\n", defconfig_file);
exit(1);
}
break;
diff --git a/scripts/mkspec b/scripts/mkspec
index c8795d20fde91..841512debca53 100755
--- a/scripts/mkspec
+++ b/scripts/mkspec
@@ -27,7 +27,7 @@ echo "Summary: The Linux Kernel"
echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//g"
# we need to determine the NEXT version number so that uname and
# rpm -q will agree
-echo "Release: `. scripts/mkversion`"
+echo "Release: `. $srctree/scripts/mkversion`"
echo "License: GPL"
echo "Group: System Environment/Kernel"
echo "Vendor: The Linux Community"
@@ -45,7 +45,7 @@ echo "%prep"
echo "%setup -q"
echo ""
echo "%build"
-echo "make clean oldconfig all"
+echo "make clean all"
echo ""
echo "%install"
echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'