Makefile 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. #
  2. # Makefile for the linux kernel.
  3. #
  4. obj-y = fork.o exec_domain.o panic.o \
  5. cpu.o exit.o softirq.o resource.o \
  6. sysctl.o sysctl_binary.o capability.o ptrace.o user.o \
  7. signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
  8. extable.o params.o \
  9. kthread.o sys_ni.o nsproxy.o \
  10. notifier.o ksysfs.o cred.o reboot.o \
  11. async.o range.o smpboot.o
  12. obj-$(CONFIG_MULTIUSER) += groups.o
  13. ifdef CONFIG_FUNCTION_TRACER
  14. # Do not trace debug files and internal ftrace files
  15. CFLAGS_REMOVE_cgroup-debug.o = $(CC_FLAGS_FTRACE)
  16. CFLAGS_REMOVE_irq_work.o = $(CC_FLAGS_FTRACE)
  17. endif
  18. # cond_syscall is currently not LTO compatible
  19. CFLAGS_sys_ni.o = $(DISABLE_LTO)
  20. obj-y += sched/
  21. obj-y += locking/
  22. obj-y += power/
  23. obj-y += printk/
  24. obj-y += irq/
  25. obj-y += rcu/
  26. obj-y += livepatch/
  27. obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
  28. obj-$(CONFIG_FREEZER) += freezer.o
  29. obj-$(CONFIG_PROFILING) += profile.o
  30. obj-$(CONFIG_STACKTRACE) += stacktrace.o
  31. obj-y += time/
  32. obj-$(CONFIG_FUTEX) += futex.o
  33. ifeq ($(CONFIG_COMPAT),y)
  34. obj-$(CONFIG_FUTEX) += futex_compat.o
  35. endif
  36. obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
  37. obj-$(CONFIG_SMP) += smp.o
  38. ifneq ($(CONFIG_SMP),y)
  39. obj-y += up.o
  40. endif
  41. obj-$(CONFIG_UID16) += uid16.o
  42. obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o
  43. obj-$(CONFIG_MODULES) += module.o
  44. obj-$(CONFIG_MODULE_SIG) += module_signing.o
  45. obj-$(CONFIG_KALLSYMS) += kallsyms.o
  46. obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
  47. obj-$(CONFIG_KEXEC) += kexec.o
  48. obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
  49. obj-$(CONFIG_COMPAT) += compat.o
  50. obj-$(CONFIG_CGROUPS) += cgroup.o
  51. obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
  52. obj-$(CONFIG_CPUSETS) += cpuset.o
  53. obj-$(CONFIG_UTS_NS) += utsname.o
  54. obj-$(CONFIG_USER_NS) += user_namespace.o
  55. obj-$(CONFIG_PID_NS) += pid_namespace.o
  56. obj-$(CONFIG_IKCONFIG) += configs.o
  57. obj-$(CONFIG_SMP) += stop_machine.o
  58. obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
  59. obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
  60. obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
  61. obj-$(CONFIG_AUDIT_WATCH) += audit_watch.o
  62. obj-$(CONFIG_AUDIT_TREE) += audit_tree.o
  63. obj-$(CONFIG_GCOV_KERNEL) += gcov/
  64. obj-$(CONFIG_KPROBES) += kprobes.o
  65. obj-$(CONFIG_KGDB) += debug/
  66. obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o
  67. obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o
  68. obj-$(CONFIG_SECCOMP) += seccomp.o
  69. obj-$(CONFIG_RELAY) += relay.o
  70. obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
  71. obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
  72. obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
  73. obj-$(CONFIG_TRACEPOINTS) += tracepoint.o
  74. obj-$(CONFIG_LATENCYTOP) += latencytop.o
  75. obj-$(CONFIG_BINFMT_ELF) += elfcore.o
  76. obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o
  77. obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o
  78. obj-$(CONFIG_FUNCTION_TRACER) += trace/
  79. obj-$(CONFIG_TRACING) += trace/
  80. obj-$(CONFIG_TRACE_CLOCK) += trace/
  81. obj-$(CONFIG_RING_BUFFER) += trace/
  82. obj-$(CONFIG_TRACEPOINTS) += trace/
  83. obj-$(CONFIG_IRQ_WORK) += irq_work.o
  84. obj-$(CONFIG_CPU_PM) += cpu_pm.o
  85. obj-$(CONFIG_BPF) += bpf/
  86. obj-$(CONFIG_PERF_EVENTS) += events/
  87. obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
  88. obj-$(CONFIG_PADATA) += padata.o
  89. obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
  90. obj-$(CONFIG_JUMP_LABEL) += jump_label.o
  91. obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o
  92. obj-$(CONFIG_TORTURE_TEST) += torture.o
  93. $(obj)/configs.o: $(obj)/config_data.h
  94. # config_data.h contains the same information as ikconfig.h but gzipped.
  95. # Info from config_data can be extracted from /proc/config*
  96. targets += config_data.gz
  97. $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
  98. $(call if_changed,gzip)
  99. filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")
  100. targets += config_data.h
  101. $(obj)/config_data.h: $(obj)/config_data.gz FORCE
  102. $(call filechk,ikconfiggz)
  103. ###############################################################################
  104. #
  105. # When a Kconfig string contains a filename, it is suitable for
  106. # passing to shell commands. It is surrounded by double-quotes, and
  107. # any double-quotes or backslashes within it are escaped by
  108. # backslashes.
  109. #
  110. # This is no use for dependencies or $(wildcard). We need to strip the
  111. # surrounding quotes and the escaping from quotes and backslashes, and
  112. # we *do* need to escape any spaces in the string. So, for example:
  113. #
  114. # Usage: $(eval $(call config_filename,FOO))
  115. #
  116. # Defines FOO_FILENAME based on the contents of the CONFIG_FOO option,
  117. # transformed as described above to be suitable for use within the
  118. # makefile.
  119. #
  120. # Also, if the filename is a relative filename and exists in the source
  121. # tree but not the build tree, define FOO_SRCPREFIX as $(srctree)/ to
  122. # be prefixed to *both* command invocation and dependencies.
  123. #
  124. # Note: We also print the filenames in the quiet_cmd_foo text, and
  125. # perhaps ought to have a version specially escaped for that purpose.
  126. # But it's only cosmetic, and $(patsubst "%",%,$(CONFIG_FOO)) is good
  127. # enough. It'll strip the quotes in the common case where there's no
  128. # space and it's a simple filename, and it'll retain the quotes when
  129. # there's a space. There are some esoteric cases in which it'll print
  130. # the wrong thing, but we don't really care. The actual dependencies
  131. # and commands *do* get it right, with various combinations of single
  132. # and double quotes, backslashes and spaces in the filenames.
  133. #
  134. ###############################################################################
  135. #
  136. quote := $(firstword " ")
  137. space :=
  138. space +=
  139. space_escape := %%%SPACE%%%
  140. #
  141. define config_filename
  142. ifneq ($$(CONFIG_$(1)),"")
  143. $(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1)))))))
  144. ifneq ($$(patsubst /%,%,$$(firstword $$($(1)_FILENAME))),$$(firstword $$($(1)_FILENAME)))
  145. else
  146. ifeq ($$(wildcard $$($(1)_FILENAME)),)
  147. ifneq ($$(wildcard $$(srctree)/$$($(1)_FILENAME)),)
  148. $(1)_SRCPREFIX := $(srctree)/
  149. endif
  150. endif
  151. endif
  152. endif
  153. endef
  154. #
  155. ###############################################################################
  156. ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y)
  157. $(eval $(call config_filename,SYSTEM_TRUSTED_KEYS))
  158. # GCC doesn't include .incbin files in -MD generated dependencies (PR#66871)
  159. $(obj)/system_certificates.o: $(obj)/x509_certificate_list
  160. # Cope with signing_key.x509 existing in $(srctree) not $(objtree)
  161. AFLAGS_system_certificates.o := -I$(srctree)
  162. quiet_cmd_extract_certs = EXTRACT_CERTS $(patsubst "%",%,$(2))
  163. cmd_extract_certs = scripts/extract-cert $(2) $@ || ( rm $@; exit 1)
  164. targets += x509_certificate_list
  165. $(obj)/x509_certificate_list: scripts/extract-cert $(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(SYSTEM_TRUSTED_KEYS_FILENAME) FORCE
  166. $(call if_changed,extract_certs,$(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_TRUSTED_KEYS))
  167. endif
  168. clean-files := x509_certificate_list .x509.list
  169. ifeq ($(CONFIG_MODULE_SIG),y)
  170. ###############################################################################
  171. #
  172. # If module signing is requested, say by allyesconfig, but a key has not been
  173. # supplied, then one will need to be generated to make sure the build does not
  174. # fail and that the kernel may be used afterwards.
  175. #
  176. ###############################################################################
  177. ifndef CONFIG_MODULE_SIG_HASH
  178. $(error Could not determine digest type to use from kernel config)
  179. endif
  180. # We do it this way rather than having a boolean option for enabling an
  181. # external private key, because 'make randconfig' might enable such a
  182. # boolean option and we unfortunately can't make it depend on !RANDCONFIG.
  183. ifeq ($(CONFIG_MODULE_SIG_KEY),"signing_key.pem")
  184. signing_key.pem: x509.genkey
  185. @echo "###"
  186. @echo "### Now generating an X.509 key pair to be used for signing modules."
  187. @echo "###"
  188. @echo "### If this takes a long time, you might wish to run rngd in the"
  189. @echo "### background to keep the supply of entropy topped up. It"
  190. @echo "### needs to be run as root, and uses a hardware random"
  191. @echo "### number generator if one is available."
  192. @echo "###"
  193. openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
  194. -batch -x509 -config x509.genkey \
  195. -outform PEM -out signing_key.pem \
  196. -keyout signing_key.pem 2>&1
  197. @echo "###"
  198. @echo "### Key pair generated."
  199. @echo "###"
  200. x509.genkey:
  201. @echo Generating X.509 key generation config
  202. @echo >x509.genkey "[ req ]"
  203. @echo >>x509.genkey "default_bits = 4096"
  204. @echo >>x509.genkey "distinguished_name = req_distinguished_name"
  205. @echo >>x509.genkey "prompt = no"
  206. @echo >>x509.genkey "string_mask = utf8only"
  207. @echo >>x509.genkey "x509_extensions = myexts"
  208. @echo >>x509.genkey
  209. @echo >>x509.genkey "[ req_distinguished_name ]"
  210. @echo >>x509.genkey "#O = Unspecified company"
  211. @echo >>x509.genkey "CN = Build time autogenerated kernel key"
  212. @echo >>x509.genkey "#emailAddress = unspecified.user@unspecified.company"
  213. @echo >>x509.genkey
  214. @echo >>x509.genkey "[ myexts ]"
  215. @echo >>x509.genkey "basicConstraints=critical,CA:FALSE"
  216. @echo >>x509.genkey "keyUsage=digitalSignature"
  217. @echo >>x509.genkey "subjectKeyIdentifier=hash"
  218. @echo >>x509.genkey "authorityKeyIdentifier=keyid"
  219. endif
  220. $(eval $(call config_filename,MODULE_SIG_KEY))
  221. # If CONFIG_MODULE_SIG_KEY isn't a PKCS#11 URI, depend on it
  222. ifeq ($(patsubst pkcs11:%,%,$(firstword $(MODULE_SIG_KEY_FILENAME))),$(firstword $(MODULE_SIG_KEY_FILENAME)))
  223. X509_DEP := $(MODULE_SIG_KEY_SRCPREFIX)$(MODULE_SIG_KEY_FILENAME)
  224. endif
  225. # GCC PR#66871 again.
  226. $(obj)/system_certificates.o: signing_key.x509
  227. signing_key.x509: scripts/extract-cert include/config/module/sig/key.h $(X509_DEP)
  228. $(call cmd,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY))
  229. endif