blob: f2a8b6246ce935e9d4ae5aeddc314e3d281c8539 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#
2# Makefile for the linux kernel.
3#
4
Joe Perchesb9ee9792013-07-31 13:53:42 -07005obj-y = fork.o exec_domain.o panic.o \
Max Krasnyansky68f4f1e2008-05-29 11:17:02 -07006 cpu.o exit.o itimer.o time.o softirq.o resource.o \
Eric W. Biedermanafa588b2009-04-02 23:44:59 -07007 sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
Oleg Nesterove73f8952012-05-11 10:59:07 +10008 signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
Paul E. McKenney4102ada2013-10-08 20:23:47 -07009 extable.o params.o posix-timers.o \
Peter Zijlstra01768b42013-10-31 18:11:53 +010010 kthread.o sys_ni.o posix-cpu-timers.o \
Peter Zijlstraed428bf2013-10-31 18:19:28 +010011 hrtimer.o nsproxy.o \
Robin Holt15d94b82013-07-08 16:01:32 -070012 notifier.o ksysfs.o cred.o reboot.o \
Peter Zijlstracd4d2412013-11-04 11:51:33 +010013 async.o range.o groups.o smpboot.o
Peter Zijlstra029632f2011-10-25 10:00:11 +020014
Steven Rostedt606576c2008-10-06 19:06:12 -040015ifdef CONFIG_FUNCTION_TRACER
Steven Rostedt6ec56232008-05-14 21:30:30 -040016# Do not trace debug files and internal ftrace files
Steven Rostedt6ec56232008-05-14 21:30:30 -040017CFLAGS_REMOVE_cgroup-debug.o = -pg
Peter Zijlstrae360adb2010-10-14 14:01:34 +080018CFLAGS_REMOVE_irq_work.o = -pg
Steven Rostedt1d09daa2008-05-12 21:20:55 +020019endif
20
Andi Kleen58edae32014-02-08 09:01:10 +010021# cond_syscall is currently not LTO compatible
22CFLAGS_sys_ni.o = $(DISABLE_LTO)
23
Peter Zijlstra391e43d2011-11-15 17:14:39 +010024obj-y += sched/
Peter Zijlstra01768b42013-10-31 18:11:53 +010025obj-y += locking/
Rafael J. Wysockidae5cbc2012-01-14 00:33:03 +010026obj-y += power/
Joe Perchesb9ee9792013-07-31 13:53:42 -070027obj-y += printk/
Martin Schwidefsky0244ad02013-08-30 09:39:53 +020028obj-y += irq/
Paul E. McKenney4102ada2013-10-08 20:23:47 -070029obj-y += rcu/
Peter Zijlstra391e43d2011-11-15 17:14:39 +010030
Cyrill Gorcunov1e142b22013-02-27 17:05:58 -080031obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
Matt Helsley8174f152008-10-18 20:27:19 -070032obj-$(CONFIG_FREEZER) += freezer.o
Adrian Bunkb03f6482008-07-25 01:45:35 -070033obj-$(CONFIG_PROFILING) += profile.o
Ingo Molnar8637c092006-07-03 00:24:38 -070034obj-$(CONFIG_STACKTRACE) += stacktrace.o
john stultzad596172006-06-26 00:25:06 -070035obj-y += time/
Linus Torvalds1da177e2005-04-16 15:20:36 -070036obj-$(CONFIG_FUTEX) += futex.o
Ingo Molnar34f192c2006-03-27 01:16:24 -080037ifeq ($(CONFIG_COMPAT),y)
38obj-$(CONFIG_FUTEX) += futex_compat.o
39endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070040obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
Amerigo Wang351f8f82011-01-12 16:59:39 -080041obj-$(CONFIG_SMP) += smp.o
Andrew Morton9316fca2009-01-14 09:35:44 -080042ifneq ($(CONFIG_SMP),y)
Andrew Morton53ce3d92009-01-09 12:27:08 -080043obj-y += up.o
44endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070045obj-$(CONFIG_UID16) += uid16.o
David Howellsb56e5a12013-08-30 16:07:30 +010046obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070047obj-$(CONFIG_MODULES) += module.o
David Howellsb56e5a12013-08-30 16:07:30 +010048obj-$(CONFIG_MODULE_SIG) += module_signing.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070049obj-$(CONFIG_KALLSYMS) += kallsyms.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070050obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
Eric W. Biedermandc009d92005-06-25 14:57:52 -070051obj-$(CONFIG_KEXEC) += kexec.o
Arjan van de Ven6dab2772008-01-30 13:33:08 +010052obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070053obj-$(CONFIG_COMPAT) += compat.o
Paul Menageddbcc7e2007-10-18 23:39:30 -070054obj-$(CONFIG_CGROUPS) += cgroup.o
Matt Helsleydc52ddc2008-10-18 20:27:21 -070055obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070056obj-$(CONFIG_CPUSETS) += cpuset.o
Pavel Emelyanovaee16ce2008-02-08 04:18:23 -080057obj-$(CONFIG_UTS_NS) += utsname.o
58obj-$(CONFIG_USER_NS) += user_namespace.o
Pavel Emelyanov74bd59b2008-02-08 04:18:24 -080059obj-$(CONFIG_PID_NS) += pid_namespace.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070060obj-$(CONFIG_IKCONFIG) += configs.o
Pavel Emelianove552b662008-02-07 00:13:49 -080061obj-$(CONFIG_RESOURCE_COUNTERS) += res_counter.o
Tejun Heobbf1bb32010-05-08 16:20:53 +020062obj-$(CONFIG_SMP) += stop_machine.o
Ananth N Mavinakayanahalli8c1c9352008-01-30 13:32:53 +010063obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
Eric Paris939a67f2009-12-17 20:12:06 -050064obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070065obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
Eric Paris939a67f2009-12-17 20:12:06 -050066obj-$(CONFIG_AUDIT_WATCH) += audit_watch.o
Al Viro74c3cbe2007-07-22 08:04:18 -040067obj-$(CONFIG_AUDIT_TREE) += audit_tree.o
Eric Paris939a67f2009-12-17 20:12:06 -050068obj-$(CONFIG_GCOV_KERNEL) += gcov/
Linus Torvalds1da177e2005-04-16 15:20:36 -070069obj-$(CONFIG_KPROBES) += kprobes.o
Jason Wesselc4338202009-05-19 07:49:32 -050070obj-$(CONFIG_KGDB) += debug/
Mandeep Singh Bainese162b392009-01-15 11:08:40 -080071obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o
Don Zickus58687ac2010-05-07 17:11:44 -040072obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070073obj-$(CONFIG_SECCOMP) += seccomp.o
Jens Axboeb86ff9812006-03-23 19:56:55 +010074obj-$(CONFIG_RELAY) += relay.o
Eric W. Biederman39732ac2007-02-14 00:33:58 -080075obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
Shailabh Nagarca74e922006-07-14 00:24:36 -070076obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
Jay Lanf3cef7a2006-09-30 23:28:55 -070077obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
Mathieu Desnoyers97e1c182008-07-18 12:16:16 -040078obj-$(CONFIG_TRACEPOINTS) += tracepoint.o
Arjan van de Ven97455122008-01-25 21:08:34 +010079obj-$(CONFIG_LATENCYTOP) += latencytop.o
Daisuke HATAYAMA1fcccba2010-03-05 13:44:07 -080080obj-$(CONFIG_BINFMT_ELF) += elfcore.o
81obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o
82obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o
Steven Rostedt606576c2008-10-06 19:06:12 -040083obj-$(CONFIG_FUNCTION_TRACER) += trace/
Steven Rostedtbc0c38d2008-05-12 21:20:42 +020084obj-$(CONFIG_TRACING) += trace/
Josh Triplettea632e92012-09-02 19:45:14 -070085obj-$(CONFIG_TRACE_CLOCK) += trace/
Paul Mundt1155de42009-06-25 14:30:12 +090086obj-$(CONFIG_RING_BUFFER) += trace/
Mathieu Desnoyers870915e2010-10-28 11:31:17 -040087obj-$(CONFIG_TRACEPOINTS) += trace/
Peter Zijlstrae360adb2010-10-14 14:01:34 +080088obj-$(CONFIG_IRQ_WORK) += irq_work.o
Colin Crossab100232011-02-10 02:04:45 -080089obj-$(CONFIG_CPU_PM) += cpu_pm.o
Borislav Petkovfae85b72010-10-26 20:24:03 +020090
91obj-$(CONFIG_PERF_EVENTS) += events/
92
Avi Kivity7a041092009-10-25 14:24:45 +020093obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o
Steffen Klassert16295be2010-01-06 19:47:10 +110094obj-$(CONFIG_PADATA) += padata.o
Olaf Hering93a72052011-03-23 16:43:29 -070095obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
Jason Baronb77f0f32011-08-05 16:40:40 -040096obj-$(CONFIG_JUMP_LABEL) += jump_label.o
Frederic Weisbecker91d1aa432012-11-27 19:33:25 +010097obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o
Paul E. McKenney51b11302014-01-27 11:49:39 -080098obj-$(CONFIG_TORTURE_TEST) += torture.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100$(obj)/configs.o: $(obj)/config_data.h
101
102# config_data.h contains the same information as ikconfig.h but gzipped.
103# Info from config_data can be extracted from /proc/config*
104targets += config_data.gz
Ben Gardiner41263fc2010-12-14 11:39:44 -0500105$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 $(call if_changed,gzip)
107
Peter Foleye78e8f22011-07-05 19:42:18 -0400108 filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/bin2c; echo "MAGIC_END;")
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109targets += config_data.h
110$(obj)/config_data.h: $(obj)/config_data.gz FORCE
Peter Foleye78e8f22011-07-05 19:42:18 -0400111 $(call filechk,ikconfiggz)
H. Peter Anvinbdc80782008-02-08 04:21:26 -0800112
113$(obj)/time.o: $(obj)/timeconst.h
114
H. Peter Anvin70730bc2013-02-14 15:13:55 -0800115quiet_cmd_hzfile = HZFILE $@
116 cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@
117
118targets += hz.bc
119$(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE
120 $(call if_changed,hzfile)
121
122quiet_cmd_bc = BC $@
123 cmd_bc = bc -q $(filter-out FORCE,$^) > $@
124
H. Peter Anvinbdc80782008-02-08 04:21:26 -0800125targets += timeconst.h
H. Peter Anvin70730bc2013-02-14 15:13:55 -0800126$(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE
127 $(call if_changed,bc)
David Howellsd4411082012-09-26 10:09:51 +0100128
David Howellsf0e6d222013-08-30 16:07:13 +0100129###############################################################################
David Howells631cc66e2012-09-26 10:09:51 +0100130#
David Howells0fbd39c2013-08-30 17:13:15 +0100131# Roll all the X.509 certificates that we can find together and pull them into
David Howellsb56e5a12013-08-30 16:07:30 +0100132# the kernel so that they get loaded into the system trusted keyring during
133# boot.
David Howells0fbd39c2013-08-30 17:13:15 +0100134#
135# We look in the source root and the build root for all files whose name ends
136# in ".x509". Unfortunately, this will generate duplicate filenames, so we
137# have make canonicalise the pathnames and then sort them to discard the
138# duplicates.
David Howells631cc66e2012-09-26 10:09:51 +0100139#
David Howellsf0e6d222013-08-30 16:07:13 +0100140###############################################################################
David Howellsb56e5a12013-08-30 16:07:30 +0100141ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y)
David Howellsf0e6d222013-08-30 16:07:13 +0100142X509_CERTIFICATES-y := $(wildcard *.x509) $(wildcard $(srctree)/*.x509)
David Howellsd7ec4352013-12-13 15:20:19 +0000143X509_CERTIFICATES-$(CONFIG_MODULE_SIG) += $(objtree)/signing_key.x509
144X509_CERTIFICATES-raw := $(sort $(foreach CERT,$(X509_CERTIFICATES-y), \
David Howells0fbd39c2013-08-30 17:13:15 +0100145 $(or $(realpath $(CERT)),$(CERT))))
David Howellsd7ec4352013-12-13 15:20:19 +0000146X509_CERTIFICATES := $(subst $(realpath $(objtree))/,,$(X509_CERTIFICATES-raw))
David Howells631cc66e2012-09-26 10:09:51 +0100147
David Howellsf0e6d222013-08-30 16:07:13 +0100148ifeq ($(X509_CERTIFICATES),)
149$(warning *** No X.509 certificates found ***)
150endif
Michal Mareke10e17742012-12-11 12:26:22 +1030151
David Howellsf0e6d222013-08-30 16:07:13 +0100152ifneq ($(wildcard $(obj)/.x509.list),)
153ifneq ($(shell cat $(obj)/.x509.list),$(X509_CERTIFICATES))
154$(info X.509 certificate list changed)
155$(shell rm $(obj)/.x509.list)
156endif
157endif
David Howells631cc66e2012-09-26 10:09:51 +0100158
David Howellsb56e5a12013-08-30 16:07:30 +0100159kernel/system_certificates.o: $(obj)/x509_certificate_list
David Howellsf0e6d222013-08-30 16:07:13 +0100160
161quiet_cmd_x509certs = CERTS $@
David Howellsb56e5a12013-08-30 16:07:30 +0100162 cmd_x509certs = cat $(X509_CERTIFICATES) /dev/null >$@ $(foreach X509,$(X509_CERTIFICATES),; echo " - Including cert $(X509)")
163
David Howellsf0e6d222013-08-30 16:07:13 +0100164targets += $(obj)/x509_certificate_list
165$(obj)/x509_certificate_list: $(X509_CERTIFICATES) $(obj)/.x509.list
166 $(call if_changed,x509certs)
167
168targets += $(obj)/.x509.list
169$(obj)/.x509.list:
170 @echo $(X509_CERTIFICATES) >$@
Kirill Tkhaif46a3cb2013-12-10 22:39:57 +0400171endif
David Howellsf0e6d222013-08-30 16:07:13 +0100172
173clean-files := x509_certificate_list .x509.list
David Howellsd4411082012-09-26 10:09:51 +0100174
H. Peter Anvinbdc80782008-02-08 04:21:26 -0800175ifeq ($(CONFIG_MODULE_SIG),y)
David Howellsd4411082012-09-26 10:09:51 +0100176###############################################################################
177#
178# If module signing is requested, say by allyesconfig, but a key has not been
179# supplied, then one will need to be generated to make sure the build does not
180# fail and that the kernel may be used afterwards.
181#
182###############################################################################
Michal Marek22753672013-01-25 13:41:00 +1030183ifndef CONFIG_MODULE_SIG_HASH
David Howells5e8cb1e2012-09-28 11:16:57 +0100184$(error Could not determine digest type to use from kernel config)
185endif
186
David Howellsd4411082012-09-26 10:09:51 +0100187signing_key.priv signing_key.x509: x509.genkey
188 @echo "###"
189 @echo "### Now generating an X.509 key pair to be used for signing modules."
190 @echo "###"
191 @echo "### If this takes a long time, you might wish to run rngd in the"
192 @echo "### background to keep the supply of entropy topped up. It"
H. Peter Anvin20087132012-10-24 14:11:48 -0700193 @echo "### needs to be run as root, and uses a hardware random"
194 @echo "### number generator if one is available."
David Howellsd4411082012-09-26 10:09:51 +0100195 @echo "###"
Michal Marek22753672013-01-25 13:41:00 +1030196 openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
197 -batch -x509 -config x509.genkey \
David Howellsd4411082012-09-26 10:09:51 +0100198 -outform DER -out signing_key.x509 \
David Cohen07c449b2013-04-11 13:22:14 +0930199 -keyout signing_key.priv 2>&1
David Howellsd4411082012-09-26 10:09:51 +0100200 @echo "###"
201 @echo "### Key pair generated."
202 @echo "###"
203
204x509.genkey:
205 @echo Generating X.509 key generation config
206 @echo >x509.genkey "[ req ]"
207 @echo >>x509.genkey "default_bits = 4096"
208 @echo >>x509.genkey "distinguished_name = req_distinguished_name"
209 @echo >>x509.genkey "prompt = no"
David Howellse7d113b2012-09-28 11:16:57 +0100210 @echo >>x509.genkey "string_mask = utf8only"
David Howellsd4411082012-09-26 10:09:51 +0100211 @echo >>x509.genkey "x509_extensions = myexts"
212 @echo >>x509.genkey
213 @echo >>x509.genkey "[ req_distinguished_name ]"
214 @echo >>x509.genkey "O = Magrathea"
215 @echo >>x509.genkey "CN = Glacier signing key"
216 @echo >>x509.genkey "emailAddress = slartibartfast@magrathea.h2g2"
217 @echo >>x509.genkey
218 @echo >>x509.genkey "[ myexts ]"
219 @echo >>x509.genkey "basicConstraints=critical,CA:FALSE"
220 @echo >>x509.genkey "keyUsage=digitalSignature"
221 @echo >>x509.genkey "subjectKeyIdentifier=hash"
222 @echo >>x509.genkey "authorityKeyIdentifier=keyid"
223endif