diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Kbuild.include | 25 | ||||
-rw-r--r-- | scripts/Kconfig.include | 2 | ||||
-rw-r--r-- | scripts/Makefile.build | 4 | ||||
-rw-r--r-- | scripts/Makefile.lib | 21 | ||||
-rw-r--r-- | scripts/Makefile.modbuiltin | 57 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 1 | ||||
-rw-r--r-- | scripts/kconfig/confdata.c | 45 | ||||
-rwxr-xr-x | scripts/link-vmlinux.sh | 4 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 8 | ||||
-rwxr-xr-x | scripts/package/builddeb | 106 |
10 files changed, 98 insertions, 175 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index bc5f25763c1b..6cabf20ce66a 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -33,6 +33,10 @@ real-prereqs = $(filter-out $(PHONY), $^) escsq = $(subst $(squote),'\$(squote)',$1) ### +# Quote a string to pass it to C files. foo => '"foo"' +stringify = $(squote)$(quote)$1$(quote)$(squote) + +### # Easy method for doing a status message kecho := : quiet_kecho := echo @@ -55,14 +59,13 @@ kecho := $($(quiet)kecho) # - stdin is piped in from the first prerequisite ($<) so one has # to specify a valid file as first prerequisite (often the kbuild file) define filechk - $(Q)set -e; \ - mkdir -p $(dir $@); \ - { $(filechk_$(1)); } > $@.tmp; \ - if [ -r $@ ] && cmp -s $@ $@.tmp; then \ - rm -f $@.tmp; \ - else \ - $(kecho) ' UPD $@'; \ - mv -f $@.tmp $@; \ + $(Q)set -e; \ + mkdir -p $(dir $@); \ + trap "rm -f $(dot-target).tmp" EXIT; \ + { $(filechk_$(1)); } > $(dot-target).tmp; \ + if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \ + $(kecho) ' UPD $@'; \ + mv -f $(dot-target).tmp $@; \ fi endef @@ -160,12 +163,6 @@ ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) build := -f $(srctree)/scripts/Makefile.build obj ### -# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= -# Usage: -# $(Q)$(MAKE) $(modbuiltin)=dir -modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj - -### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= # Usage: # $(Q)$(MAKE) $(dtbinst)=dir diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 9d07e59cbdf7..85334dc8c997 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y) # $(cc-option,<flag>) # Return y if the compiler supports <flag>, n otherwise -cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null) +cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null) # $(ld-option,<flag>) # Return y if the linker supports <flag>, n otherwise diff --git a/scripts/Makefile.build b/scripts/Makefile.build index b734ac8a654e..a562d695f0fa 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -66,7 +66,7 @@ lib-target := $(obj)/lib.a real-obj-y += $(obj)/lib-ksyms.o endif -ifneq ($(strip $(real-obj-y) $(need-builtin)),) +ifdef need-builtin builtin-target := $(obj)/built-in.a endif @@ -372,7 +372,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler # --------------------------------------------------------------------------- # To build objects in subdirs, we need to descend into the directories -$(sort $(subdir-obj-y)): $(subdir-ym) ; +$(obj)/%/built-in.a: $(obj)/% ; # # Rule to compile a set of .o files into one .a file (without symbol table) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3fa32f83b2d7..d10f7a03e0ee 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -35,7 +35,11 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) subdir-m += $(__subdir-m) +ifdef need-builtin obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) +else +obj-y := $(filter-out %/, $(obj-y)) +endif obj-m := $(filter-out %/, $(obj-m)) # Subdirectories we need to descend into @@ -80,12 +84,14 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) # Finds the multi-part object the current object will be linked into. -# If the object belongs to two or more multi-part objects, all of them are -# concatenated with a colon separator. -modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ - $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) +# If the object belongs to two or more multi-part objects, list them all. +modname-multi = $(sort $(foreach m,$(multi-used),\ + $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) + +__modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) -modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) +modname = $(subst $(space),:,$(__modname)) +modfile = $(addprefix $(obj)/,$(__modname)) # target with $(obj)/ and its suffix stripped target-stem = $(basename $(patsubst $(obj)/%,%,$@)) @@ -93,9 +99,10 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@)) # These flags are needed for modversions and compiling, so we define them here # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will # end up in (or would, if it gets compiled in) -name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1))) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) +modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(target-stem).o) @@ -154,7 +161,7 @@ quiet_modtag = $(if $(part-of-module),[M], ) modkern_cflags = \ $(if $(part-of-module), \ $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ - $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) + $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags)) modkern_aflags = $(if $(part-of-module), \ $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin deleted file mode 100644 index 7d4711b88656..000000000000 --- a/scripts/Makefile.modbuiltin +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# ========================================================================== -# Generating modules.builtin -# ========================================================================== - -src := $(obj) - -PHONY := __modbuiltin -__modbuiltin: - -include include/config/auto.conf -# tristate.conf sets tristate variables to uppercase 'Y' or 'M' -# That way, we get the list of built-in modules in obj-Y -include include/config/tristate.conf - -include scripts/Kbuild.include - -ifdef building_out_of_srctree -# Create output directory if not already present -_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) -endif - -# The filename Kbuild has precedence over Makefile -kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) -kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) -include $(kbuild-file) - -include scripts/Makefile.lib -__subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y))) -subdir-Y += $(__subdir-Y) -subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m)) -subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -obj-Y := $(addprefix $(obj)/,$(obj-Y)) - -modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym)) -modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko)) -modbuiltin-target := $(obj)/modules.builtin - -__modbuiltin: $(modbuiltin-target) $(subdir-ym) - @: - -$(modbuiltin-target): $(subdir-ym) FORCE - $(Q)(for m in $(modbuiltin-mods); do echo $$m; done; \ - cat /dev/null $(modbuiltin-subdirs)) > $@ - -PHONY += FORCE - -FORCE: - -# Descending -# --------------------------------------------------------------------------- - -PHONY += $(subdir-ym) -$(subdir-ym): - $(Q)$(MAKE) $(modbuiltin)=$@ - -.PHONY: $(PHONY) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 69897d5d3a70..b4d3f2d122ac 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -90,7 +90,6 @@ quiet_cmd_modpost = MODPOST $(words $(modules)) modules cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) __modpost: - @$(kecho) ' Building modules, stage 2.' $(call cmd,modpost) ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 3569d2dec37c..fb675bd9a809 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -710,25 +710,6 @@ static struct conf_printer header_printer_cb = .print_comment = header_print_comment, }; -/* - * Tristate printer - * - * This printer is used when generating the `include/config/tristate.conf' file. - */ -static void -tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) -{ - - if (sym->type == S_TRISTATE && *value != 'n') - fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value)); -} - -static struct conf_printer tristate_printer_cb = -{ - .print_symbol = tristate_print_symbol, - .print_comment = kconfig_print_comment, -}; - static void conf_write_symbol(FILE *fp, struct symbol *sym, struct conf_printer *printer, void *printer_arg) { @@ -1062,7 +1043,7 @@ int conf_write_autoconf(int overwrite) struct symbol *sym; const char *name; const char *autoconf_name = conf_get_autoconfig_name(); - FILE *out, *tristate, *out_h; + FILE *out, *out_h; int i; if (!overwrite && is_present(autoconf_name)) @@ -1077,23 +1058,13 @@ int conf_write_autoconf(int overwrite) if (!out) return 1; - tristate = fopen(".tmpconfig_tristate", "w"); - if (!tristate) { - fclose(out); - return 1; - } - out_h = fopen(".tmpconfig.h", "w"); if (!out_h) { fclose(out); - fclose(tristate); return 1; } conf_write_heading(out, &kconfig_printer_cb, NULL); - - conf_write_heading(tristate, &tristate_printer_cb, NULL); - conf_write_heading(out_h, &header_printer_cb, NULL); for_all_symbols(i, sym) { @@ -1101,15 +1072,11 @@ int conf_write_autoconf(int overwrite) if (!(sym->flags & SYMBOL_WRITE) || !sym->name) continue; - /* write symbol to auto.conf, tristate and header files */ + /* write symbols to auto.conf and autoconf.h */ conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); - - conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); - conf_write_symbol(out_h, sym, &header_printer_cb, NULL); } fclose(out); - fclose(tristate); fclose(out_h); name = getenv("KCONFIG_AUTOHEADER"); @@ -1120,14 +1087,6 @@ int conf_write_autoconf(int overwrite) if (rename(".tmpconfig.h", name)) return 1; - name = getenv("KCONFIG_TRISTATE"); - if (!name) - name = "include/config/tristate.conf"; - if (make_parent_dir(name)) - return 1; - if (rename(".tmpconfig_tristate", name)) - return 1; - if (make_parent_dir(autoconf_name)) return 1; /* diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index bbe9be2bf5ff..1919c311c149 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -250,6 +250,10 @@ ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1 info MODINFO modules.builtin.modinfo ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo +info GEN modules.builtin +# The second line aids cases where multiple modules share the same object. +tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.file=//p' | + tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.builtin btf_vmlinux_bin_o="" if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6e892c93d104..7edfdb2f4497 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -12,6 +12,7 @@ */ #define _GNU_SOURCE +#include <elf.h> #include <stdio.h> #include <ctype.h> #include <string.h> @@ -729,12 +730,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, break; if (ignore_undef_symbol(info, symname)) break; -/* cope with newer glibc (2.3.4 or higher) STT_ definition in elf.h */ -#if defined(STT_REGISTER) || defined(STT_SPARC_REGISTER) -/* add compatibility with older glibc */ -#ifndef STT_SPARC_REGISTER -#define STT_SPARC_REGISTER STT_REGISTER -#endif if (info->hdr->e_machine == EM_SPARC || info->hdr->e_machine == EM_SPARCV9) { /* Ignore register directives. */ @@ -747,7 +742,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, symname = munged; } } -#endif mod->unres = alloc_symbol(symname, ELF_ST_BIND(sym->st_info) == STB_WEAK, diff --git a/scripts/package/builddeb b/scripts/package/builddeb index c4c580f547ef..6df3c9f8b2da 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -43,17 +43,66 @@ create_package() { # Create the package dpkg-gencontrol -p$pname -P"$pdir" - dpkg --build "$pdir" .. + dpkg-deb ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. +} + +deploy_kernel_headers () { + pdir=$1 + + rm -rf $pdir + + ( + cd $srctree + find . arch/$SRCARCH -maxdepth 1 -name Makefile\* + find include scripts -type f -o -type l + find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform + find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f + ) > debian/hdrsrcfiles + + { + if is_enabled CONFIG_STACK_VALIDATION; then + echo tools/objtool/objtool + fi + + find arch/$SRCARCH/include Module.symvers include scripts -type f + + if is_enabled CONFIG_GCC_PLUGINS; then + find scripts/gcc-plugins -name \*.so + fi + } > debian/hdrobjfiles + + destdir=$pdir/usr/src/linux-headers-$version + mkdir -p $destdir + tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir + tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir + rm -f debian/hdrsrcfiles debian/hdrobjfiles + + # copy .config manually to be where it's expected to be + cp $KCONFIG_CONFIG $destdir/.config + + mkdir -p $pdir/lib/modules/$version/ + ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build +} + +deploy_libc_headers () { + pdir=$1 + + rm -rf $pdir + + $MAKE -f $srctree/Makefile headers + $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr + + # move asm headers to /usr/include/<libc-machine>/asm to match the structure + # used by Debian-based distros (to support multi-arch) + host_arch=$(dpkg-architecture -a$(cat debian/arch) -qDEB_HOST_MULTIARCH) + mkdir $pdir/usr/include/$host_arch + mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/ } version=$KERNELRELEASE -tmpdir="$objtree/debian/tmp" -kernel_headers_dir="$objtree/debian/hdrtmp" -libc_headers_dir="$objtree/debian/headertmp" -dbg_dir="$objtree/debian/dbgtmp" +tmpdir=debian/linux-image +dbg_dir=debian/linux-image-dbg packagename=linux-image-$version -kernel_headers_packagename=linux-headers-$version -libc_headers_packagename=linux-libc-dev dbg_packagename=$packagename-dbg if [ "$ARCH" = "um" ] ; then @@ -77,15 +126,13 @@ esac BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes) # Setup the directory structure -rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files +rm -rf "$tmpdir" "$dbg_dir" debian/files mkdir -m 755 -p "$tmpdir/DEBIAN" mkdir -p "$tmpdir/lib" "$tmpdir/boot" -mkdir -p "$kernel_headers_dir/lib/modules/$version/" -# Build and install the kernel +# Install the kernel if [ "$ARCH" = "um" ] ; then mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename" - $MAKE linux cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" gzip "$tmpdir/usr/share/doc/$packagename/config" @@ -129,16 +176,6 @@ if is_enabled CONFIG_MODULES; then fi fi -if [ "$ARCH" != "um" ]; then - $MAKE -f $srctree/Makefile headers - $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" - # move asm headers to /usr/include/<libc-machine>/asm to match the structure - # used by Debian-based distros (to support multi-arch) - host_arch=$(dpkg-architecture -a$(cat debian/arch) -qDEB_HOST_MULTIARCH) - mkdir $libc_headers_dir/usr/include/$host_arch - mv $libc_headers_dir/usr/include/asm $libc_headers_dir/usr/include/$host_arch/ -fi - # Install the maintainer scripts # Note: hook scripts under /etc/kernel are also executed by official Debian # kernel packages, as well as kernel packages built using make-kpkg. @@ -164,29 +201,12 @@ EOF chmod 755 "$tmpdir/DEBIAN/$script" done -# Build kernel header package -(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" -(cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" -(cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" -(cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" -if is_enabled CONFIG_STACK_VALIDATION; then - (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" -fi -(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" -if is_enabled CONFIG_GCC_PLUGINS; then - (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" -fi -destdir=$kernel_headers_dir/usr/src/linux-headers-$version -mkdir -p "$destdir" -(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) -(cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) -(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be -ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" -rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" - if [ "$ARCH" != "um" ]; then - create_package "$kernel_headers_packagename" "$kernel_headers_dir" - create_package "$libc_headers_packagename" "$libc_headers_dir" + deploy_kernel_headers debian/linux-headers + create_package linux-headers-$version debian/linux-headers + + deploy_libc_headers debian/linux-libc-dev + create_package linux-libc-dev debian/linux-libc-dev fi create_package "$packagename" "$tmpdir" |