Pull Kbuild updates from Masahiro Yamada: - detect missing include guard in UAPI headers - do not create orphan built-in.a or obj-y objects - generate modules.builtin more simply, and drop tristate.conf - simplify built-in initramfs creation - make linux-headers deb package thinner - optimize the deb package build script - misc cleanups * tag 'kbuild-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits) builddeb: split libc headers deployment out into a function builddeb: split kernel headers deployment out into a function builddeb: remove redundant make for ARCH=um builddeb: avoid invoking sub-shells where possible builddeb: remove redundant $objtree/ builddeb: match temporary directory name to the package name builddeb: remove unneeded files in hdrobjfiles for headers package kbuild: use -S instead of -E for precise cc-option test in Kconfig builddeb: allow selection of .deb compressor kbuild: remove 'Building modules, stage 2.' log kbuild: remove *.tmp file when filechk fails kbuild: remove PYTHON2 variable modpost: assume STT_SPARC_REGISTER is defined gen_initramfs.sh: remove intermediate cpio_list on errors initramfs: refactor the initramfs build rules gen_initramfs.sh: always output cpio even without -o option initramfs: add default_cpio_list, and delete -d option support initramfs: generate dependency list and cpio at the same time initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in Makefile initramfs: make initramfs compression choice non-optional ...
Showing the changes to scripts (10 of 20 files). Show all
Unified · Split
| @@ -32,6 +32,10 @@ real-prereqs = $(filter-out $(PHONY), $^) · 31 unmodified lines | |||
| 32 | # Escape single quote for use in echo statements | 32 | # Escape single quote for use in echo statements |
| 33 | escsq = $(subst $(squote),'\$(squote)',$1) | 33 | escsq = $(subst $(squote),'\$(squote)',$1) |
| 34 | 34 | ||
| 35 | ### | ||
| 36 | # Quote a string to pass it to C files. foo => '"foo"' | ||
| 37 | stringify = $(squote)$(quote)$1$(quote)$(squote) | ||
| 38 | |||
| 35 | ### | 39 | ### |
| 36 | # Easy method for doing a status message | 40 | # Easy method for doing a status message |
| 37 | kecho := : | 41 | kecho := : |
| @@ -55,14 +59,13 @@ kecho := $($(quiet)kecho) · 17 unmodified lines | |||
| 55 | # - stdin is piped in from the first prerequisite ($<) so one has | 59 | # - stdin is piped in from the first prerequisite ($<) so one has |
| 56 | # to specify a valid file as first prerequisite (often the kbuild file) | 60 | # to specify a valid file as first prerequisite (often the kbuild file) |
| 57 | define filechk | 61 | define filechk |
| 58 | $(Q)set -e; \ | 62 | $(Q)set -e; \ |
| 59 | mkdir -p $(dir $@); \ | 63 | mkdir -p $(dir $@); \ |
| 60 | { $(filechk_$(1)); } > $@.tmp; \ | 64 | trap "rm -f $(dot-target).tmp" EXIT; \ |
| 61 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | 65 | { $(filechk_$(1)); } > $(dot-target).tmp; \ |
| 62 | rm -f $@.tmp; \ | 66 | if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \ |
| 63 | else \ | 67 | $(kecho) ' UPD $@'; \ |
| 64 | $(kecho) ' UPD $@'; \ | 68 | mv -f $(dot-target).tmp $@; \ |
| 65 | mv -f $@.tmp $@; \ | ||
| 66 | fi | 69 | fi |
| 67 | endef | 70 | endef |
| 68 | 71 | ||
| @@ -159,12 +162,6 @@ ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) · 90 unmodified lines | |||
| 159 | # $(Q)$(MAKE) $(build)=dir | 162 | # $(Q)$(MAKE) $(build)=dir |
| 160 | build := -f $(srctree)/scripts/Makefile.build obj | 163 | build := -f $(srctree)/scripts/Makefile.build obj |
| 161 | 164 | ||
| 162 | ### | ||
| 163 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= | ||
| 164 | # Usage: | ||
| 165 | # $(Q)$(MAKE) $(modbuiltin)=dir | ||
| 166 | modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj | ||
| 167 | |||
| 168 | ### | 165 | ### |
| 169 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= | 166 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= |
| 170 | # Usage: | 167 | # Usage: |
| @@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y) · 24 unmodified lines | |||
| 25 | 25 | ||
| 26 | # $(cc-option,<flag>) | 26 | # $(cc-option,<flag>) |
| 27 | # Return y if the compiler supports <flag>, n otherwise | 27 | # Return y if the compiler supports <flag>, n otherwise |
| 28 | cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null) | 28 | cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null) |
| 29 | 29 | ||
| 30 | # $(ld-option,<flag>) | 30 | # $(ld-option,<flag>) |
| 31 | # Return y if the linker supports <flag>, n otherwise | 31 | # Return y if the linker supports <flag>, n otherwise |
| @@ -66,7 +66,7 @@ lib-target := $(obj)/lib.a · 65 unmodified lines | |||
| 66 | real-obj-y += $(obj)/lib-ksyms.o | 66 | real-obj-y += $(obj)/lib-ksyms.o |
| 67 | endif | 67 | endif |
| 68 | 68 | ||
| 69 | ifneq ($(strip $(real-obj-y) $(need-builtin)),) | 69 | ifdef need-builtin |
| 70 | builtin-target := $(obj)/built-in.a | 70 | builtin-target := $(obj)/built-in.a |
| 71 | endif | 71 | endif |
| 72 | 72 | ||
| @@ -372,7 +372,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler · 299 unmodified lines | |||
| 372 | # --------------------------------------------------------------------------- | 372 | # --------------------------------------------------------------------------- |
| 373 | 373 | ||
| 374 | # To build objects in subdirs, we need to descend into the directories | 374 | # To build objects in subdirs, we need to descend into the directories |
| 375 | $(sort $(subdir-obj-y)): $(subdir-ym) ; | 375 | $(obj)/%/built-in.a: $(obj)/% ; |
| 376 | 376 | ||
| 377 | # | 377 | # |
| 378 | # Rule to compile a set of .o files into one .a file (without symbol table) | 378 | # Rule to compile a set of .o files into one .a file (without symbol table) |
| @@ -35,7 +35,11 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) · 34 unmodified lines | |||
| 35 | subdir-y += $(__subdir-y) | 35 | subdir-y += $(__subdir-y) |
| 36 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) | 36 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) |
| 37 | subdir-m += $(__subdir-m) | 37 | subdir-m += $(__subdir-m) |
| 38 | ifdef need-builtin | ||
| 38 | obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) | 39 | obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) |
| 40 | else | ||
| 41 | obj-y := $(filter-out %/, $(obj-y)) | ||
| 42 | endif | ||
| 39 | obj-m := $(filter-out %/, $(obj-m)) | 43 | obj-m := $(filter-out %/, $(obj-m)) |
| 40 | 44 | ||
| 41 | # Subdirectories we need to descend into | 45 | # Subdirectories we need to descend into |
| @@ -80,12 +84,14 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) · 38 unmodified lines | |||
| 80 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) | 84 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) |
| 81 | 85 | ||
| 82 | # Finds the multi-part object the current object will be linked into. | 86 | # Finds the multi-part object the current object will be linked into. |
| 83 | # If the object belongs to two or more multi-part objects, all of them are | 87 | # If the object belongs to two or more multi-part objects, list them all. |
| 84 | # concatenated with a colon separator. | 88 | modname-multi = $(sort $(foreach m,$(multi-used),\ |
| 85 | modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ | 89 | $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) |
| 86 | $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) | 90 | |
| 91 | __modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) | ||
| 87 | 92 | ||
| 88 | modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) | 93 | modname = $(subst $(space),:,$(__modname)) |
| 94 | modfile = $(addprefix $(obj)/,$(__modname)) | ||
| 89 | 95 | ||
| 90 | # target with $(obj)/ and its suffix stripped | 96 | # target with $(obj)/ and its suffix stripped |
| 91 | target-stem = $(basename $(patsubst $(obj)/%,%,$@)) | 97 | target-stem = $(basename $(patsubst $(obj)/%,%,$@)) |
| @@ -93,9 +99,10 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@)) · 1 unmodified line | |||
| 93 | # These flags are needed for modversions and compiling, so we define them here | 99 | # These flags are needed for modversions and compiling, so we define them here |
| 94 | # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will | 100 | # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will |
| 95 | # end up in (or would, if it gets compiled in) | 101 | # end up in (or would, if it gets compiled in) |
| 96 | name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) | 102 | name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1))) |
| 97 | basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) | 103 | basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) |
| 98 | modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) | 104 | modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) |
| 105 | modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) | ||
| 99 | 106 | ||
| 100 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ | 107 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ |
| 101 | $(ccflags-y) $(CFLAGS_$(target-stem).o) | 108 | $(ccflags-y) $(CFLAGS_$(target-stem).o) |
| @@ -154,7 +161,7 @@ quiet_modtag = $(if $(part-of-module),[M], ) · 52 unmodified lines | |||
| 154 | modkern_cflags = \ | 161 | modkern_cflags = \ |
| 155 | $(if $(part-of-module), \ | 162 | $(if $(part-of-module), \ |
| 156 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ | 163 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ |
| 157 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) | 164 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags)) |
| 158 | 165 | ||
| 159 | modkern_aflags = $(if $(part-of-module), \ | 166 | modkern_aflags = $(if $(part-of-module), \ |
| 160 | $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ | 167 | $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \ |
| @@ -1,57 +0,0 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | # ========================================================================== | ||
| 3 | # Generating modules.builtin | ||
| 4 | # ========================================================================== | ||
| 5 | |||
| 6 | src := $(obj) | ||
| 7 | |||
| 8 | PHONY := __modbuiltin | ||
| 9 | __modbuiltin: | ||
| 10 | |||
| 11 | include include/config/auto.conf | ||
| 12 | # tristate.conf sets tristate variables to uppercase 'Y' or 'M' | ||
| 13 | # That way, we get the list of built-in modules in obj-Y | ||
| 14 | include include/config/tristate.conf | ||
| 15 | |||
| 16 | include scripts/Kbuild.include | ||
| 17 | |||
| 18 | ifdef building_out_of_srctree | ||
| 19 | # Create output directory if not already present | ||
| 20 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) | ||
| 21 | endif | ||
| 22 | |||
| 23 | # The filename Kbuild has precedence over Makefile | ||
| 24 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | ||
| 25 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) | ||
| 26 | include $(kbuild-file) | ||
| 27 | |||
| 28 | include scripts/Makefile.lib | ||
| 29 | __subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y))) | ||
| 30 | subdir-Y += $(__subdir-Y) | ||
| 31 | subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m)) | ||
| 32 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) | ||
| 33 | obj-Y := $(addprefix $(obj)/,$(obj-Y)) | ||
| 34 | |||
| 35 | modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym)) | ||
| 36 | modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko)) | ||
| 37 | modbuiltin-target := $(obj)/modules.builtin | ||
| 38 | |||
| 39 | __modbuiltin: $(modbuiltin-target) $(subdir-ym) | ||
| 40 | @: | ||
| 41 | |||
| 42 | $(modbuiltin-target): $(subdir-ym) FORCE | ||
| 43 | $(Q)(for m in $(modbuiltin-mods); do echo $$m; done; \ | ||
| 44 | cat /dev/null $(modbuiltin-subdirs)) > $@ | ||
| 45 | |||
| 46 | PHONY += FORCE | ||
| 47 | |||
| 48 | FORCE: | ||
| 49 | |||
| 50 | # Descending | ||
| 51 | # --------------------------------------------------------------------------- | ||
| 52 | |||
| 53 | PHONY += $(subdir-ym) | ||
| 54 | $(subdir-ym): | ||
| 55 | $(Q)$(MAKE) $(modbuiltin)=$@ | ||
| 56 | |||
| 57 | .PHONY: $(PHONY) | ||
| @@ -90,7 +90,6 @@ quiet_cmd_modpost = MODPOST $(words $(modules)) modules · 89 unmodified lines | |||
| 90 | cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) | 90 | cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) |
| 91 | 91 | ||
| 92 | __modpost: | 92 | __modpost: |
| 93 | @$(kecho) ' Building modules, stage 2.' | ||
| 94 | $(call cmd,modpost) | 93 | $(call cmd,modpost) |
| 95 | ifneq ($(KBUILD_MODPOST_NOFINAL),1) | 94 | ifneq ($(KBUILD_MODPOST_NOFINAL),1) |
| 96 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal | 95 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal |
| @@ -710,25 +710,6 @@ static struct conf_printer header_printer_cb = · 709 unmodified lines | |||
| 710 | .print_comment = header_print_comment, | 710 | .print_comment = header_print_comment, |
| 711 | }; | 711 | }; |
| 712 | 712 | ||
| 713 | /* | ||
| 714 | * Tristate printer | ||
| 715 | * | ||
| 716 | * This printer is used when generating the `include/config/tristate.conf' file. | ||
| 717 | */ | ||
| 718 | static void | ||
| 719 | tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | ||
| 720 | { | ||
| 721 | |||
| 722 | if (sym->type == S_TRISTATE && *value != 'n') | ||
| 723 | fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value)); | ||
| 724 | } | ||
| 725 | |||
| 726 | static struct conf_printer tristate_printer_cb = | ||
| 727 | { | ||
| 728 | .print_symbol = tristate_print_symbol, | ||
| 729 | .print_comment = kconfig_print_comment, | ||
| 730 | }; | ||
| 731 | |||
| 732 | static void conf_write_symbol(FILE *fp, struct symbol *sym, | 713 | static void conf_write_symbol(FILE *fp, struct symbol *sym, |
| 733 | struct conf_printer *printer, void *printer_arg) | 714 | struct conf_printer *printer, void *printer_arg) |
| 734 | { | 715 | { |
| @@ -1062,7 +1043,7 @@ int conf_write_autoconf(int overwrite) · 327 unmodified lines | |||
| 1062 | struct symbol *sym; | 1043 | struct symbol *sym; |
| 1063 | const char *name; | 1044 | const char *name; |
| 1064 | const char *autoconf_name = conf_get_autoconfig_name(); | 1045 | const char *autoconf_name = conf_get_autoconfig_name(); |
| 1065 | FILE *out, *tristate, *out_h; | 1046 | FILE *out, *out_h; |
| 1066 | int i; | 1047 | int i; |
| 1067 | 1048 | ||
| 1068 | if (!overwrite && is_present(autoconf_name)) | 1049 | if (!overwrite && is_present(autoconf_name)) |
| @@ -1077,23 +1058,13 @@ int conf_write_autoconf(int overwrite) · 8 unmodified lines | |||
| 1077 | if (!out) | 1058 | if (!out) |
| 1078 | return 1; | 1059 | return 1; |
| 1079 | 1060 | ||
| 1080 | tristate = fopen(".tmpconfig_tristate", "w"); | ||
| 1081 | if (!tristate) { | ||
| 1082 | fclose(out); | ||
| 1083 | return 1; | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | out_h = fopen(".tmpconfig.h", "w"); | 1061 | out_h = fopen(".tmpconfig.h", "w"); |
| 1087 | if (!out_h) { | 1062 | if (!out_h) { |
| 1088 | fclose(out); | 1063 | fclose(out); |
| 1089 | fclose(tristate); | ||
| 1090 | return 1; | 1064 | return 1; |
| 1091 | } | 1065 | } |
| 1092 | 1066 | ||
| 1093 | conf_write_heading(out, &kconfig_printer_cb, NULL); | 1067 | conf_write_heading(out, &kconfig_printer_cb, NULL); |
| 1094 | |||
| 1095 | conf_write_heading(tristate, &tristate_printer_cb, NULL); | ||
| 1096 | |||
| 1097 | conf_write_heading(out_h, &header_printer_cb, NULL); | 1068 | conf_write_heading(out_h, &header_printer_cb, NULL); |
| 1098 | 1069 | ||
| 1099 | for_all_symbols(i, sym) { | 1070 | for_all_symbols(i, sym) { |
| @@ -1101,15 +1072,11 @@ int conf_write_autoconf(int overwrite) · 1 unmodified line | |||
| 1101 | if (!(sym->flags & SYMBOL_WRITE) || !sym->name) | 1072 | if (!(sym->flags & SYMBOL_WRITE) || !sym->name) |
| 1102 | continue; | 1073 | continue; |
| 1103 | 1074 | ||
| 1104 | /* write symbol to auto.conf, tristate and header files */ | 1075 | /* write symbols to auto.conf and autoconf.h */ |
| 1105 | conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); | 1076 | conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); |
| 1106 | |||
| 1107 | conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); | ||
| 1108 | |||
| 1109 | conf_write_symbol(out_h, sym, &header_printer_cb, NULL); | 1077 | conf_write_symbol(out_h, sym, &header_printer_cb, NULL); |
| 1110 | } | 1078 | } |
| 1111 | fclose(out); | 1079 | fclose(out); |
| 1112 | fclose(tristate); | ||
| 1113 | fclose(out_h); | 1080 | fclose(out_h); |
| 1114 | 1081 | ||
| 1115 | name = getenv("KCONFIG_AUTOHEADER"); | 1082 | name = getenv("KCONFIG_AUTOHEADER"); |
| @@ -1120,14 +1087,6 @@ int conf_write_autoconf(int overwrite) · 4 unmodified lines | |||
| 1120 | if (rename(".tmpconfig.h", name)) | 1087 | if (rename(".tmpconfig.h", name)) |
| 1121 | return 1; | 1088 | return 1; |
| 1122 | 1089 | ||
| 1123 | name = getenv("KCONFIG_TRISTATE"); | ||
| 1124 | if (!name) | ||
| 1125 | name = "include/config/tristate.conf"; | ||
| 1126 | if (make_parent_dir(name)) | ||
| 1127 | return 1; | ||
| 1128 | if (rename(".tmpconfig_tristate", name)) | ||
| 1129 | return 1; | ||
| 1130 | |||
| 1131 | if (make_parent_dir(autoconf_name)) | 1090 | if (make_parent_dir(autoconf_name)) |
| 1132 | return 1; | 1091 | return 1; |
| 1133 | /* | 1092 | /* |
| @@ -250,6 +250,10 @@ ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1 · 249 unmodified lines | |||
| 250 | 250 | ||
| 251 | info MODINFO modules.builtin.modinfo | 251 | info MODINFO modules.builtin.modinfo |
| 252 | ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo | 252 | ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo |
| 253 | info GEN modules.builtin | ||
| 254 | # The second line aids cases where multiple modules share the same object. | ||
| 255 | tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.file=//p' | | ||
| 256 | tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.builtin | ||
| 253 | 257 | ||
| 254 | btf_vmlinux_bin_o="" | 258 | btf_vmlinux_bin_o="" |
| 255 | if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then | 259 | if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | |||
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #define _GNU_SOURCE | 14 | #define _GNU_SOURCE |
| 15 | #include <elf.h> | ||
| 15 | #include <stdio.h> | 16 | #include <stdio.h> |
| 16 | #include <ctype.h> | 17 | #include <ctype.h> |
| 17 | #include <string.h> | 18 | #include <string.h> |
| @@ -729,12 +730,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, · 711 unmodified lines | |||
| 729 | break; | 730 | break; |
| 730 | if (ignore_undef_symbol(info, symname)) | 731 | if (ignore_undef_symbol(info, symname)) |
| 731 | break; | 732 | break; |
| 732 | /* cope with newer glibc (2.3.4 or higher) STT_ definition in elf.h */ | ||
| 733 | #if defined(STT_REGISTER) || defined(STT_SPARC_REGISTER) | ||
| 734 | /* add compatibility with older glibc */ | ||
| 735 | #ifndef STT_SPARC_REGISTER | ||
| 736 | #define STT_SPARC_REGISTER STT_REGISTER | ||
| 737 | #endif | ||
| 738 | if (info->hdr->e_machine == EM_SPARC || | 733 | if (info->hdr->e_machine == EM_SPARC || |
| 739 | info->hdr->e_machine == EM_SPARCV9) { | 734 | info->hdr->e_machine == EM_SPARCV9) { |
| 740 | /* Ignore register directives. */ | 735 | /* Ignore register directives. */ |
| @@ -747,7 +742,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, · 6 unmodified lines | |||
| 747 | symname = munged; | 742 | symname = munged; |
| 748 | } | 743 | } |
| 749 | } | 744 | } |
| 750 | #endif | ||
| 751 | 745 | ||
| 752 | mod->unres = alloc_symbol(symname, | 746 | mod->unres = alloc_symbol(symname, |
| 753 | ELF_ST_BIND(sym->st_info) == STB_WEAK, | 747 | ELF_ST_BIND(sym->st_info) == STB_WEAK, |
| @@ -43,17 +43,66 @@ create_package() { · 42 unmodified lines | |||
| 43 | 43 | ||
| 44 | # Create the package | 44 | # Create the package |
| 45 | dpkg-gencontrol -p$pname -P"$pdir" | 45 | dpkg-gencontrol -p$pname -P"$pdir" |
| 46 | dpkg --build "$pdir" .. | 46 | dpkg-deb ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. |
| 47 | } | ||
| 48 | |||
| 49 | deploy_kernel_headers () { | ||
| 50 | pdir=$1 | ||
| 51 | |||
| 52 | rm -rf $pdir | ||
| 53 | |||
| 54 | ( | ||
| 55 | cd $srctree | ||
| 56 | find . arch/$SRCARCH -maxdepth 1 -name Makefile\* | ||
| 57 | find include scripts -type f -o -type l | ||
| 58 | find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform | ||
| 59 | find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f | ||
| 60 | ) > debian/hdrsrcfiles | ||
| 61 | |||
| 62 | { | ||
| 63 | if is_enabled CONFIG_STACK_VALIDATION; then | ||
| 64 | echo tools/objtool/objtool | ||
| 65 | fi | ||
| 66 | |||
| 67 | find arch/$SRCARCH/include Module.symvers include scripts -type f | ||
| 68 | |||
| 69 | if is_enabled CONFIG_GCC_PLUGINS; then | ||
| 70 | find scripts/gcc-plugins -name \*.so | ||
| 71 | fi | ||
| 72 | } > debian/hdrobjfiles | ||
| 73 | |||
| 74 | destdir=$pdir/usr/src/linux-headers-$version | ||
| 75 | mkdir -p $destdir | ||
| 76 | tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir | ||
| 77 | tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir | ||
| 78 | rm -f debian/hdrsrcfiles debian/hdrobjfiles | ||
| 79 | |||
| 80 | # copy .config manually to be where it's expected to be | ||
| 81 | cp $KCONFIG_CONFIG $destdir/.config | ||
| 82 | |||
| 83 | mkdir -p $pdir/lib/modules/$version/ | ||
| 84 | ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build | ||
| 85 | } | ||
| 86 | |||
| 87 | deploy_libc_headers () { | ||
| 88 | pdir=$1 | ||
| 89 | |||
| 90 | rm -rf $pdir | ||
| 91 | |||
| 92 | $MAKE -f $srctree/Makefile headers | ||
| 93 | $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH=$pdir/usr | ||
| 94 | |||
| 95 | # move asm headers to /usr/include/<libc-machine>/asm to match the structure | ||
| 96 | # used by Debian-based distros (to support multi-arch) | ||
| 97 | host_arch=$(dpkg-architecture -a$(cat debian/arch) -qDEB_HOST_MULTIARCH) | ||
| 98 | mkdir $pdir/usr/include/$host_arch | ||
| 99 | mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/ | ||
| 47 | } | 100 | } |
| 48 | 101 | ||
| 49 | version=$KERNELRELEASE | 102 | version=$KERNELRELEASE |
| 50 | tmpdir="$objtree/debian/tmp" | 103 | tmpdir=debian/linux-image |
| 51 | kernel_headers_dir="$objtree/debian/hdrtmp" | 104 | dbg_dir=debian/linux-image-dbg |
| 52 | libc_headers_dir="$objtree/debian/headertmp" | ||
| 53 | dbg_dir="$objtree/debian/dbgtmp" | ||
| 54 | packagename=linux-image-$version | 105 | packagename=linux-image-$version |
| 55 | kernel_headers_packagename=linux-headers-$version | ||
| 56 | libc_headers_packagename=linux-libc-dev | ||
| 57 | dbg_packagename=$packagename-dbg | 106 | dbg_packagename=$packagename-dbg |
| 58 | 107 | ||
| 59 | if [ "$ARCH" = "um" ] ; then | 108 | if [ "$ARCH" = "um" ] ; then |
| @@ -77,15 +126,13 @@ esac · 17 unmodified lines | |||
| 77 | BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes) | 126 | BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes) |
| 78 | 127 | ||
| 79 | # Setup the directory structure | 128 | # Setup the directory structure |
| 80 | rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files | 129 | rm -rf "$tmpdir" "$dbg_dir" debian/files |
| 81 | mkdir -m 755 -p "$tmpdir/DEBIAN" | 130 | mkdir -m 755 -p "$tmpdir/DEBIAN" |
| 82 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" | 131 | mkdir -p "$tmpdir/lib" "$tmpdir/boot" |
| 83 | mkdir -p "$kernel_headers_dir/lib/modules/$version/" | ||
| 84 | 132 | ||
| 85 | # Build and install the kernel | 133 | # Install the kernel |
| 86 | if [ "$ARCH" = "um" ] ; then | 134 | if [ "$ARCH" = "um" ] ; then |
| 87 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename" | 135 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename" |
| 88 | $MAKE linux | ||
| 89 | cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" | 136 | cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" |
| 90 | cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" | 137 | cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" |
| 91 | gzip "$tmpdir/usr/share/doc/$packagename/config" | 138 | gzip "$tmpdir/usr/share/doc/$packagename/config" |
| @@ -129,16 +176,6 @@ if is_enabled CONFIG_MODULES; then · 37 unmodified lines | |||
| 129 | fi | 176 | fi |
| 130 | fi | 177 | fi |
| 131 | 178 | ||
| 132 | if [ "$ARCH" != "um" ]; then | ||
| 133 | $MAKE -f $srctree/Makefile headers | ||
| 134 | $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" | ||
| 135 | # move asm headers to /usr/include/<libc-machine>/asm to match the structure | ||
| 136 | # used by Debian-based distros (to support multi-arch) | ||
| 137 | host_arch=$(dpkg-architecture -a$(cat debian/arch) -qDEB_HOST_MULTIARCH) | ||
| 138 | mkdir $libc_headers_dir/usr/include/$host_arch | ||
| 139 | mv $libc_headers_dir/usr/include/asm $libc_headers_dir/usr/include/$host_arch/ | ||
| 140 | fi | ||
| 141 | |||
| 142 | # Install the maintainer scripts | 179 | # Install the maintainer scripts |
| 143 | # Note: hook scripts under /etc/kernel are also executed by official Debian | 180 | # Note: hook scripts under /etc/kernel are also executed by official Debian |
| 144 | # kernel packages, as well as kernel packages built using make-kpkg. | 181 | # kernel packages, as well as kernel packages built using make-kpkg. |
| @@ -164,29 +201,12 @@ EOF · 19 unmodified lines | |||
| 164 | chmod 755 "$tmpdir/DEBIAN/$script" | 201 | chmod 755 "$tmpdir/DEBIAN/$script" |
| 165 | done | 202 | done |
| 166 | 203 | ||
| 167 | # Build kernel header package | ||
| 168 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" | ||
| 169 | (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" | ||
| 170 | (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" | ||
| 171 | (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" | ||
| 172 | if is_enabled CONFIG_STACK_VALIDATION; then | ||
| 173 | (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" | ||
| 174 | fi | ||
| 175 | (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" | ||
| 176 | if is_enabled CONFIG_GCC_PLUGINS; then | ||
| 177 | (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" | ||
| 178 | fi | ||
| 179 | destdir=$kernel_headers_dir/usr/src/linux-headers-$version | ||
| 180 | mkdir -p "$destdir" | ||
| 181 | (cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) | ||
| 182 | (cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) | ||
| 183 | (cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be | ||
| 184 | ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" | ||
| 185 | rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" | ||
| 186 | |||
| 187 | if [ "$ARCH" != "um" ]; then | 204 | if [ "$ARCH" != "um" ]; then |
| 188 | create_package "$kernel_headers_packagename" "$kernel_headers_dir" | 205 | deploy_kernel_headers debian/linux-headers |
| 189 | create_package "$libc_headers_packagename" "$libc_headers_dir" | 206 | create_package linux-headers-$version debian/linux-headers |
| 207 | |||
| 208 | deploy_libc_headers debian/linux-libc-dev | ||
| 209 | create_package linux-libc-dev debian/linux-libc-dev | ||
| 190 | fi | 210 | fi |
| 191 | 211 | ||
| 192 | create_package "$packagename" "$tmpdir" | 212 | create_package "$packagename" "$tmpdir" |