Kbuild updates for v5.18

- Add new environment variables, USERCFLAGS and USERLDFLAGS to allow
    additional flags to be passed to user-space programs.
 
  - Fix missing fflush() bugs in Kconfig and fixdep
 
  - Fix a minor bug in the comment format of the .config file
 
  - Make kallsyms ignore llvm's local labels, .L*
 
  - Fix UAPI compile-test for cross-compiling with Clang
 
  - Extend the LLVM= syntax to support LLVM=<suffix> form for using a
    particular version of LLVm, and LLVM=<prefix> form for using custom
    LLVM in a particular directory path.
 
  - Clean up Makefiles
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmJFGloVHG1hc2FoaXJv
 eUBrZXJuZWwub3JnAAoJED2LAQed4NsGH0kP/j6Vx5BqEv3tP2Q+UANxLqITleJs
 IFpbSesz/BhlG7I/IapWmCDSqFbYd5uJTO4ko8CsPmZHcxr6Gw3y+DN5yQACKaG/
 p9xiF6GjPyKR8+VdcT2tV50+dVY8ANe/DxCyzKrJd/uyYxgARPKJh0KRMNz+d9lj
 ixUpCXDhx/XlKzPIlcxrvhhjevKz+NnHmN0fe6rzcOw9KzBGBTsf20Q3PqUuBOKa
 rWHsRGcBPA8eKLfWT1Us1jjic6cT2g4aMpWjF20YgUWKHgWVKcNHpxYKGXASVo/z
 ewdDnNfmwo7f7fKMCDDro9iwFWV/BumGtn43U00tnqdBcTpFojPlEOga37UPbZDF
 nmTblGVUhR0vn4PmfBy8WkAkbW+IpVatKwJGV4J3KjSvdWvZOmVj9VUGLVAR0TXW
 /YcgRs6EtG8Hn0IlCj0fvZ5wRWoDLbP2DSZ67R/44EP0GaNQPwUe4FI1izEE4EYX
 oVUAIxcKixWGj4RmdtmtMMdUcZzTpbgS9uloMUmS3u9LK0Ir/8tcWaf2zfMO6Jl2
 p4Q31s1dUUKCnFnj0xDKRyKGUkxYebrHLfuBqi0RIc0xRpSlxoXe3Dynm9aHEQoD
 ZSV0eouQJxnaxM1ck5Bu4AHLgEebHfEGjWVyUHno7jFU5EI9Wpbqpe4pCYEEDTm1
 +LJMEpdZO0dFvpF+
 =84rW
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-v5.18-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

 - Add new environment variables, USERCFLAGS and USERLDFLAGS to allow
   additional flags to be passed to user-space programs.

 - Fix missing fflush() bugs in Kconfig and fixdep

 - Fix a minor bug in the comment format of the .config file

 - Make kallsyms ignore llvm's local labels, .L*

 - Fix UAPI compile-test for cross-compiling with Clang

 - Extend the LLVM= syntax to support LLVM=<suffix> form for using a
   particular version of LLVm, and LLVM=<prefix> form for using custom
   LLVM in a particular directory path.

 - Clean up Makefiles

* tag 'kbuild-v5.18-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: Make $(LLVM) more flexible
  kbuild: add --target to correctly cross-compile UAPI headers with Clang
  fixdep: use fflush() and ferror() to ensure successful write to files
  arch: syscalls: simplify uapi/kapi directory creation
  usr/include: replace extra-y with always-y
  certs: simplify empty certs creation in certs/Makefile
  certs: include certs/signing_key.x509 unconditionally
  kallsyms: ignore all local labels prefixed by '.L'
  kconfig: fix missing '# end of' for empty menu
  kconfig: add fflush() before ferror() check
  kbuild: replace $(if A,A,B) with $(or A,B)
  kbuild: Add environment variables for userprogs flags
  kbuild: unify cmd_copy and cmd_shipped
This commit is contained in:
Linus Torvalds 2022-03-31 11:59:03 -07:00
commit b8321ed4a4
51 changed files with 189 additions and 175 deletions

View File

@ -77,6 +77,17 @@ HOSTLDLIBS
---------- ----------
Additional libraries to link against when building host programs. Additional libraries to link against when building host programs.
.. _userkbuildflags:
USERCFLAGS
----------
Additional options used for $(CC) when compiling userprogs.
USERLDFLAGS
-----------
Additional options used for $(LD) when linking userprogs. userprogs are linked
with CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable.
KBUILD_KCONFIG KBUILD_KCONFIG
-------------- --------------
Set the top-level Kconfig file to the value of this environment Set the top-level Kconfig file to the value of this environment

View File

@ -49,17 +49,36 @@ example: ::
LLVM Utilities LLVM Utilities
-------------- --------------
LLVM has substitutes for GNU binutils utilities. Kbuild supports ``LLVM=1`` LLVM has substitutes for GNU binutils utilities. They can be enabled individually.
to enable them. :: The full list of supported make variables::
make LLVM=1
They can be enabled individually. The full list of the parameters: ::
make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \ make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \
OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf \ OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf \
HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar HOSTLD=ld.lld HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar HOSTLD=ld.lld
To simplify the above command, Kbuild supports the ``LLVM`` variable::
make LLVM=1
If your LLVM tools are not available in your PATH, you can supply their
location using the LLVM variable with a trailing slash::
make LLVM=/path/to/llvm/
which will use ``/path/to/llvm/clang``, ``/path/to/llvm/ld.lld``, etc.
If your LLVM tools have a version suffix and you want to test with that
explicit version rather than the unsuffixed executables like ``LLVM=1``, you
can pass the suffix using the ``LLVM`` variable::
make LLVM=-14
which will use ``clang-14``, ``ld.lld-14``, etc.
``LLVM=0`` is not the same as omitting ``LLVM`` altogether, it will behave like
``LLVM=1``. If you only wish to use certain LLVM utilities, use their respective
make variables.
The integrated assembler is enabled by default. You can pass ``LLVM_IAS=0`` to The integrated assembler is enabled by default. You can pass ``LLVM_IAS=0`` to
disable it. disable it.

View File

@ -982,6 +982,8 @@ The syntax is quite similar. The difference is to use "userprogs" instead of
When linking bpfilter_umh, it will be passed the extra option -static. When linking bpfilter_umh, it will be passed the extra option -static.
From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used.
5.4 When userspace programs are actually built 5.4 When userspace programs are actually built
---------------------------------------------- ----------------------------------------------

View File

@ -424,19 +424,26 @@ HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
ifneq ($(LLVM),) ifneq ($(LLVM),)
HOSTCC = clang ifneq ($(filter %/,$(LLVM)),)
HOSTCXX = clang++ LLVM_PREFIX := $(LLVM)
else ifneq ($(filter -%,$(LLVM)),)
LLVM_SUFFIX := $(LLVM)
endif
HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
HOSTCXX = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX)
else else
HOSTCC = gcc HOSTCC = gcc
HOSTCXX = g++ HOSTCXX = g++
endif endif
export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-O2 -fomit-frame-pointer -std=gnu11 \ -O2 -fomit-frame-pointer -std=gnu11 \
-Wdeclaration-after-statement -Wdeclaration-after-statement
export KBUILD_USERLDFLAGS := KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
KBUILD_USERLDFLAGS := $(USERLDFLAGS)
KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
@ -444,14 +451,14 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
# Make variables (CC, etc...) # Make variables (CC, etc...)
CPP = $(CC) -E CPP = $(CC) -E
ifneq ($(LLVM),) ifneq ($(LLVM),)
CC = clang CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
LD = ld.lld LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
AR = llvm-ar AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
NM = llvm-nm NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
OBJCOPY = llvm-objcopy OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
OBJDUMP = llvm-objdump OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
READELF = llvm-readelf READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
STRIP = llvm-strip STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
else else
CC = $(CROSS_COMPILE)gcc CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld LD = $(CROSS_COMPILE)ld
@ -531,6 +538,7 @@ export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AW
export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
@ -1237,8 +1245,8 @@ define filechk_version.h
echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL) echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
endef endef
$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0) $(version_h): PATCHLEVEL := $(or $(PATCHLEVEL), 0)
$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0) $(version_h): SUBLEVEL := $(or $(SUBLEVEL), 0)
$(version_h): FORCE $(version_h): FORCE
$(call filechk,version.h) $(call filechk,version.h)
@ -1621,7 +1629,7 @@ help:
@$(MAKE) -f $(srctree)/Documentation/Makefile dochelp @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
@echo '' @echo ''
@echo 'Architecture specific targets ($(SRCARCH)):' @echo 'Architecture specific targets ($(SRCARCH)):'
@$(if $(archhelp),$(archhelp),\ @$(or $(archhelp),\
echo ' No architecture specific help defined for $(SRCARCH)') echo ' No architecture specific help defined for $(SRCARCH)')
@echo '' @echo ''
@$(if $(boards), \ @$(if $(boards), \
@ -1838,7 +1846,7 @@ $(clean-dirs):
clean: $(clean-dirs) clean: $(clean-dirs)
$(call cmd,rmfiles) $(call cmd,rmfiles)
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ @find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
\( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '*.ko.*' \ -o -name '*.ko.*' \
-o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -29,8 +29,7 @@ kapi: $(kapi-hdrs-y) $(gen-y)
uapi: $(uapi-hdrs-y) uapi: $(uapi-hdrs-y)
# Create output directory if not already present # Create output directory if not already present
_dummy := $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') \ $(shell mkdir -p $(kapi) $(uapi))
$(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)')
quiet_cmd_gen_mach = GEN $@ quiet_cmd_gen_mach = GEN $@
cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@ cmd_gen_mach = $(AWK) -f $(real-prereqs) > $@

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -29,7 +29,7 @@ $(obj)/simpleImage.$(DTB).ub: $(obj)/simpleImage.$(DTB) FORCE
$(call if_changed,uimage) $(call if_changed,uimage)
$(obj)/simpleImage.$(DTB).unstrip: vmlinux FORCE $(obj)/simpleImage.$(DTB).unstrip: vmlinux FORCE
$(call if_changed,shipped) $(call if_changed,copy)
$(obj)/simpleImage.$(DTB).strip: vmlinux FORCE $(obj)/simpleImage.$(DTB).strip: vmlinux FORCE
$(call if_changed,strip) $(call if_changed,strip)

View File

@ -12,7 +12,7 @@ $(obj)/linked_dtb.o: $(obj)/system.dtb
# Generate system.dtb from $(DTB).dtb # Generate system.dtb from $(DTB).dtb
ifneq ($(DTB),system) ifneq ($(DTB),system)
$(obj)/system.dtb: $(obj)/$(DTB).dtb $(obj)/system.dtb: $(obj)/$(DTB).dtb
$(call if_changed,shipped) $(call if_changed,copy)
endif endif
endif endif

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh
sysnr := $(srctree)/$(src)/syscallnr.sh sysnr := $(srctree)/$(src)/syscallnr.sh

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -21,8 +21,7 @@ uapi: $(uapi-hdrs-y)
# Create output directory if not already present # Create output directory if not already present
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
filechk_syshdr = $(CONFIG_SHELL) '$(systbl)' -H -a $(syshdr_abi_$(basetarget)) -f "$2" < $< filechk_syshdr = $(CONFIG_SHELL) '$(systbl)' -H -a $(syshdr_abi_$(basetarget)) -f "$2" < $<

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -3,8 +3,7 @@ out := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
# Create output directory if not already present # Create output directory if not already present
_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') \ $(shell mkdir -p $(out) $(uapi))
$(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)')
syscall32 := $(src)/syscall_32.tbl syscall32 := $(src)/syscall_32.tbl
syscall64 := $(src)/syscall_64.tbl syscall64 := $(src)/syscall_64.tbl

View File

@ -2,8 +2,7 @@
kapi := arch/$(SRCARCH)/include/generated/asm kapi := arch/$(SRCARCH)/include/generated/asm
uapi := arch/$(SRCARCH)/include/generated/uapi/asm uapi := arch/$(SRCARCH)/include/generated/uapi/asm
_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell mkdir -p $(uapi) $(kapi))
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(src)/syscall.tbl syscall := $(src)/syscall.tbl
syshdr := $(srctree)/scripts/syscallhdr.sh syshdr := $(srctree)/scripts/syscallhdr.sh

View File

@ -13,34 +13,20 @@ obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_nohashes.o
endif endif
quiet_cmd_extract_certs = CERT $@ quiet_cmd_extract_certs = CERT $@
cmd_extract_certs = $(obj)/extract-cert $(2) $@ cmd_extract_certs = $(obj)/extract-cert $(extract-cert-in) $@
extract-cert-in = $(or $(filter-out $(obj)/extract-cert, $(real-prereqs)),"")
$(obj)/system_certificates.o: $(obj)/x509_certificate_list $(obj)/system_certificates.o: $(obj)/x509_certificate_list
$(obj)/x509_certificate_list: $(CONFIG_SYSTEM_TRUSTED_KEYS) $(obj)/extract-cert FORCE $(obj)/x509_certificate_list: $(CONFIG_SYSTEM_TRUSTED_KEYS) $(obj)/extract-cert FORCE
$(call if_changed,extract_certs,$(if $(CONFIG_SYSTEM_TRUSTED_KEYS),$<,"")) $(call if_changed,extract_certs)
targets += x509_certificate_list targets += x509_certificate_list
ifeq ($(CONFIG_MODULE_SIG),y)
SIGN_KEY = y
endif
ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)
ifeq ($(CONFIG_MODULES),y)
SIGN_KEY = y
endif
endif
ifdef SIGN_KEY
###############################################################################
#
# If module signing is requested, say by allyesconfig, but a key has not been # If module signing is requested, say by allyesconfig, but a key has not been
# supplied, then one will need to be generated to make sure the build does not # supplied, then one will need to be generated to make sure the build does not
# fail and that the kernel may be used afterwards. # fail and that the kernel may be used afterwards.
# #
###############################################################################
# We do it this way rather than having a boolean option for enabling an # We do it this way rather than having a boolean option for enabling an
# external private key, because 'make randconfig' might enable such a # external private key, because 'make randconfig' might enable such a
# boolean option and we unfortunately can't make it depend on !RANDCONFIG. # boolean option and we unfortunately can't make it depend on !RANDCONFIG.
@ -67,23 +53,22 @@ $(obj)/x509.genkey:
endif # CONFIG_MODULE_SIG_KEY endif # CONFIG_MODULE_SIG_KEY
# If CONFIG_MODULE_SIG_KEY isn't a PKCS#11 URI, depend on it
ifneq ($(filter-out pkcs11:%, $(CONFIG_MODULE_SIG_KEY)),)
X509_DEP := $(CONFIG_MODULE_SIG_KEY)
endif
$(obj)/system_certificates.o: $(obj)/signing_key.x509 $(obj)/system_certificates.o: $(obj)/signing_key.x509
$(obj)/signing_key.x509: $(X509_DEP) $(obj)/extract-cert FORCE PKCS11_URI := $(filter pkcs11:%, $(CONFIG_MODULE_SIG_KEY))
$(call if_changed,extract_certs,$(if $(CONFIG_MODULE_SIG_KEY),$(if $(X509_DEP),$<,$(CONFIG_MODULE_SIG_KEY)),"")) ifdef PKCS11_URI
endif # CONFIG_MODULE_SIG $(obj)/signing_key.x509: extract-cert-in := $(PKCS11_URI)
endif
$(obj)/signing_key.x509: $(filter-out $(PKCS11_URI),$(CONFIG_MODULE_SIG_KEY)) $(obj)/extract-cert FORCE
$(call if_changed,extract_certs)
targets += signing_key.x509 targets += signing_key.x509
$(obj)/revocation_certificates.o: $(obj)/x509_revocation_list $(obj)/revocation_certificates.o: $(obj)/x509_revocation_list
$(obj)/x509_revocation_list: $(CONFIG_SYSTEM_REVOCATION_KEYS) $(obj)/extract-cert FORCE $(obj)/x509_revocation_list: $(CONFIG_SYSTEM_REVOCATION_KEYS) $(obj)/extract-cert FORCE
$(call if_changed,extract_certs,$(if $(CONFIG_SYSTEM_REVOCATION_KEYS),$<,"")) $(call if_changed,extract_certs)
targets += x509_revocation_list targets += x509_revocation_list

View File

@ -9,10 +9,7 @@
system_certificate_list: system_certificate_list:
__cert_list_start: __cert_list_start:
__module_cert_start: __module_cert_start:
#if defined(CONFIG_MODULE_SIG) || (defined(CONFIG_IMA_APPRAISE_MODSIG) \
&& defined(CONFIG_MODULES))
.incbin "certs/signing_key.x509" .incbin "certs/signing_key.x509"
#endif
__module_cert_end: __module_cert_end:
.incbin "certs/x509_certificate_list" .incbin "certs/x509_certificate_list"
__cert_list_end: __cert_list_end:

View File

@ -33,7 +33,7 @@ $(obj)/utf8data.c: $(obj)/mkutf8data $(filter %.txt, $(cmd_utf8data)) FORCE
else else
$(obj)/utf8data.c: $(src)/utf8data.c_shipped FORCE $(obj)/utf8data.c: $(src)/utf8data.c_shipped FORCE
$(call if_changed,shipped) $(call if_changed,copy)
endif endif

View File

@ -62,13 +62,13 @@ config LLD_VERSION
config CC_CAN_LINK config CC_CAN_LINK
bool bool
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m64-flag)) if 64BIT
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag)) default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m32-flag))
config CC_CAN_LINK_STATIC config CC_CAN_LINK_STATIC
bool bool
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag) -static) if 64BIT default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m64-flag) -static) if 64BIT
default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag) -static) default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m32-flag) -static)
config CC_HAS_ASM_GOTO config CC_HAS_ASM_GOTO
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))

View File

@ -40,8 +40,7 @@ include $(srctree)/scripts/Makefile.compiler
# The filename Kbuild has precedence over Makefile # The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
include $(kbuild-file)
include $(srctree)/scripts/Makefile.lib include $(srctree)/scripts/Makefile.lib

View File

@ -12,7 +12,7 @@ include $(srctree)/scripts/Kbuild.include
# The filename Kbuild has precedence over Makefile # The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
# Figure out what we need to build from the various variables # Figure out what we need to build from the various variables
# ========================================================================== # ==========================================================================

View File

@ -106,7 +106,7 @@ subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
modname-multi = $(sort $(foreach m,$(multi-obj-ym),\ modname-multi = $(sort $(foreach m,$(multi-obj-ym),\
$(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=)))) $(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=))))
__modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) __modname = $(or $(modname-multi),$(basetarget))
modname = $(subst $(space),:,$(__modname)) modname = $(subst $(space),:,$(__modname))
modfile = $(addprefix $(obj)/,$(__modname)) modfile = $(addprefix $(obj)/,$(__modname))
@ -241,20 +241,16 @@ $(foreach m, $(notdir $1), \
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
endef endef
quiet_cmd_copy = COPY $@ # Copy a file
cmd_copy = cp $< $@
# Shipped files
# =========================================================================== # ===========================================================================
# 'cp' preserves permissions. If you use it to copy a file in read-only srctree, # 'cp' preserves permissions. If you use it to copy a file in read-only srctree,
# the copy would be read-only as well, leading to an error when executing the # the copy would be read-only as well, leading to an error when executing the
# rule next time. Use 'cat' instead in order to generate a writable file. # rule next time. Use 'cat' instead in order to generate a writable file.
quiet_cmd_copy = COPY $@
quiet_cmd_shipped = SHIPPED $@ cmd_copy = cat $< > $@
cmd_shipped = cat $< > $@
$(obj)/%: $(src)/%_shipped $(obj)/%: $(src)/%_shipped
$(call cmd,shipped) $(call cmd,copy)
# Commands useful for building a boot image # Commands useful for building a boot image
# =========================================================================== # ===========================================================================
@ -431,7 +427,7 @@ MKIMAGE := $(srctree)/scripts/mkuboot.sh
# SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces # SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces
# the number of overrides in arch makefiles # the number of overrides in arch makefiles
UIMAGE_ARCH ?= $(SRCARCH) UIMAGE_ARCH ?= $(SRCARCH)
UIMAGE_COMPRESSION ?= $(if $(2),$(2),none) UIMAGE_COMPRESSION ?= $(or $(2),none)
UIMAGE_OPTS-y ?= UIMAGE_OPTS-y ?=
UIMAGE_TYPE ?= kernel UIMAGE_TYPE ?= kernel
UIMAGE_LOADADDR ?= arch_must_set_this UIMAGE_LOADADDR ?= arch_must_set_this

View File

@ -105,25 +105,6 @@ static void usage(void)
exit(1); exit(1);
} }
/*
* In the intended usage of this program, the stdout is redirected to .*.cmd
* files. The return value of printf() must be checked to catch any error,
* e.g. "No space left on device".
*/
static void xprintf(const char *format, ...)
{
va_list ap;
int ret;
va_start(ap, format);
ret = vprintf(format, ap);
if (ret < 0) {
perror("fixdep");
exit(1);
}
va_end(ap);
}
struct item { struct item {
struct item *next; struct item *next;
unsigned int len; unsigned int len;
@ -189,7 +170,7 @@ static void use_config(const char *m, int slen)
define_config(m, slen, hash); define_config(m, slen, hash);
/* Print out a dependency path from a symbol name. */ /* Print out a dependency path from a symbol name. */
xprintf(" $(wildcard include/config/%.*s) \\\n", slen, m); printf(" $(wildcard include/config/%.*s) \\\n", slen, m);
} }
/* test if s ends in sub */ /* test if s ends in sub */
@ -318,13 +299,13 @@ static void parse_dep_file(char *m, const char *target)
*/ */
if (!saw_any_target) { if (!saw_any_target) {
saw_any_target = 1; saw_any_target = 1;
xprintf("source_%s := %s\n\n", printf("source_%s := %s\n\n",
target, m); target, m);
xprintf("deps_%s := \\\n", target); printf("deps_%s := \\\n", target);
} }
is_first_dep = 0; is_first_dep = 0;
} else { } else {
xprintf(" %s \\\n", m); printf(" %s \\\n", m);
} }
buf = read_file(m); buf = read_file(m);
@ -347,8 +328,8 @@ static void parse_dep_file(char *m, const char *target)
exit(1); exit(1);
} }
xprintf("\n%s: $(deps_%s)\n\n", target, target); printf("\n%s: $(deps_%s)\n\n", target, target);
xprintf("$(deps_%s):\n", target); printf("$(deps_%s):\n", target);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -363,11 +344,22 @@ int main(int argc, char *argv[])
target = argv[2]; target = argv[2];
cmdline = argv[3]; cmdline = argv[3];
xprintf("cmd_%s := %s\n\n", target, cmdline); printf("cmd_%s := %s\n\n", target, cmdline);
buf = read_file(depfile); buf = read_file(depfile);
parse_dep_file(buf, target); parse_dep_file(buf, target);
free(buf); free(buf);
fflush(stdout);
/*
* In the intended usage, the stdout is redirected to .*.cmd files.
* Call ferror() to catch errors such as "No space left on device".
*/
if (ferror(stdout)) {
fprintf(stderr, "fixdep: not all data was written to the output\n");
exit(1);
}
return 0; return 0;
} }

View File

@ -108,7 +108,7 @@ static bool is_ignored_symbol(const char *name, char type)
/* Symbol names that begin with the following are ignored.*/ /* Symbol names that begin with the following are ignored.*/
static const char * const ignored_prefixes[] = { static const char * const ignored_prefixes[] = {
"$", /* local symbols for ARM, MIPS, etc. */ "$", /* local symbols for ARM, MIPS, etc. */
".LASANPC", /* s390 kasan local symbols */ ".L", /* local labels, .LBB,.Ltmpxxx,.L__unnamed_xx,.LASANPC, etc. */
"__crc_", /* modversions */ "__crc_", /* modversions */
"__efistub_", /* arm64 EFI stub namespace */ "__efistub_", /* arm64 EFI stub namespace */
"__kvm_nvhe_", /* arm64 non-VHE KVM namespace */ "__kvm_nvhe_", /* arm64 non-VHE KVM namespace */

View File

@ -903,19 +903,20 @@ int conf_write(const char *name)
menu = menu->list; menu = menu->list;
continue; continue;
} }
if (menu->next)
end_check:
if (!menu->sym && menu_is_visible(menu) && menu != &rootmenu &&
menu->prompt->type == P_MENU) {
fprintf(out, "# end of %s\n", menu_get_prompt(menu));
need_newline = true;
}
if (menu->next) {
menu = menu->next; menu = menu->next;
else while ((menu = menu->parent)) { } else {
if (!menu->sym && menu_is_visible(menu) && menu = menu->parent;
menu != &rootmenu) { if (menu)
str = menu_get_prompt(menu); goto end_check;
fprintf(out, "# end of %s\n", str);
need_newline = true;
}
if (menu->next) {
menu = menu->next;
break;
}
} }
} }
fclose(out); fclose(out);
@ -979,6 +980,7 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
fprintf(out, "\n$(deps_config): ;\n"); fprintf(out, "\n$(deps_config): ;\n");
fflush(out);
ret = ferror(out); /* error check for all fprintf() calls */ ret = ferror(out); /* error check for all fprintf() calls */
fclose(out); fclose(out);
if (ret) if (ret)
@ -1097,6 +1099,7 @@ static int __conf_write_autoconf(const char *filename,
if ((sym->flags & SYMBOL_WRITE) && sym->name) if ((sym->flags & SYMBOL_WRITE) && sym->name)
print_symbol(file, sym); print_symbol(file, sym);
fflush(file);
/* check possible errors in conf_write_heading() and print_symbol() */ /* check possible errors in conf_write_heading() and print_symbol() */
ret = ferror(file); ret = ferror(file);
fclose(file); fclose(file);

View File

@ -74,7 +74,7 @@ CFLAGS += -O2
CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS)) CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS))
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
-I$(if $(OUTPUT),$(OUTPUT),.) \ -I$(or $(OUTPUT),.) \
-I$(LIBBPF_INCLUDE) \ -I$(LIBBPF_INCLUDE) \
-I$(srctree)/kernel/bpf/ \ -I$(srctree)/kernel/bpf/ \
-I$(srctree)/tools/include \ -I$(srctree)/tools/include \
@ -180,7 +180,7 @@ endif
$(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP) $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP)
$(QUIET_CLANG)$(CLANG) \ $(QUIET_CLANG)$(CLANG) \
-I$(if $(OUTPUT),$(OUTPUT),.) \ -I$(or $(OUTPUT),.) \
-I$(srctree)/tools/include/uapi/ \ -I$(srctree)/tools/include/uapi/ \
-I$(LIBBPF_BOOTSTRAP_INCLUDE) \ -I$(LIBBPF_BOOTSTRAP_INCLUDE) \
-g -O2 -Wall -target bpf -c $< -o $@ -g -O2 -Wall -target bpf -c $< -o $@

View File

@ -36,7 +36,7 @@ TMP_O := $(if $(OUTPUT),$(OUTPUT)feature/,./)
clean: clean:
$(call QUIET_CLEAN, fixdep) $(call QUIET_CLEAN, fixdep)
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)rm -f $(OUTPUT)fixdep $(Q)rm -f $(OUTPUT)fixdep
$(call QUIET_CLEAN, feature-detect) $(call QUIET_CLEAN, feature-detect)
ifneq ($(wildcard $(TMP_O)),) ifneq ($(wildcard $(TMP_O)),)

View File

@ -40,7 +40,7 @@ $(OUTPUT)counter_example: $(COUNTER_EXAMPLE)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/linux/counter.h rm -rf $(OUTPUT)include/linux/counter.h
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -78,7 +78,7 @@ $(OUTPUT)gpio-watch: $(GPIO_WATCH_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
rm -f $(OUTPUT)include/linux/gpio.h rm -f $(OUTPUT)include/linux/gpio.h
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -47,7 +47,7 @@ $(OUTPUT)hv_fcopy_daemon: $(HV_FCOPY_DAEMON_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(sbindir); \ install -d -m 755 $(DESTDIR)$(sbindir); \

View File

@ -58,7 +58,7 @@ $(OUTPUT)iio_generic_buffer: $(IIO_GENERIC_BUFFER_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/linux/iio rm -rf $(OUTPUT)include/linux/iio
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -60,7 +60,7 @@ $(LIBFILE): $(API_IN)
clean: clean:
$(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \ $(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
FORCE: FORCE:

View File

@ -60,7 +60,7 @@ ifndef VERBOSE
VERBOSE = 0 VERBOSE = 0
endif endif
INCLUDES = -I$(if $(OUTPUT),$(OUTPUT),.) \ INCLUDES = -I$(or $(OUTPUT),.) \
-I$(srctree)/tools/include -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/include/uapi
export prefix libdir src obj export prefix libdir src obj

View File

@ -153,7 +153,7 @@ $(TESTS_STATIC): $(TESTS_IN) $(LIBPERF_A) $(LIBAPI)
$(QUIET_LINK)$(CC) -o $@ $^ $(QUIET_LINK)$(CC) -o $@ $^
$(TESTS_SHARED): $(TESTS_IN) $(LIBAPI) $(TESTS_SHARED): $(TESTS_IN) $(LIBAPI)
$(QUIET_LINK)$(CC) -o $@ -L$(if $(OUTPUT),$(OUTPUT),.) $^ -lperf $(QUIET_LINK)$(CC) -o $@ -L$(or $(OUTPUT),.) $^ -lperf
make-tests: libs $(TESTS_SHARED) $(TESTS_STATIC) make-tests: libs $(TESTS_SHARED) $(TESTS_STATIC)

View File

@ -63,7 +63,7 @@ $(LIBFILE): $(SUBCMD_IN)
clean: clean:
$(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \ $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
FORCE: FORCE:

View File

@ -13,7 +13,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
endif endif
SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/
LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/) LIBSUBCMD_OUTPUT = $(or $(OUTPUT),$(CURDIR)/)
LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a
OBJTOOL := $(OUTPUT)objtool OBJTOOL := $(OUTPUT)objtool

View File

@ -42,7 +42,7 @@ $(OUTPUT)pcitest: $(PCITEST_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/ rm -rf $(OUTPUT)include/
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -724,7 +724,7 @@ endif
# get relative building directory (to $(OUTPUT)) # get relative building directory (to $(OUTPUT))
# and '.' if it's $(OUTPUT) itself # and '.' if it's $(OUTPUT) itself
__build-dir = $(subst $(OUTPUT),,$(dir $@)) __build-dir = $(subst $(OUTPUT),,$(dir $@))
build-dir = $(if $(__build-dir),$(__build-dir),.) build-dir = $(or $(__build-dir),.)
prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
$(fadvise_advice_array) \ $(fadvise_advice_array) \
@ -1090,7 +1090,7 @@ bpf-skel-clean:
clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS)
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detected $(Q)$(RM) $(OUTPUT).config-detected
$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
$(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \ $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \

View File

@ -47,7 +47,7 @@ $(OUTPUT)intel-speed-select: $(ISST_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/linux/isst_if.h rm -rf $(OUTPUT)include/linux/isst_if.h
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -52,11 +52,17 @@ define allow-override
endef endef
ifneq ($(LLVM),) ifneq ($(LLVM),)
$(call allow-override,CC,clang) ifneq ($(filter %/,$(LLVM)),)
$(call allow-override,AR,llvm-ar) LLVM_PREFIX := $(LLVM)
$(call allow-override,LD,ld.lld) else ifneq ($(filter -%,$(LLVM)),)
$(call allow-override,CXX,clang++) LLVM_SUFFIX := $(LLVM)
$(call allow-override,STRIP,llvm-strip) endif
$(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
$(call allow-override,AR,$(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX))
$(call allow-override,LD,$(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX))
$(call allow-override,CXX,$(LLVM_PREFIX)clang++$(LLVM_SUFFIX))
$(call allow-override,STRIP,$(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX))
else else
# Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix. # Allow setting various cross-compile vars or setting CROSS_COMPILE as a prefix.
$(call allow-override,CC,$(CROSS_COMPILE)gcc) $(call allow-override,CC,$(CROSS_COMPILE)gcc)
@ -69,9 +75,9 @@ endif
CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
ifneq ($(LLVM),) ifneq ($(LLVM),)
HOSTAR ?= llvm-ar HOSTAR ?= $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
HOSTCC ?= clang HOSTCC ?= $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
HOSTLD ?= ld.lld HOSTLD ?= $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
else else
HOSTAR ?= ar HOSTAR ?= ar
HOSTCC ?= gcc HOSTCC ?= gcc

View File

@ -175,5 +175,5 @@ _ge-abspath = $(if $(is-executable),$(1))
define get-executable-or-default define get-executable-or-default
$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2))) $(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2)))
endef endef
_ge_attempt = $(if $(get-executable),$(get-executable),$(call _gea_err,$(2))) _ge_attempt = $(or $(get-executable),$(call _gea_err,$(2)))
_gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) _gea_err = $(if $(1),$(error Please set '$(1)' appropriately))

View File

@ -53,9 +53,9 @@ $(OUTPUT)spidev_fdx: $(SPIDEV_FDX_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/ rm -rf $(OUTPUT)include/
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete find $(or $(OUTPUT),.) -name '*.o' -delete
find $(if $(OUTPUT),$(OUTPUT),.) -name '\.*.o.d' -delete find $(or $(OUTPUT),.) -name '\.*.o.d' -delete
find $(if $(OUTPUT),$(OUTPUT),.) -name '\.*.o.cmd' -delete find $(or $(OUTPUT),.) -name '\.*.o.cmd' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -1,7 +1,13 @@
# This mimics the top-level Makefile. We do it explicitly here so that this # This mimics the top-level Makefile. We do it explicitly here so that this
# Makefile can operate with or without the kbuild infrastructure. # Makefile can operate with or without the kbuild infrastructure.
ifneq ($(LLVM),) ifneq ($(LLVM),)
CC := clang ifneq ($(filter %/,$(LLVM)),)
LLVM_PREFIX := $(LLVM)
else ifneq ($(filter -%,$(LLVM)),)
LLVM_SUFFIX := $(LLVM)
endif
CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
else else
CC := $(CROSS_COMPILE)gcc CC := $(CROSS_COMPILE)gcc
endif endif

View File

@ -46,7 +46,7 @@ DATADIR := /usr/share
DOCDIR := $(DATADIR)/doc DOCDIR := $(DATADIR)/doc
MANDIR := $(DATADIR)/man MANDIR := $(DATADIR)/man
LICDIR := $(DATADIR)/licenses LICDIR := $(DATADIR)/licenses
SRCTREE := $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR)) SRCTREE := $(or $(BUILD_SRC),$(CURDIR))
# If running from the tarball, man pages are stored in the Documentation # If running from the tarball, man pages are stored in the Documentation
# dir. If running from the kernel source, man pages are stored in # dir. If running from the kernel source, man pages are stored in

View File

@ -38,7 +38,7 @@ $(OUTPUT)ffs-test: $(FFS_TEST_IN)
clean: clean:
rm -f $(ALL_PROGRAMS) rm -f $(ALL_PROGRAMS)
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
install: $(ALL_PROGRAMS) install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \ install -d -m 755 $(DESTDIR)$(bindir); \

View File

@ -3,7 +3,7 @@
# kbuild file for usr/ - including initramfs image # kbuild file for usr/ - including initramfs image
# #
compress-y := shipped compress-y := copy
compress-$(CONFIG_INITRAMFS_COMPRESSION_GZIP) := gzip compress-$(CONFIG_INITRAMFS_COMPRESSION_GZIP) := gzip
compress-$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) := bzip2 compress-$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) := bzip2
compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma
@ -37,7 +37,7 @@ endif
# .cpio.*, use it directly as an initramfs, and avoid double compression. # .cpio.*, use it directly as an initramfs, and avoid double compression.
ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2) ifeq ($(words $(subst .cpio.,$(space),$(ramfs-input))),2)
cpio-data := $(ramfs-input) cpio-data := $(ramfs-input)
compress-y := shipped compress-y := copy
endif endif
endif endif

View File

@ -10,7 +10,10 @@ UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration
# In theory, we do not care -m32 or -m64 for header compile tests. # In theory, we do not care -m32 or -m64 for header compile tests.
# It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64. # It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64.
UAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS)) UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
# USERCFLAGS might contain sysroot location for CC.
UAPI_CFLAGS += $(USERCFLAGS)
override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
@ -84,7 +87,7 @@ endif
# asm-generic/*.h is used by asm/*.h, and should not be included directly # asm-generic/*.h is used by asm/*.h, and should not be included directly
no-header-test += asm-generic/% no-header-test += asm-generic/%
extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
# Include the header twice to detect missing include guard. # Include the header twice to detect missing include guard.
quiet_cmd_hdrtest = HDRTEST $< quiet_cmd_hdrtest = HDRTEST $<