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 ...
Unified · Split
| @@ -154,11 +154,6 @@ KCONFIG_AUTOCONFIG · 153 unmodified lines | |||
| 154 | This environment variable can be set to specify the path & name of the | 154 | This environment variable can be set to specify the path & name of the |
| 155 | "auto.conf" file. Its default value is "include/config/auto.conf". | 155 | "auto.conf" file. Its default value is "include/config/auto.conf". |
| 156 | 156 | ||
| 157 | KCONFIG_TRISTATE | ||
| 158 | ---------------- | ||
| 159 | This environment variable can be set to specify the path & name of the | ||
| 160 | "tristate.conf" file. Its default value is "include/config/tristate.conf". | ||
| 161 | |||
| 162 | KCONFIG_AUTOHEADER | 157 | KCONFIG_AUTOHEADER |
| 163 | ------------------ | 158 | ------------------ |
| 164 | This environment variable can be set to specify the path & name of the | 159 | This environment variable can be set to specify the path & name of the |
| @@ -423,7 +423,6 @@ INSTALLKERNEL := installkernel · 422 unmodified lines | |||
| 423 | DEPMOD = /sbin/depmod | 423 | DEPMOD = /sbin/depmod |
| 424 | PERL = perl | 424 | PERL = perl |
| 425 | PYTHON = python | 425 | PYTHON = python |
| 426 | PYTHON2 = python2 | ||
| 427 | PYTHON3 = python3 | 426 | PYTHON3 = python3 |
| 428 | CHECK = sparse | 427 | CHECK = sparse |
| 429 | BASH = bash | 428 | BASH = bash |
| @@ -474,7 +473,7 @@ CLANG_FLAGS := · 44 unmodified lines | |||
| 474 | 473 | ||
| 475 | export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC | 474 | export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC |
| 476 | export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL | 475 | export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL |
| 477 | export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX | 476 | export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX |
| 478 | export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE | 477 | export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE |
| 479 | 478 | ||
| 480 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS | 479 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS |
| @@ -674,7 +673,7 @@ $(KCONFIG_CONFIG): · 193 unmodified lines | |||
| 674 | # | 673 | # |
| 675 | # This exploits the 'multi-target pattern rule' trick. | 674 | # This exploits the 'multi-target pattern rule' trick. |
| 676 | # The syncconfig should be executed only once to make all the targets. | 675 | # The syncconfig should be executed only once to make all the targets. |
| 677 | %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) | 676 | %/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG) |
| 678 | $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig | 677 | $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig |
| 679 | else # !may-sync-config | 678 | else # !may-sync-config |
| 680 | # External modules and some install targets need include/generated/autoconf.h | 679 | # External modules and some install targets need include/generated/autoconf.h |
| @@ -1278,24 +1277,13 @@ all: modules · 597 unmodified lines | |||
| 1278 | # using awk while concatenating to the final file. | 1277 | # using awk while concatenating to the final file. |
| 1279 | 1278 | ||
| 1280 | PHONY += modules | 1279 | PHONY += modules |
| 1281 | modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin | 1280 | modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order |
| 1282 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost | 1281 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
| 1283 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh | 1282 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh |
| 1284 | 1283 | ||
| 1285 | modules.order: descend | 1284 | modules.order: descend |
| 1286 | $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@ | 1285 | $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@ |
| 1287 | 1286 | ||
| 1288 | modbuiltin-dirs := $(addprefix _modbuiltin_, $(build-dirs)) | ||
| 1289 | |||
| 1290 | modules.builtin: $(modbuiltin-dirs) | ||
| 1291 | $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@ | ||
| 1292 | |||
| 1293 | PHONY += $(modbuiltin-dirs) | ||
| 1294 | # tristate.conf is not included from this Makefile. Add it as a prerequisite | ||
| 1295 | # here to make it self-healing in case somebody accidentally removes it. | ||
| 1296 | $(modbuiltin-dirs): include/config/tristate.conf | ||
| 1297 | $(Q)$(MAKE) $(modbuiltin)=$(patsubst _modbuiltin_%,%,$@) | ||
| 1298 | |||
| 1299 | # Target to prepare building external modules | 1287 | # Target to prepare building external modules |
| 1300 | PHONY += modules_prepare | 1288 | PHONY += modules_prepare |
| 1301 | modules_prepare: prepare | 1289 | modules_prepare: prepare |
| @@ -1315,7 +1303,7 @@ _modinst_: · 13 unmodified lines | |||
| 1315 | ln -s $(CURDIR) $(MODLIB)/build ; \ | 1303 | ln -s $(CURDIR) $(MODLIB)/build ; \ |
| 1316 | fi | 1304 | fi |
| 1317 | @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order | 1305 | @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order |
| 1318 | @sed 's:^:kernel/:' modules.builtin > $(MODLIB)/modules.builtin | 1306 | @cp -f modules.builtin $(MODLIB)/ |
| 1319 | @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ | 1307 | @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ |
| 1320 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst | 1308 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
| 1321 | 1309 | ||
| @@ -1357,7 +1345,7 @@ endif # CONFIG_MODULES · 35 unmodified lines | |||
| 1357 | 1345 | ||
| 1358 | # Directories & files removed with 'make clean' | 1346 | # Directories & files removed with 'make clean' |
| 1359 | CLEAN_DIRS += include/ksym | 1347 | CLEAN_DIRS += include/ksym |
| 1360 | CLEAN_FILES += modules.builtin.modinfo modules.nsdeps | 1348 | CLEAN_FILES += modules.builtin modules.builtin.modinfo modules.nsdeps |
| 1361 | 1349 | ||
| 1362 | # Directories & files removed with 'make mrproper' | 1350 | # Directories & files removed with 'make mrproper' |
| 1363 | MRPROPER_DIRS += include/config include/generated \ | 1351 | MRPROPER_DIRS += include/config include/generated \ |
| @@ -1712,7 +1700,7 @@ clean: $(clean-dirs) · 348 unmodified lines | |||
| 1712 | -o -name '*.lex.c' -o -name '*.tab.[ch]' \ | 1700 | -o -name '*.lex.c' -o -name '*.tab.[ch]' \ |
| 1713 | -o -name '*.asn1.[ch]' \ | 1701 | -o -name '*.asn1.[ch]' \ |
| 1714 | -o -name '*.symtypes' -o -name 'modules.order' \ | 1702 | -o -name '*.symtypes' -o -name 'modules.order' \ |
| 1715 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ | 1703 | -o -name '.tmp_*.o.*' \ |
| 1716 | -o -name '*.c.[012]*.*' \ | 1704 | -o -name '*.c.[012]*.*' \ |
| 1717 | -o -name '*.ll' \ | 1705 | -o -name '*.ll' \ |
| 1718 | -o -name '*.gcno' \) -type f -print | xargs rm -f | 1706 | -o -name '*.gcno' \) -type f -print | xargs rm -f |
| @@ -169,6 +169,16 @@ extern void cleanup_module(void); · 168 unmodified lines | |||
| 169 | */ | 169 | */ |
| 170 | #define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep) | 170 | #define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep) |
| 171 | 171 | ||
| 172 | /* | ||
| 173 | * MODULE_FILE is used for generating modules.builtin | ||
| 174 | * So, make it no-op when this is being built as a module | ||
| 175 | */ | ||
| 176 | #ifdef MODULE | ||
| 177 | #define MODULE_FILE | ||
| 178 | #else | ||
| 179 | #define MODULE_FILE MODULE_INFO(file, KBUILD_MODFILE); | ||
| 180 | #endif | ||
| 181 | |||
| 172 | /* | 182 | /* |
| 173 | * The following license idents are currently accepted as indicating free | 183 | * The following license idents are currently accepted as indicating free |
| 174 | * software modules | 184 | * software modules |
| @@ -213,7 +223,7 @@ extern void cleanup_module(void); · 38 unmodified lines | |||
| 213 | * 2. So the community can ignore bug reports including proprietary modules | 223 | * 2. So the community can ignore bug reports including proprietary modules |
| 214 | * 3. So vendors can do likewise based on their own policies | 224 | * 3. So vendors can do likewise based on their own policies |
| 215 | */ | 225 | */ |
| 216 | #define MODULE_LICENSE(_license) MODULE_INFO(license, _license) | 226 | #define MODULE_LICENSE(_license) MODULE_FILE MODULE_INFO(license, _license) |
| 217 | 227 | ||
| 218 | /* | 228 | /* |
| 219 | * Author(s), use "Name <email>" or just "Name", for multiple | 229 | * Author(s), use "Name <email>" or just "Name", for multiple |
| @@ -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" |
| @@ -1,9 +1,3 @@ | |||
| 1 | # | ||
| 2 | # Generated files | ||
| 3 | # | ||
| 4 | gen_init_cpio | 1 | gen_init_cpio |
| 5 | initramfs_data.cpio | 2 | initramfs_data.cpio |
| 6 | initramfs_data.cpio.gz | 3 | /initramfs_inc_data |
| 7 | initramfs_data.cpio.bz2 | ||
| 8 | initramfs_data.cpio.lzma | ||
| 9 | initramfs_list | ||
| @@ -54,7 +54,6 @@ config INITRAMFS_ROOT_GID · 53 unmodified lines | |||
| 54 | 54 | ||
| 55 | config RD_GZIP | 55 | config RD_GZIP |
| 56 | bool "Support initial ramdisk/ramfs compressed using gzip" | 56 | bool "Support initial ramdisk/ramfs compressed using gzip" |
| 57 | depends on BLK_DEV_INITRD | ||
| 58 | default y | 57 | default y |
| 59 | select DECOMPRESS_GZIP | 58 | select DECOMPRESS_GZIP |
| 60 | help | 59 | help |
| @@ -64,7 +63,6 @@ config RD_GZIP · 3 unmodified lines | |||
| 64 | config RD_BZIP2 | 63 | config RD_BZIP2 |
| 65 | bool "Support initial ramdisk/ramfs compressed using bzip2" | 64 | bool "Support initial ramdisk/ramfs compressed using bzip2" |
| 66 | default y | 65 | default y |
| 67 | depends on BLK_DEV_INITRD | ||
| 68 | select DECOMPRESS_BZIP2 | 66 | select DECOMPRESS_BZIP2 |
| 69 | help | 67 | help |
| 70 | Support loading of a bzip2 encoded initial ramdisk or cpio buffer | 68 | Support loading of a bzip2 encoded initial ramdisk or cpio buffer |
| @@ -73,7 +71,6 @@ config RD_BZIP2 · 2 unmodified lines | |||
| 73 | config RD_LZMA | 71 | config RD_LZMA |
| 74 | bool "Support initial ramdisk/ramfs compressed using LZMA" | 72 | bool "Support initial ramdisk/ramfs compressed using LZMA" |
| 75 | default y | 73 | default y |
| 76 | depends on BLK_DEV_INITRD | ||
| 77 | select DECOMPRESS_LZMA | 74 | select DECOMPRESS_LZMA |
| 78 | help | 75 | help |
| 79 | Support loading of a LZMA encoded initial ramdisk or cpio buffer | 76 | Support loading of a LZMA encoded initial ramdisk or cpio buffer |
| @@ -81,7 +78,6 @@ config RD_LZMA · 1 unmodified line | |||
| 81 | 78 | ||
| 82 | config RD_XZ | 79 | config RD_XZ |
| 83 | bool "Support initial ramdisk/ramfs compressed using XZ" | 80 | bool "Support initial ramdisk/ramfs compressed using XZ" |
| 84 | depends on BLK_DEV_INITRD | ||
| 85 | default y | 81 | default y |
| 86 | select DECOMPRESS_XZ | 82 | select DECOMPRESS_XZ |
| 87 | help | 83 | help |
| @@ -91,7 +87,6 @@ config RD_XZ · 3 unmodified lines | |||
| 91 | config RD_LZO | 87 | config RD_LZO |
| 92 | bool "Support initial ramdisk/ramfs compressed using LZO" | 88 | bool "Support initial ramdisk/ramfs compressed using LZO" |
| 93 | default y | 89 | default y |
| 94 | depends on BLK_DEV_INITRD | ||
| 95 | select DECOMPRESS_LZO | 90 | select DECOMPRESS_LZO |
| 96 | help | 91 | help |
| 97 | Support loading of a LZO encoded initial ramdisk or cpio buffer | 92 | Support loading of a LZO encoded initial ramdisk or cpio buffer |
| @@ -100,7 +95,6 @@ config RD_LZO · 2 unmodified lines | |||
| 100 | config RD_LZ4 | 95 | config RD_LZ4 |
| 101 | bool "Support initial ramdisk/ramfs compressed using LZ4" | 96 | bool "Support initial ramdisk/ramfs compressed using LZ4" |
| 102 | default y | 97 | default y |
| 103 | depends on BLK_DEV_INITRD | ||
| 104 | select DECOMPRESS_LZ4 | 98 | select DECOMPRESS_LZ4 |
| 105 | help | 99 | help |
| 106 | Support loading of a LZ4 encoded initial ramdisk or cpio buffer | 100 | Support loading of a LZ4 encoded initial ramdisk or cpio buffer |
| @@ -108,8 +102,6 @@ config RD_LZ4 · 1 unmodified line | |||
| 108 | 102 | ||
| 109 | choice | 103 | choice |
| 110 | prompt "Built-in initramfs compression mode" | 104 | prompt "Built-in initramfs compression mode" |
| 111 | depends on INITRAMFS_SOURCE!="" | ||
| 112 | optional | ||
| 113 | help | 105 | help |
| 114 | This option allows you to decide by which algorithm the builtin | 106 | This option allows you to decide by which algorithm the builtin |
| 115 | initramfs will be compressed. Several compression algorithms are | 107 | initramfs will be compressed. Several compression algorithms are |
| @@ -215,21 +207,3 @@ config INITRAMFS_COMPRESSION_LZ4 · 99 unmodified lines | |||
| 215 | by default which could cause a build failure. | 207 | by default which could cause a build failure. |
| 216 | 208 | ||
| 217 | endchoice | 209 | endchoice |
| 218 | |||
| 219 | config INITRAMFS_COMPRESSION | ||
| 220 | depends on INITRAMFS_SOURCE!="" | ||
| 221 | string | ||
| 222 | default "" if INITRAMFS_COMPRESSION_NONE | ||
| 223 | default ".gz" if INITRAMFS_COMPRESSION_GZIP | ||
| 224 | default ".bz2" if INITRAMFS_COMPRESSION_BZIP2 | ||
| 225 | default ".lzma" if INITRAMFS_COMPRESSION_LZMA | ||
| 226 | default ".xz" if INITRAMFS_COMPRESSION_XZ | ||
| 227 | default ".lzo" if INITRAMFS_COMPRESSION_LZO | ||
| 228 | default ".lz4" if INITRAMFS_COMPRESSION_LZ4 | ||
| 229 | default ".gz" if RD_GZIP | ||
| 230 | default ".lz4" if RD_LZ4 | ||
| 231 | default ".lzo" if RD_LZO | ||
| 232 | default ".xz" if RD_XZ | ||
| 233 | default ".lzma" if RD_LZMA | ||
| 234 | default ".bz2" if RD_BZIP2 | ||
| 235 | default "" | ||
| @@ -3,61 +3,86 @@ · 2 unmodified lines | |||
| 3 | # kbuild file for usr/ - including initramfs image | 3 | # kbuild file for usr/ - including initramfs image |
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | klibcdirs:; | 6 | # cmd_bzip2, cmd_lzma, cmd_lzo, cmd_lz4 from scripts/Makefile.lib appends the |
| 7 | PHONY += klibcdirs | 7 | # size at the end of the compressed file, which unfortunately does not work |
| 8 | # with unpack_to_rootfs(). Make size_append no-op. | ||
| 9 | override size_append := : | ||
| 8 | 10 | ||
| 9 | suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION)) | 11 | compress-$(CONFIG_INITRAMFS_COMPRESSION_NONE) := shipped |
| 10 | datafile_y = initramfs_data.cpio$(suffix_y) | 12 | compress-$(CONFIG_INITRAMFS_COMPRESSION_GZIP) := gzip |
| 11 | datafile_d_y = .$(datafile_y).d | 13 | compress-$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) := bzip2 |
| 12 | AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)" | 14 | compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma |
| 15 | compress-$(CONFIG_INITRAMFS_COMPRESSION_XZ) := xzmisc | ||
| 16 | compress-$(CONFIG_INITRAMFS_COMPRESSION_LZO) := lzo | ||
| 17 | compress-$(CONFIG_INITRAMFS_COMPRESSION_LZ4) := lz4 | ||
| 13 | 18 | ||
| 14 | # clean rules do not have CONFIG_INITRAMFS_COMPRESSION. So clean up after all | ||
| 15 | # possible compression formats. | ||
| 16 | clean-files += initramfs_data.cpio* | ||
| 17 | |||
| 18 | # Generate builtin.o based on initramfs_data.o | ||
| 19 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o | 19 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o |
| 20 | 20 | ||
| 21 | # initramfs_data.o contains the compressed initramfs_data.cpio image. | 21 | $(obj)/initramfs_data.o: $(obj)/initramfs_inc_data |
| 22 | # The image is included using .incbin, a dependency which is not | 22 | |
| 23 | # tracked automatically. | 23 | ramfs-input := $(strip $(shell echo $(CONFIG_INITRAMFS_SOURCE))) |
| 24 | $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE | 24 | cpio-data := |
| 25 | |||
| 26 | # If CONFIG_INITRAMFS_SOURCE is empty, generate a small initramfs with the | ||
| 27 | # default contents. | ||
| 28 | ifeq ($(ramfs-input),) | ||
| 29 | ramfs-input := $(srctree)/$(src)/default_cpio_list | ||
| 30 | endif | ||
| 31 | |||
| 32 | ifeq ($(words $(ramfs-input)),1) | ||
| 33 | |||
| 34 | # If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with | ||
| 35 | # .cpio, use it directly as an initramfs. | ||
| 36 | ifneq ($(filter %.cpio,$(ramfs-input)),) | ||
| 37 | cpio-data := $(ramfs-input) | ||
| 38 | endif | ||
| 39 | |||
| 40 | # If CONFIG_INITRAMFS_SOURCE specifies a single file, and it is suffixed with | ||
| 41 | # .cpio.*, use it directly as an initramfs, and avoid double compression. | ||
| 42 | ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2) | ||
| 43 | cpio-data := $(ramfs-input) | ||
| 44 | compress-y := shipped | ||
| 45 | endif | ||
| 46 | |||
| 47 | endif | ||
| 48 | |||
| 49 | # For other cases, generate the initramfs cpio archive based on the contents | ||
| 50 | # specified by CONFIG_INITRAMFS_SOURCE. | ||
| 51 | ifeq ($(cpio-data),) | ||
| 25 | 52 | ||
| 26 | ##### | 53 | cpio-data := $(obj)/initramfs_data.cpio |
| 27 | # Generate the initramfs cpio archive | ||
| 28 | 54 | ||
| 29 | hostprogs-y := gen_init_cpio | 55 | hostprogs-y := gen_init_cpio |
| 30 | initramfs := $(CONFIG_SHELL) $(srctree)/$(src)/gen_initramfs_list.sh | 56 | |
| 31 | ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ | 57 | # .initramfs_data.cpio.d is used to identify all files included |
| 32 | $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) | ||
| 33 | ramfs-args := \ | ||
| 34 | $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ | ||
| 35 | $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) | ||
| 36 | |||
| 37 | # $(datafile_d_y) is used to identify all files included | ||
| 38 | # in initramfs and to detect if any files are added/removed. | 58 | # in initramfs and to detect if any files are added/removed. |
| 39 | # Removed files are identified by directory timestamp being updated | 59 | # Removed files are identified by directory timestamp being updated |
| 40 | # The dependency list is generated by gen_initramfs.sh -l | 60 | # The dependency list is generated by gen_initramfs.sh -l |
| 41 | ifneq ($(wildcard $(obj)/$(datafile_d_y)),) | 61 | -include $(obj)/.initramfs_data.cpio.d |
| 42 | include $(obj)/$(datafile_d_y) | ||
| 43 | endif | ||
| 44 | |||
| 45 | quiet_cmd_initfs = GEN $@ | ||
| 46 | cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) | ||
| 47 | |||
| 48 | targets := $(datafile_y) | ||
| 49 | 62 | ||
| 50 | # do not try to update files included in initramfs | 63 | # do not try to update files included in initramfs |
| 51 | $(deps_initramfs): ; | 64 | $(deps_initramfs): ; |
| 52 | 65 | ||
| 53 | $(deps_initramfs): klibcdirs | 66 | quiet_cmd_initfs = GEN $@ |
| 67 | cmd_initfs = \ | ||
| 68 | $(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \ | ||
| 69 | $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ | ||
| 70 | $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \ | ||
| 71 | $(ramfs-input) | ||
| 72 | |||
| 54 | # We rebuild initramfs_data.cpio if: | 73 | # We rebuild initramfs_data.cpio if: |
| 55 | # 1) Any included file is newer than initramfs_data.cpio | 74 | # 1) Any included file is newer than initramfs_data.cpio |
| 56 | # 2) There are changes in which files are included (added or deleted) | 75 | # 2) There are changes in which files are included (added or deleted) |
| 57 | # 3) If gen_init_cpio are newer than initramfs_data.cpio | 76 | # 3) If gen_init_cpio are newer than initramfs_data.cpio |
| 58 | # 4) Arguments to gen_initramfs.sh changes | 77 | # 4) Arguments to gen_initramfs.sh changes |
| 59 | $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs | 78 | $(obj)/initramfs_data.cpio: $(src)/gen_initramfs.sh $(obj)/gen_init_cpio $(deps_initramfs) FORCE |
| 60 | $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) | ||
| 61 | $(call if_changed,initfs) | 79 | $(call if_changed,initfs) |
| 62 | 80 | ||
| 81 | endif | ||
| 82 | |||
| 83 | $(obj)/initramfs_inc_data: $(cpio-data) FORCE | ||
| 84 | $(call if_changed,$(compress-y)) | ||
| 85 | |||
| 86 | targets += initramfs_data.cpio initramfs_inc_data | ||
| 87 | |||
| 63 | subdir-$(CONFIG_UAPI_HEADER_TEST) += include | 88 | subdir-$(CONFIG_UAPI_HEADER_TEST) += include |
| @@ -0,0 +1,6 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 2 | # This is a very simple, default initramfs | ||
| 3 | |||
| 4 | dir /dev 0755 0 0 | ||
| 5 | nod /dev/console 0600 0 0 c 5 1 | ||
| 6 | dir /root 0700 0 0 | ||
| @@ -5,8 +5,7 @@ · 4 unmodified lines | |||
| 5 | # Released under the terms of the GNU GPL | 5 | # Released under the terms of the GNU GPL |
| 6 | # | 6 | # |
| 7 | # Generate a cpio packed initramfs. It uses gen_init_cpio to generate | 7 | # Generate a cpio packed initramfs. It uses gen_init_cpio to generate |
| 8 | # the cpio archive, and then compresses it. | 8 | # the cpio archive. |
| 9 | # The script may also be used to generate the inputfile used for gen_init_cpio | ||
| 10 | # This script assumes that gen_init_cpio is located in usr/ directory | 9 | # This script assumes that gen_init_cpio is located in usr/ directory |
| 11 | 10 | ||
| 12 | # error out on errors | 11 | # error out on errors |
| @@ -15,9 +14,9 @@ set -e · 2 unmodified lines | |||
| 15 | usage() { | 14 | usage() { |
| 16 | cat << EOF | 15 | cat << EOF |
| 17 | Usage: | 16 | Usage: |
| 18 | $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... | 17 | $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... |
| 19 | -o <file> Create compressed initramfs file named <file> using | 18 | -o <file> Create initramfs file named <file> by using gen_init_cpio |
| 20 | gen_init_cpio and compressor depending on the extension | 19 | -l <dep_list> Create dependency list named <dep_list> |
| 21 | -u <uid> User ID to map to user ID 0 (root). | 20 | -u <uid> User ID to map to user ID 0 (root). |
| 22 | <uid> is only meaningful if <cpio_source> is a | 21 | <uid> is only meaningful if <cpio_source> is a |
| 23 | directory. "squash" forces all files to uid 0. | 22 | directory. "squash" forces all files to uid 0. |
| @@ -27,7 +26,6 @@ $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... · 3 unmodified lines | |||
| 27 | <cpio_source> File list or directory for cpio archive. | 26 | <cpio_source> File list or directory for cpio archive. |
| 28 | If <cpio_source> is a .cpio file it will be used | 27 | If <cpio_source> is a .cpio file it will be used |
| 29 | as direct input to initramfs. | 28 | as direct input to initramfs. |
| 30 | -d Output the default cpio list. | ||
| 31 | 29 | ||
| 32 | All options except -o and -l may be repeated and are interpreted | 30 | All options except -o and -l may be repeated and are interpreted |
| 33 | sequentially and immediately. -u and -g states are preserved across | 31 | sequentially and immediately. -u and -g states are preserved across |
| @@ -42,23 +40,6 @@ field() { · 8 unmodified lines | |||
| 42 | shift $1 ; echo $1 | 40 | shift $1 ; echo $1 |
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | list_default_initramfs() { | ||
| 46 | # echo usr/kinit/kinit | ||
| 47 | : | ||
| 48 | } | ||
| 49 | |||
| 50 | default_initramfs() { | ||
| 51 | cat <<-EOF >> ${output} | ||
| 52 | # This is a very simple, default initramfs | ||
| 53 | |||
| 54 | dir /dev 0755 0 0 | ||
| 55 | nod /dev/console 0600 0 0 c 5 1 | ||
| 56 | dir /root 0700 0 0 | ||
| 57 | # file /kinit usr/kinit/kinit 0755 0 0 | ||
| 58 | # slink /init kinit 0755 0 0 | ||
| 59 | EOF | ||
| 60 | } | ||
| 61 | |||
| 62 | filetype() { | 43 | filetype() { |
| 63 | local argv1="$1" | 44 | local argv1="$1" |
| 64 | 45 | ||
| @@ -81,10 +62,6 @@ filetype() { · 16 unmodified lines | |||
| 81 | return 0 | 62 | return 0 |
| 82 | } | 63 | } |
| 83 | 64 | ||
| 84 | list_print_mtime() { | ||
| 85 | : | ||
| 86 | } | ||
| 87 | |||
| 88 | print_mtime() { | 65 | print_mtime() { |
| 89 | local my_mtime="0" | 66 | local my_mtime="0" |
| 90 | 67 | ||
| @@ -92,15 +69,15 @@ print_mtime() { · 1 unmodified line | |||
| 92 | my_mtime=$(find "$1" -printf "%T@\n" | sort -r | head -n 1) | 69 | my_mtime=$(find "$1" -printf "%T@\n" | sort -r | head -n 1) |
| 93 | fi | 70 | fi |
| 94 | 71 | ||
| 95 | echo "# Last modified: ${my_mtime}" >> ${output} | 72 | echo "# Last modified: ${my_mtime}" >> $cpio_list |
| 96 | echo "" >> ${output} | 73 | echo "" >> $cpio_list |
| 97 | } | 74 | } |
| 98 | 75 | ||
| 99 | list_parse() { | 76 | list_parse() { |
| 100 | if [ -L "$1" ]; then | 77 | if [ -z "$dep_list" -o -L "$1" ]; then |
| 101 | return | 78 | return |
| 102 | fi | 79 | fi |
| 103 | echo "$1" | sed 's/:/\\:/g; s/$/ \\/' | 80 | echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list |
| 104 | } | 81 | } |
| 105 | 82 | ||
| 106 | # for each file print a line in following format | 83 | # for each file print a line in following format |
| @@ -146,7 +123,7 @@ parse() { · 39 unmodified lines | |||
| 146 | ;; | 123 | ;; |
| 147 | esac | 124 | esac |
| 148 | 125 | ||
| 149 | echo "${str}" >> ${output} | 126 | echo "${str}" >> $cpio_list |
| 150 | 127 | ||
| 151 | return 0 | 128 | return 0 |
| 152 | } | 129 | } |
| @@ -161,58 +138,47 @@ unknown_option() { · 8 unmodified lines | |||
| 161 | exit 1 | 138 | exit 1 |
| 162 | } | 139 | } |
| 163 | 140 | ||
| 164 | list_header() { | ||
| 165 | : | ||
| 166 | } | ||
| 167 | |||
| 168 | header() { | 141 | header() { |
| 169 | printf "\n#####################\n# $1\n" >> ${output} | 142 | printf "\n#####################\n# $1\n" >> $cpio_list |
| 170 | } | 143 | } |
| 171 | 144 | ||
| 172 | # process one directory (incl sub-directories) | 145 | # process one directory (incl sub-directories) |
| 173 | dir_filelist() { | 146 | dir_filelist() { |
| 174 | ${dep_list}header "$1" | 147 | header "$1" |
| 175 | 148 | ||
| 176 | srcdir=$(echo "$1" | sed -e 's://*:/:g') | 149 | srcdir=$(echo "$1" | sed -e 's://*:/:g') |
| 177 | dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LANG=C sort) | 150 | dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LANG=C sort) |
| 178 | 151 | ||
| 179 | # If $dirlist is only one line, then the directory is empty | 152 | # If $dirlist is only one line, then the directory is empty |
| 180 | if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then | 153 | if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then |
| 181 | ${dep_list}print_mtime "$1" | 154 | print_mtime "$1" |
| 182 | 155 | ||
| 183 | echo "${dirlist}" | \ | 156 | echo "${dirlist}" | \ |
| 184 | while read x; do | 157 | while read x; do |
| 185 | ${dep_list}parse ${x} | 158 | list_parse $x |
| 159 | parse $x | ||
| 186 | done | 160 | done |
| 187 | fi | 161 | fi |
| 188 | } | 162 | } |
| 189 | 163 | ||
| 190 | # if only one file is specified and it is .cpio file then use it direct as fs | ||
| 191 | # if a directory is specified then add all files in given direcotry to fs | ||
| 192 | # if a regular file is specified assume it is in gen_initramfs format | ||
| 193 | input_file() { | 164 | input_file() { |
| 194 | source="$1" | 165 | source="$1" |
| 195 | if [ -f "$1" ]; then | 166 | if [ -f "$1" ]; then |
| 196 | ${dep_list}header "$1" | 167 | # If a regular file is specified, assume it is in |
| 197 | is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\{0,1\}/cpio/')" | 168 | # gen_init_cpio format |
| 198 | if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then | 169 | header "$1" |
| 199 | cpio_file=$1 | 170 | print_mtime "$1" >> $cpio_list |
| 200 | echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" | 171 | cat "$1" >> $cpio_list |
| 201 | [ ! -z ${dep_list} ] && echo "$1" | 172 | if [ -n "$dep_list" ]; then |
| 202 | return 0 | 173 | echo "$1 \\" >> $dep_list |
| 203 | fi | ||
| 204 | if [ -z ${dep_list} ]; then | ||
| 205 | print_mtime "$1" >> ${output} | ||
| 206 | cat "$1" >> ${output} | ||
| 207 | else | ||
| 208 | echo "$1 \\" | ||
| 209 | cat "$1" | while read type dir file perm ; do | 174 | cat "$1" | while read type dir file perm ; do |
| 210 | if [ "$type" = "file" ]; then | 175 | if [ "$type" = "file" ]; then |
| 211 | echo "$file \\"; | 176 | echo "$file \\" >> $dep_list |
| 212 | fi | 177 | fi |
| 213 | done | 178 | done |
| 214 | fi | 179 | fi |
| 215 | elif [ -d "$1" ]; then | 180 | elif [ -d "$1" ]; then |
| 181 | # If a directory is specified then add all files in it to fs | ||
| 216 | dir_filelist "$1" | 182 | dir_filelist "$1" |
| 217 | else | 183 | else |
| 218 | echo " ${prog}: Cannot open '$1'" >&2 | 184 | echo " ${prog}: Cannot open '$1'" >&2 |
| @@ -224,51 +190,24 @@ prog=$0 · 5 unmodified lines | |||
| 224 | root_uid=0 | 190 | root_uid=0 |
| 225 | root_gid=0 | 191 | root_gid=0 |
| 226 | dep_list= | 192 | dep_list= |
| 227 | cpio_file= | 193 | cpio_list=$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) |
| 228 | cpio_list= | ||
| 229 | output="/dev/stdout" | 194 | output="/dev/stdout" |
| 230 | output_file="" | ||
| 231 | is_cpio_compressed= | ||
| 232 | compr="gzip -n -9 -f" | ||
| 233 | 195 | ||
| 234 | arg="$1" | 196 | trap "rm -f $cpio_list" EXIT |
| 235 | case "$arg" in | 197 | |
| 236 | "-l") # files included in initramfs - used by kbuild | ||
| 237 | dep_list="list_" | ||
| 238 | echo "deps_initramfs := $0 \\" | ||
| 239 | shift | ||
| 240 | ;; | ||
| 241 | "-o") # generate compressed cpio image named $1 | ||
| 242 | shift | ||
| 243 | output_file="$1" | ||
| 244 | cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" | ||
| 245 | output=${cpio_list} | ||
| 246 | echo "$output_file" | grep -q "\.gz$" \ | ||
| 247 | && [ -x "`which gzip 2> /dev/null`" ] \ | ||
| 248 | && compr="gzip -n -9 -f" | ||
| 249 | echo "$output_file" | grep -q "\.bz2$" \ | ||
| 250 | && [ -x "`which bzip2 2> /dev/null`" ] \ | ||
| 251 | && compr="bzip2 -9 -f" | ||
| 252 | echo "$output_file" | grep -q "\.lzma$" \ | ||
| 253 | && [ -x "`which lzma 2> /dev/null`" ] \ | ||
| 254 | && compr="lzma -9 -f" | ||
| 255 | echo "$output_file" | grep -q "\.xz$" \ | ||
| 256 | && [ -x "`which xz 2> /dev/null`" ] \ | ||
| 257 | && compr="xz --check=crc32 --lzma2=dict=1MiB" | ||
| 258 | echo "$output_file" | grep -q "\.lzo$" \ | ||
| 259 | && [ -x "`which lzop 2> /dev/null`" ] \ | ||
| 260 | && compr="lzop -9 -f" | ||
| 261 | echo "$output_file" | grep -q "\.lz4$" \ | ||
| 262 | && [ -x "`which lz4 2> /dev/null`" ] \ | ||
| 263 | && compr="lz4 -l -9 -f" | ||
| 264 | echo "$output_file" | grep -q "\.cpio$" && compr="cat" | ||
| 265 | shift | ||
| 266 | ;; | ||
| 267 | esac | ||
| 268 | while [ $# -gt 0 ]; do | 198 | while [ $# -gt 0 ]; do |
| 269 | arg="$1" | 199 | arg="$1" |
| 270 | shift | 200 | shift |
| 271 | case "$arg" in | 201 | case "$arg" in |
| 202 | "-l") # files included in initramfs - used by kbuild | ||
| 203 | dep_list="$1" | ||
| 204 | echo "deps_initramfs := \\" > $dep_list | ||
| 205 | shift | ||
| 206 | ;; | ||
| 207 | "-o") # generate cpio image named $1 | ||
| 208 | output="$1" | ||
| 209 | shift | ||
| 210 | ;; | ||
| 272 | "-u") # map $1 to uid=0 (root) | 211 | "-u") # map $1 to uid=0 (root) |
| 273 | root_uid="$1" | 212 | root_uid="$1" |
| 274 | [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0) | 213 | [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0) |
| @@ -279,10 +218,6 @@ while [ $# -gt 0 ]; do · 4 unmodified lines | |||
| 279 | [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0) | 218 | [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0) |
| 280 | shift | 219 | shift |
| 281 | ;; | 220 | ;; |
| 282 | "-d") # display default initramfs list | ||
| 283 | default_list="$arg" | ||
| 284 | ${dep_list}default_initramfs | ||
| 285 | ;; | ||
| 286 | "-h") | 221 | "-h") |
| 287 | usage | 222 | usage |
| 288 | exit 0 | 223 | exit 0 |
| @@ -293,36 +228,20 @@ while [ $# -gt 0 ]; do · 4 unmodified lines | |||
| 293 | unknown_option | 228 | unknown_option |
| 294 | ;; | 229 | ;; |
| 295 | *) # input file/dir - process it | 230 | *) # input file/dir - process it |
| 296 | input_file "$arg" "$#" | 231 | input_file "$arg" |
| 297 | ;; | 232 | ;; |
| 298 | esac | 233 | esac |
| 299 | ;; | 234 | ;; |
| 300 | esac | 235 | esac |
| 301 | done | 236 | done |
| 302 | 237 | ||
| 303 | # If output_file is set we will generate cpio archive and compress it | 238 | # If output_file is set we will generate cpio archive |
| 304 | # we are careful to delete tmp files | 239 | # we are careful to delete tmp files |
| 305 | if [ ! -z ${output_file} ]; then | 240 | timestamp= |
| 306 | if [ -z ${cpio_file} ]; then | 241 | if test -n "$KBUILD_BUILD_TIMESTAMP"; then |
| 307 | timestamp= | 242 | timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" |
| 308 | if test -n "$KBUILD_BUILD_TIMESTAMP"; then | 243 | if test -n "$timestamp"; then |
| 309 | timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" | 244 | timestamp="-t $timestamp" |
| 310 | if test -n "$timestamp"; then | ||
| 311 | timestamp="-t $timestamp" | ||
| 312 | fi | ||
| 313 | fi | ||
| 314 | cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" | ||
| 315 | usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile} | ||
| 316 | else | ||
| 317 | cpio_tfile=${cpio_file} | ||
| 318 | fi | ||
| 319 | rm ${cpio_list} | ||
| 320 | if [ "${is_cpio_compressed}" = "compressed" ]; then | ||
| 321 | cat ${cpio_tfile} > ${output_file} | ||
| 322 | else | ||
| 323 | (cat ${cpio_tfile} | ${compr} - > ${output_file}) \ | ||
| 324 | || (rm -f ${output_file} ; false) | ||
| 325 | fi | 245 | fi |
| 326 | [ -z ${cpio_file} ] && rm ${cpio_tfile} | ||
| 327 | fi | 246 | fi |
| 328 | exit 0 | 247 | usr/gen_init_cpio $timestamp $cpio_list > $output |
| @@ -16,87 +16,88 @@ override c_flags = $(UAPI_CFLAGS) -Wp,-MD,$(depfile) -I$(objtree)/usr/include · 15 unmodified lines | |||
| 16 | # Please consider to fix the header first. | 16 | # Please consider to fix the header first. |
| 17 | # | 17 | # |
| 18 | # Sorted alphabetically. | 18 | # Sorted alphabetically. |
| 19 | header-test- += asm/shmbuf.h | 19 | no-header-test += asm/shmbuf.h |
| 20 | header-test- += asm/signal.h | 20 | no-header-test += asm/signal.h |
| 21 | header-test- += asm/ucontext.h | 21 | no-header-test += asm/ucontext.h |
| 22 | header-test- += drm/vmwgfx_drm.h | 22 | no-header-test += drm/vmwgfx_drm.h |
| 23 | header-test- += linux/am437x-vpfe.h | 23 | no-header-test += linux/am437x-vpfe.h |
| 24 | header-test- += linux/android/binder.h | 24 | no-header-test += linux/android/binder.h |
| 25 | header-test- += linux/android/binderfs.h | 25 | no-header-test += linux/android/binderfs.h |
| 26 | header-test- += linux/coda.h | 26 | no-header-test += linux/coda.h |
| 27 | header-test- += linux/elfcore.h | 27 | no-header-test += linux/elfcore.h |
| 28 | header-test- += linux/errqueue.h | 28 | no-header-test += linux/errqueue.h |
| 29 | header-test- += linux/fsmap.h | 29 | no-header-test += linux/fsmap.h |
| 30 | header-test- += linux/hdlc/ioctl.h | 30 | no-header-test += linux/hdlc/ioctl.h |
| 31 | header-test- += linux/ivtv.h | 31 | no-header-test += linux/ivtv.h |
| 32 | header-test- += linux/kexec.h | 32 | no-header-test += linux/kexec.h |
| 33 | header-test- += linux/matroxfb.h | 33 | no-header-test += linux/matroxfb.h |
| 34 | header-test- += linux/nfc.h | 34 | no-header-test += linux/nfc.h |
| 35 | header-test- += linux/omap3isp.h | 35 | no-header-test += linux/omap3isp.h |
| 36 | header-test- += linux/omapfb.h | 36 | no-header-test += linux/omapfb.h |
| 37 | header-test- += linux/patchkey.h | 37 | no-header-test += linux/patchkey.h |
| 38 | header-test- += linux/phonet.h | 38 | no-header-test += linux/phonet.h |
| 39 | header-test- += linux/reiserfs_xattr.h | 39 | no-header-test += linux/reiserfs_xattr.h |
| 40 | header-test- += linux/sctp.h | 40 | no-header-test += linux/sctp.h |
| 41 | header-test- += linux/signal.h | 41 | no-header-test += linux/signal.h |
| 42 | header-test- += linux/sysctl.h | 42 | no-header-test += linux/sysctl.h |
| 43 | header-test- += linux/usb/audio.h | 43 | no-header-test += linux/usb/audio.h |
| 44 | header-test- += linux/v4l2-mediabus.h | 44 | no-header-test += linux/v4l2-mediabus.h |
| 45 | header-test- += linux/v4l2-subdev.h | 45 | no-header-test += linux/v4l2-subdev.h |
| 46 | header-test- += linux/videodev2.h | 46 | no-header-test += linux/videodev2.h |
| 47 | header-test- += linux/vm_sockets.h | 47 | no-header-test += linux/vm_sockets.h |
| 48 | header-test- += sound/asequencer.h | 48 | no-header-test += sound/asequencer.h |
| 49 | header-test- += sound/asoc.h | 49 | no-header-test += sound/asoc.h |
| 50 | header-test- += sound/asound.h | 50 | no-header-test += sound/asound.h |
| 51 | header-test- += sound/compress_offload.h | 51 | no-header-test += sound/compress_offload.h |
| 52 | header-test- += sound/emu10k1.h | 52 | no-header-test += sound/emu10k1.h |
| 53 | header-test- += sound/sfnt_info.h | 53 | no-header-test += sound/sfnt_info.h |
| 54 | header-test- += xen/evtchn.h | 54 | no-header-test += xen/evtchn.h |
| 55 | header-test- += xen/gntdev.h | 55 | no-header-test += xen/gntdev.h |
| 56 | header-test- += xen/privcmd.h | 56 | no-header-test += xen/privcmd.h |
| 57 | 57 | ||
| 58 | # More headers are broken in some architectures | 58 | # More headers are broken in some architectures |
| 59 | 59 | ||
| 60 | ifeq ($(SRCARCH),arc) | 60 | ifeq ($(SRCARCH),arc) |
| 61 | header-test- += linux/bpf_perf_event.h | 61 | no-header-test += linux/bpf_perf_event.h |
| 62 | endif | 62 | endif |
| 63 | 63 | ||
| 64 | ifeq ($(SRCARCH),ia64) | 64 | ifeq ($(SRCARCH),ia64) |
| 65 | header-test- += asm/setup.h | 65 | no-header-test += asm/setup.h |
| 66 | header-test- += asm/sigcontext.h | 66 | no-header-test += asm/sigcontext.h |
| 67 | header-test- += asm/perfmon.h | 67 | no-header-test += asm/perfmon.h |
| 68 | header-test- += asm/perfmon_default_smpl.h | 68 | no-header-test += asm/perfmon_default_smpl.h |
| 69 | header-test- += linux/if_bonding.h | 69 | no-header-test += linux/if_bonding.h |
| 70 | endif | 70 | endif |
| 71 | 71 | ||
| 72 | ifeq ($(SRCARCH),mips) | 72 | ifeq ($(SRCARCH),mips) |
| 73 | header-test- += asm/stat.h | 73 | no-header-test += asm/stat.h |
| 74 | endif | 74 | endif |
| 75 | 75 | ||
| 76 | ifeq ($(SRCARCH),powerpc) | 76 | ifeq ($(SRCARCH),powerpc) |
| 77 | header-test- += asm/stat.h | 77 | no-header-test += asm/stat.h |
| 78 | header-test- += linux/bpf_perf_event.h | 78 | no-header-test += linux/bpf_perf_event.h |
| 79 | endif | 79 | endif |
| 80 | 80 | ||
| 81 | ifeq ($(SRCARCH),riscv) | 81 | ifeq ($(SRCARCH),riscv) |
| 82 | header-test- += linux/bpf_perf_event.h | 82 | no-header-test += linux/bpf_perf_event.h |
| 83 | endif | 83 | endif |
| 84 | 84 | ||
| 85 | ifeq ($(SRCARCH),sparc) | 85 | ifeq ($(SRCARCH),sparc) |
| 86 | header-test- += asm/stat.h | 86 | no-header-test += asm/stat.h |
| 87 | header-test- += asm/uctx.h | 87 | no-header-test += asm/uctx.h |
| 88 | header-test- += asm/fbio.h | 88 | no-header-test += asm/fbio.h |
| 89 | endif | 89 | endif |
| 90 | 90 | ||
| 91 | # asm-generic/*.h is used by asm/*.h, and should not be included directly | 91 | # asm-generic/*.h is used by asm/*.h, and should not be included directly |
| 92 | header-test- += asm-generic/% | 92 | no-header-test += asm-generic/% |
| 93 | 93 | ||
| 94 | extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) | 94 | extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) |
| 95 | 95 | ||
| 96 | # Include the header to detect missing include guard. | ||
| 96 | quiet_cmd_hdrtest = HDRTEST $< | 97 | quiet_cmd_hdrtest = HDRTEST $< |
| 97 | cmd_hdrtest = \ | 98 | cmd_hdrtest = \ |
| 98 | $(CC) $(c_flags) -S -o /dev/null -x c /dev/null \ | 99 | $(CC) $(c_flags) -S -o /dev/null -x c /dev/null \ |
| 99 | $(if $(filter-out $(header-test-), $*.h), -include $<); \ | 100 | $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ |
| 100 | $(PERL) $(srctree)/scripts/headers_check.pl $(obj) $(SRCARCH) $<; \ | 101 | $(PERL) $(srctree)/scripts/headers_check.pl $(obj) $(SRCARCH) $<; \ |
| 101 | touch $@ | 102 | touch $@ |
| 102 | 103 | ||
| @@ -22,12 +22,9 @@ · 21 unmodified lines | |||
| 22 | in the ELF header, as required by certain architectures. | 22 | in the ELF header, as required by certain architectures. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include <linux/stringify.h> | ||
| 26 | #include <asm-generic/vmlinux.lds.h> | ||
| 27 | |||
| 28 | .section .init.ramfs,"a" | 25 | .section .init.ramfs,"a" |
| 29 | __irf_start: | 26 | __irf_start: |
| 30 | .incbin __stringify(INITRAMFS_IMAGE) | 27 | .incbin "usr/initramfs_inc_data" |
| 31 | __irf_end: | 28 | __irf_end: |
| 32 | .section .init.ramfs.info,"a" | 29 | .section .init.ramfs.info,"a" |
| 33 | .globl __initramfs_size | 30 | .globl __initramfs_size |