xref: /linux/kernel/Makefile (revision 93d90ad708b8da6efc0e487b66111aa9db7f70c7)
1#
2# Makefile for the linux kernel.
3#
4
5obj-y     = fork.o exec_domain.o panic.o \
6	    cpu.o exit.o softirq.o resource.o \
7	    sysctl.o sysctl_binary.o capability.o ptrace.o user.o \
8	    signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
9	    extable.o params.o \
10	    kthread.o sys_ni.o nsproxy.o \
11	    notifier.o ksysfs.o cred.o reboot.o \
12	    async.o range.o groups.o smpboot.o
13
14ifdef CONFIG_FUNCTION_TRACER
15# Do not trace debug files and internal ftrace files
16CFLAGS_REMOVE_cgroup-debug.o = -pg
17CFLAGS_REMOVE_irq_work.o = -pg
18endif
19
20# cond_syscall is currently not LTO compatible
21CFLAGS_sys_ni.o = $(DISABLE_LTO)
22
23obj-y += sched/
24obj-y += locking/
25obj-y += power/
26obj-y += printk/
27obj-y += irq/
28obj-y += rcu/
29
30obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
31obj-$(CONFIG_FREEZER) += freezer.o
32obj-$(CONFIG_PROFILING) += profile.o
33obj-$(CONFIG_STACKTRACE) += stacktrace.o
34obj-y += time/
35obj-$(CONFIG_FUTEX) += futex.o
36ifeq ($(CONFIG_COMPAT),y)
37obj-$(CONFIG_FUTEX) += futex_compat.o
38endif
39obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
40obj-$(CONFIG_SMP) += smp.o
41ifneq ($(CONFIG_SMP),y)
42obj-y += up.o
43endif
44obj-$(CONFIG_UID16) += uid16.o
45obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o
46obj-$(CONFIG_MODULES) += module.o
47obj-$(CONFIG_MODULE_SIG) += module_signing.o
48obj-$(CONFIG_KALLSYMS) += kallsyms.o
49obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
50obj-$(CONFIG_KEXEC) += kexec.o
51obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
52obj-$(CONFIG_COMPAT) += compat.o
53obj-$(CONFIG_CGROUPS) += cgroup.o
54obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
55obj-$(CONFIG_CPUSETS) += cpuset.o
56obj-$(CONFIG_UTS_NS) += utsname.o
57obj-$(CONFIG_USER_NS) += user_namespace.o
58obj-$(CONFIG_PID_NS) += pid_namespace.o
59obj-$(CONFIG_IKCONFIG) += configs.o
60obj-$(CONFIG_SMP) += stop_machine.o
61obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
62obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
63obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
64obj-$(CONFIG_AUDIT_WATCH) += audit_watch.o
65obj-$(CONFIG_AUDIT_TREE) += audit_tree.o
66obj-$(CONFIG_GCOV_KERNEL) += gcov/
67obj-$(CONFIG_KPROBES) += kprobes.o
68obj-$(CONFIG_KGDB) += debug/
69obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o
70obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o
71obj-$(CONFIG_SECCOMP) += seccomp.o
72obj-$(CONFIG_RELAY) += relay.o
73obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
74obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
75obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
76obj-$(CONFIG_TRACEPOINTS) += tracepoint.o
77obj-$(CONFIG_LATENCYTOP) += latencytop.o
78obj-$(CONFIG_BINFMT_ELF) += elfcore.o
79obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o
80obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o
81obj-$(CONFIG_FUNCTION_TRACER) += trace/
82obj-$(CONFIG_TRACING) += trace/
83obj-$(CONFIG_TRACE_CLOCK) += trace/
84obj-$(CONFIG_RING_BUFFER) += trace/
85obj-$(CONFIG_TRACEPOINTS) += trace/
86obj-$(CONFIG_IRQ_WORK) += irq_work.o
87obj-$(CONFIG_CPU_PM) += cpu_pm.o
88obj-$(CONFIG_BPF) += bpf/
89
90obj-$(CONFIG_PERF_EVENTS) += events/
91
92obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
93obj-$(CONFIG_PADATA) += padata.o
94obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
95obj-$(CONFIG_JUMP_LABEL) += jump_label.o
96obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o
97obj-$(CONFIG_TORTURE_TEST) += torture.o
98
99$(obj)/configs.o: $(obj)/config_data.h
100
101# config_data.h contains the same information as ikconfig.h but gzipped.
102# Info from config_data can be extracted from /proc/config*
103targets += config_data.gz
104$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
105	$(call if_changed,gzip)
106
107      filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")
108targets += config_data.h
109$(obj)/config_data.h: $(obj)/config_data.gz FORCE
110	$(call filechk,ikconfiggz)
111
112###############################################################################
113#
114# Roll all the X.509 certificates that we can find together and pull them into
115# the kernel so that they get loaded into the system trusted keyring during
116# boot.
117#
118# We look in the source root and the build root for all files whose name ends
119# in ".x509".  Unfortunately, this will generate duplicate filenames, so we
120# have make canonicalise the pathnames and then sort them to discard the
121# duplicates.
122#
123###############################################################################
124ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y)
125X509_CERTIFICATES-y := $(wildcard *.x509) $(wildcard $(srctree)/*.x509)
126X509_CERTIFICATES-$(CONFIG_MODULE_SIG) += $(objtree)/signing_key.x509
127X509_CERTIFICATES-raw := $(sort $(foreach CERT,$(X509_CERTIFICATES-y), \
128				$(or $(realpath $(CERT)),$(CERT))))
129X509_CERTIFICATES := $(subst $(realpath $(objtree))/,,$(X509_CERTIFICATES-raw))
130
131ifeq ($(X509_CERTIFICATES),)
132$(warning *** No X.509 certificates found ***)
133endif
134
135ifneq ($(wildcard $(obj)/.x509.list),)
136ifneq ($(shell cat $(obj)/.x509.list),$(X509_CERTIFICATES))
137$(info X.509 certificate list changed)
138$(shell rm $(obj)/.x509.list)
139endif
140endif
141
142kernel/system_certificates.o: $(obj)/x509_certificate_list
143
144quiet_cmd_x509certs  = CERTS   $@
145      cmd_x509certs  = cat $(X509_CERTIFICATES) /dev/null >$@ $(foreach X509,$(X509_CERTIFICATES),; echo "  - Including cert $(X509)")
146
147targets += $(obj)/x509_certificate_list
148$(obj)/x509_certificate_list: $(X509_CERTIFICATES) $(obj)/.x509.list
149	$(call if_changed,x509certs)
150
151targets += $(obj)/.x509.list
152$(obj)/.x509.list:
153	@echo $(X509_CERTIFICATES) >$@
154endif
155
156clean-files := x509_certificate_list .x509.list
157
158ifeq ($(CONFIG_MODULE_SIG),y)
159###############################################################################
160#
161# If module signing is requested, say by allyesconfig, but a key has not been
162# supplied, then one will need to be generated to make sure the build does not
163# fail and that the kernel may be used afterwards.
164#
165###############################################################################
166ifndef CONFIG_MODULE_SIG_HASH
167$(error Could not determine digest type to use from kernel config)
168endif
169
170signing_key.priv signing_key.x509: x509.genkey
171	@echo "###"
172	@echo "### Now generating an X.509 key pair to be used for signing modules."
173	@echo "###"
174	@echo "### If this takes a long time, you might wish to run rngd in the"
175	@echo "### background to keep the supply of entropy topped up.  It"
176	@echo "### needs to be run as root, and uses a hardware random"
177	@echo "### number generator if one is available."
178	@echo "###"
179	openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
180		-batch -x509 -config x509.genkey \
181		-outform DER -out signing_key.x509 \
182		-keyout signing_key.priv 2>&1
183	@echo "###"
184	@echo "### Key pair generated."
185	@echo "###"
186
187x509.genkey:
188	@echo Generating X.509 key generation config
189	@echo  >x509.genkey "[ req ]"
190	@echo >>x509.genkey "default_bits = 4096"
191	@echo >>x509.genkey "distinguished_name = req_distinguished_name"
192	@echo >>x509.genkey "prompt = no"
193	@echo >>x509.genkey "string_mask = utf8only"
194	@echo >>x509.genkey "x509_extensions = myexts"
195	@echo >>x509.genkey
196	@echo >>x509.genkey "[ req_distinguished_name ]"
197	@echo >>x509.genkey "O = Magrathea"
198	@echo >>x509.genkey "CN = Glacier signing key"
199	@echo >>x509.genkey "emailAddress = slartibartfast@magrathea.h2g2"
200	@echo >>x509.genkey
201	@echo >>x509.genkey "[ myexts ]"
202	@echo >>x509.genkey "basicConstraints=critical,CA:FALSE"
203	@echo >>x509.genkey "keyUsage=digitalSignature"
204	@echo >>x509.genkey "subjectKeyIdentifier=hash"
205	@echo >>x509.genkey "authorityKeyIdentifier=keyid"
206endif
207