summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile28
-rw-r--r--scripts/Makefile.build49
-rw-r--r--scripts/Makefile.lib13
-rw-r--r--scripts/Makefile.modinst6
-rw-r--r--scripts/kallsyms40
-rw-r--r--scripts/kallsyms.c148
-rw-r--r--scripts/lxdialog/Makefile8
7 files changed, 193 insertions, 99 deletions
diff --git a/scripts/Makefile b/scripts/Makefile
index 5ecc03a43242..eca3f1661bf4 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -8,31 +8,11 @@
# docproc: Preprocess .tmpl file in order to generate .sgml documentation
# conmakehash: Create arrays for initializing the kernel console tables
-EXTRA_TARGETS := fixdep split-include docproc conmakehash
+host-progs := fixdep split-include conmakehash docproc kallsyms
+build-targets := $(host-progs)
+# Let clean descend into subdirs
subdir- := lxdialog kconfig
-# Yikes. We need to build this stuff here even if the user only wants
-# modules.
-
-KBUILD_BUILTIN := 1
-
-# The following temporary rule will make sure that people's
-# trees get updated to the right permissions, since patch(1)
-# can't do it
-# ---------------------------------------------------------------------------
-
-host-progs := fixdep split-include conmakehash docproc
-
-include $(TOPDIR)/Rules.make
-
-
-# ---------------------------------------------------------------------------
-# Targets hardcoded and wellknow in top-level makefile
-.PHONY: lxdialog
-lxdialog:
- $(call descend,scripts/lxdialog,)
-
# fixdep is needed to compile other host programs
-$(obj)/split-include $(obj)/docproc \
-$(obj)/conmakehash lxdialog: $(obj)/fixdep
+$(addprefix $(obj)/,$(filter-out fixdep,$(host-progs))): $(obj)/fixdep
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f5f9a84fdd99..4bccbe923690 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -40,12 +40,14 @@ endif
ifdef L_TARGET
L_TARGET := $(obj)/$(L_TARGET)
else
+ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-)),)
O_TARGET := $(obj)/built-in.o
endif
+endif
__build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
- $(if $(KBUILD_MODULES),$(obj-m)) \
- $(subdir-ym)
+ $(if $(KBUILD_MODULES),$(obj-m:.o=.ko)) \
+ $(subdir-ym) $(build-targets)
@:
# Compile C sources (.c)
@@ -103,7 +105,9 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
$(call if_changed_dep,cc_o_c)
quiet_cmd_cc_lst_c = MKLST $@
-cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && sh scripts/makelst $*.o System.map $(OBJDUMP) > $@
+ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
+ $(CONFIG_SHELL) $(src)/scripts/makelst $*.o \
+ System.map $(OBJDUMP) > $@
%.lst: %.c FORCE
$(call if_changed_dep,cc_lst_c)
@@ -116,9 +120,6 @@ modkern_aflags := $(AFLAGS_KERNEL)
$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
-a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(NOSTDINC_FLAGS) \
- $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
-
quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
@@ -171,21 +172,29 @@ endif
#
# Rule to link composite objects
#
+quiet_cmd_link_multi-y = LD $@
+cmd_link_multi-y = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^)
-quiet_cmd_link_multi = LD $(quiet_modtag) $@
-cmd_link_multi = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.o=-objs))) $($(subst $(obj)/,,$(@:.o=-y)))),$^)
+quiet_cmd_link_multi-m = LD [M] $@
+cmd_link_multi-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.ko=-objs))) $($(subst $(obj)/,,$(@:.ko=-y)))),$^)
+
+quiet_cmd_link_single-m = LD [M] $@
+cmd_link_single-m = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $<
# We would rather have a list of rules like
# foo.o: $(foo-objs)
# but that's not so easy, so we rather make all composite objects depend
# on the set of all their parts
$(multi-used-y) : %.o: $(multi-objs-y) FORCE
- $(call if_changed,link_multi)
+ $(call if_changed,link_multi-y)
+
+$(multi-used-m:.o=.ko) : %.ko: $(multi-objs-m) FORCE
+ $(call if_changed,link_multi-m)
-$(multi-used-m) : %.o: $(multi-objs-m) FORCE
- $(call if_changed,link_multi)
+$(single-used-m:.o=.ko) : %.ko: %.o FORCE
+ $(call if_changed,link_single-m)
-targets += $(multi-used-y) $(multi-used-m)
+targets += $(multi-used-y) $(multi-used-m:.o=.ko) $(single-used-m:.o=.ko)
# Compile programs on the host
# ===========================================================================
@@ -217,9 +226,7 @@ targets += $(multi-used-y) $(multi-used-m)
# 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 $@ $<
+ cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) -o $@ $<
$(host-csingle): %: %.c FORCE
$(call if_changed_dep,host-csingle)
@@ -235,9 +242,7 @@ $(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
# 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 $@ $<
+ cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $<
$(host-cobjs): %.o: %.c FORCE
$(call if_changed_dep,host-cobjs)
@@ -253,18 +258,14 @@ $(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
# 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 $@ $<
+ cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -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 $@ $<
+ cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
$(host-cshobjs): %.o: %.c FORCE
$(call if_changed_dep,host-cshobjs)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index c8e1528aae55..f21c0905c2da 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -43,6 +43,7 @@ __obj-m = $(filter-out export.o,$(obj-m))
multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
multi-used := $(multi-used-y) $(multi-used-m)
+single-used-m := $(filter-out $(multi-used-m),$(obj-m))
# Build list of the parts of our composite objects, our composite
# objects depend on those (obviously)
@@ -92,12 +93,14 @@ host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
# Add subdir path
EXTRA_TARGETS := $(addprefix $(obj)/,$(EXTRA_TARGETS))
+build-targets := $(addprefix $(obj)/,$(build-targets))
obj-y := $(addprefix $(obj)/,$(obj-y))
obj-m := $(addprefix $(obj)/,$(obj-m))
export-objs := $(addprefix $(obj)/,$(export-objs))
subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
+single-used-m := $(addprefix $(obj)/,$(single-used-m))
multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
@@ -128,6 +131,12 @@ modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $
c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
$(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
$(basename_flags) $(modname_flags) $(export_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)
# Finds the multi-part object the current object will be linked into
modname-multi = $(sort $(foreach m,$(multi-used),\
@@ -139,7 +148,7 @@ modname-multi = $(sort $(foreach m,$(multi-used),\
quiet_cmd_shipped = SHIPPED $@
cmd_shipped = cat $< > $@
-%:: %_shipped
+$(obj)/%:: $(src)/%_shipped
$(call cmd,shipped)
# Commands useful for building a boot image
@@ -236,4 +245,4 @@ endef
# $(call descend,<dir>,<target>)
# Recursively call a sub-make in <dir> with target <target>
-descend = $(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)
+descend =$(Q)$(MAKE) -f scripts/Makefile.build obj=$(1) $(2)
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 45f5387d365f..1ea62f1c679c 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -15,12 +15,12 @@ include scripts/Makefile.lib
# ==========================================================================
-quiet_cmd_modules_install = INSTALL $(obj-m)
+quiet_cmd_modules_install = INSTALL $(obj-m:.o=.ko)
cmd_modules_install = mkdir -p $(MODLIB)/kernel && \
- cp $(obj-m) $(MODLIB)/kernel/
+ cp $(obj-m:.o=.ko) $(MODLIB)/kernel/
modules_install: $(subdir-ym)
-ifneq ($(obj-m),)
+ifneq ($(obj-m:.o=.ko),)
$(call cmd,modules_install)
else
@:
diff --git a/scripts/kallsyms b/scripts/kallsyms
deleted file mode 100644
index 72a51e0dbdd7..000000000000
--- a/scripts/kallsyms
+++ /dev/null
@@ -1,40 +0,0 @@
-#! /bin/sh
-# Written by Rusty Russell <rusty@rustcorp.com.au> 2002.
-
-if [ $# -ne 2 ]; then
- echo Usage: kallsyms vmlinux objfile >&2
-
- echo Adds a .kallsyms section containing symbol info.
- exit 1
-fi
-
-set -e
-
-# Clean up on exit.
-trap "rm -f kallsyms.map kallsyms.c $2" 0
-
-# Takes nm output from $1, produces a .c file on standard output.
-encode_symbols()
-{
- # First take addresses.
- echo "unsigned long kallsyms_addresses[] = {"
- sed 's/^[ ]*\([A-Fa-f0-9]*\).*/0x\1UL,/' < $1
- echo "};"
-
- # Now output size.
- echo "unsigned long kallsyms_num_syms = `wc -l < $1`;"
-
- # Now output names.
- echo "char kallsyms_names[] = ";
- sed 's/^[ ]*[A-Fa-f0-9]*[ ]*.[ ]\(.*\)/"\1\\0"/' < $1
- echo ";"
-}
-
-# FIXME: Use System.map as input, and regenerate each time in Makefile.
-$NM -n $1 | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > kallsyms.map
-
-encode_symbols kallsyms.map > kallsyms.c
-$CC $CFLAGS -c -o $2 kallsyms.c
-
-trap "rm -f kallsyms.map kallsyms.c" 0
-exit 0
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
new file mode 100644
index 000000000000..1f68d859559f
--- /dev/null
+++ b/scripts/kallsyms.c
@@ -0,0 +1,148 @@
+/* Generate assembler source containing symbol information
+ *
+ * Copyright 2002 by Kai Germaschewski
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ * Usage: nm -n vmlinux | scripts/kallsyms > symbols.S
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct sym_entry {
+ unsigned long long addr;
+ char type;
+ char *sym;
+};
+
+
+static struct sym_entry *table;
+static int size, cnt;
+static unsigned long long _stext, _etext;
+
+static void
+usage(void)
+{
+ fprintf(stderr, "Usage: kallsyms < in.map > out.S\n");
+ exit(1);
+}
+
+static int
+read_symbol(FILE *in, struct sym_entry *s)
+{
+ char str[500];
+ int rc;
+
+ rc = fscanf(in, "%llx %c %499s\n", &s->addr, &s->type, str);
+ if (rc != 3) {
+ if (rc != EOF) {
+ /* skip line */
+ fgets(str, 500, in);
+ }
+ return -1;
+ }
+ s->sym = strdup(str);
+ return 0;
+}
+
+static int
+symbol_valid(struct sym_entry *s)
+{
+ if (s->addr < _stext)
+ return 0;
+
+ if (s->addr > _etext)
+ return 0;
+
+ if (strstr(s->sym, "_compiled."))
+ return 0;
+
+ return 1;
+}
+
+static void
+read_map(FILE *in)
+{
+ int i;
+
+ while (!feof(in)) {
+ if (cnt >= size) {
+ size += 10000;
+ table = realloc(table, sizeof(*table) * size);
+ if (!table) {
+ fprintf(stderr, "out of memory\n");
+ exit (1);
+ }
+ }
+ if (read_symbol(in, &table[cnt]) == 0)
+ cnt++;
+ }
+ for (i = 0; i < cnt; i++) {
+ if (strcmp(table[i].sym, "_stext") == 0)
+ _stext = table[i].addr;
+ if (strcmp(table[i].sym, "_etext") == 0)
+ _etext = table[i].addr;
+ }
+}
+
+static void
+write_src(void)
+{
+ unsigned long long last_addr;
+ int i, valid = 0;
+
+ printf(".data\n");
+
+ printf(".globl kallsyms_addresses\n");
+ printf("\t.align 8\n");
+ printf("kallsyms_addresses:\n");
+ for (i = 0, last_addr = 0; i < cnt; i++) {
+ if (!symbol_valid(&table[i]))
+ continue;
+
+ if (table[i].addr == last_addr)
+ continue;
+
+ printf("\t.long\t%#llx\n", table[i].addr);
+ valid++;
+ last_addr = table[i].addr;
+ }
+ printf("\n");
+
+ printf(".globl kallsyms_num_syms\n");
+ printf("\t.align 8\n");
+ printf("\t.long\t%d\n", valid);
+ printf("\n");
+
+ printf(".globl kallsyms_names\n");
+ printf(".data\n");
+ printf("\t.align 8\n");
+ printf("kallsyms_names:\n");
+ for (i = 0, last_addr = 0; i < cnt; i++) {
+ if (!symbol_valid(&table[i]))
+ continue;
+
+ if (table[i].addr == last_addr)
+ continue;
+
+ printf("\t.string\t\"%s\"\n", table[i].sym);
+ last_addr = table[i].addr;
+ }
+ printf("\n");
+}
+
+int
+main(int argc, char **argv)
+{
+ if (argc != 1)
+ usage();
+
+ read_map(stdin);
+ write_src();
+
+ return 0;
+}
+
diff --git a/scripts/lxdialog/Makefile b/scripts/lxdialog/Makefile
index 252c5bf86cd1..f4b40f078ee8 100644
--- a/scripts/lxdialog/Makefile
+++ b/scripts/lxdialog/Makefile
@@ -15,19 +15,15 @@ endif
endif
endif
-host-progs := lxdialog
+host-progs := lxdialog
+build-targets := $(host-progs)
lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \
util.o lxdialog.o msgbox.o
-EXTRA_TARGETS := lxdialog
-
first_rule: ncurses
-include $(TOPDIR)/Rules.make
-
.PHONY: ncurses
-
ncurses:
@echo "main() {}" > lxtemp.c
@if $(HOSTCC) lxtemp.c $(HOST_LOADLIBES); then \