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