xref: /haiku/src/system/kernel/Jamfile (revision c9afad22682e9f15753db4e9ca8684e2d4a643a9)
1SubDir HAIKU_TOP src system kernel ;
2
3{
4	local defines =
5		HAIKU_ARCH=\\\"$(TARGET_ARCH)\\\"
6		;
7
8	defines = [ FDefines $(defines) ] ;
9	SubDirCcFlags $(defines) ;
10	SubDirC++Flags $(defines) ;
11}
12
13SEARCH_SOURCE += [ FDirName $(SUBDIR) events ] ;
14SEARCH_SOURCE += [ FDirName $(SUBDIR) locks ] ;
15SEARCH_SOURCE += [ FDirName $(SUBDIR) scheduler ] ;
16
17UsePrivateHeaders libroot ;
18UsePrivateHeaders shared ;
19UsePrivateHeaders runtime_loader ;
20
21AddResources kernel_$(TARGET_ARCH) : kernel.rdef ;
22
23SetVersionScript kernel_$(TARGET_ARCH) : kernel_versions ;
24SetVersionScript kernel.so : kernel_versions ;
25
26KernelMergeObject kernel_core.o :
27	boot_item.cpp
28	boot_splash.cpp
29	commpage.cpp
30	condition_variable.cpp
31	convertutf.cpp
32	cpu.cpp
33	DPC.cpp
34	elf.cpp
35	guarded_heap.cpp
36	heap.cpp
37	image.cpp
38	int.cpp
39	kernel_daemon.cpp
40	linkhack.c
41	listeners.cpp
42	low_resource_manager.cpp
43	main.cpp
44	module.cpp
45	port.cpp
46	real_time_clock.cpp
47	sem.cpp
48	shutdown.cpp
49	signal.cpp
50	system_info.cpp
51	smp.cpp
52	syscalls.cpp
53	team.cpp
54	thread.cpp
55	timer.cpp
56	UserEvent.cpp
57	usergroup.cpp
58	UserTimer.cpp
59
60	# events
61	wait_for_objects.cpp
62	Notifications.cpp
63	event_queue.cpp
64
65	# locks
66	lock.cpp
67	user_mutex.cpp
68
69	# scheduler
70	low_latency.cpp
71	power_saving.cpp
72	scheduler.cpp
73	scheduler_cpu.cpp
74	scheduler_profiler.cpp
75	scheduler_thread.cpp
76	scheduler_tracing.cpp
77	scheduling_analysis.cpp
78
79	: $(TARGET_KERNEL_PIC_CCFLAGS)
80;
81
82# Generate the header defining macros for C++ structure sizes.
83local kernelC++StructSizesHeader = [ FGristFiles kernel_c++_struct_sizes.h ] ;
84TARGET_HDRS_$(TARGET_KERNEL_ARCH) on $(kernelC++StructSizesHeader)
85	= [ on $(kernelC++StructSizesHeader)
86			return $(TARGET_HDRS_$(TARGET_KERNEL_ARCH)) ]
87		$(TARGET_PRIVATE_KERNEL_HEADERS) ;
88CreateAsmStructOffsetsHeader $(kernelC++StructSizesHeader)
89	: kernel_c++_structs.cpp : $(TARGET_KERNEL_ARCH) ;
90
91# We need to specify the dependency on the generated syscalls files explicitly.
92Includes [ FGristFiles syscalls.cpp ]
93	:
94	<syscalls!$(TARGET_PACKAGING_ARCH)>syscall_dispatcher.h
95	<syscalls!$(TARGET_PACKAGING_ARCH)>syscall_table.h
96	<syscalls!$(TARGET_PACKAGING_ARCH)>syscall_numbers.h
97;
98
99KernelLd linkhack.so :
100	<$(SOURCE_GRIST)>linkhack.o
101	:
102	:
103	-shared -Bdynamic
104;
105
106KernelLd kernel_$(TARGET_ARCH) :
107	kernel_cache.o
108	kernel_core.o
109	kernel_debug.o
110	kernel_device_manager.o
111	kernel_disk_device_manager.o
112	kernel_fs.o
113	kernel_messaging.o
114	kernel_posix.o
115	kernel_slab.o
116	kernel_util.o
117	kernel_vm.o
118
119	kernel_arch_$(TARGET_KERNEL_ARCH).o
120	kernel_platform_$(TARGET_KERNEL_PLATFORM).o
121
122	linkhack.so
123
124	# kernel parts borrowed from libroot and others
125	kernel_os_main.o
126	kernel_os_arch_$(TARGET_ARCH).o
127	kernel_lib_posix.o
128	kernel_lib_posix_arch_$(TARGET_ARCH).o
129	kernel_misc.o
130
131	: $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/kernel.ld
132	: -Bdynamic -export-dynamic -dynamic-linker /foo/bar
133	  $(TARGET_KERNEL_PIC_LINKFLAGS) --no-undefined
134	:
135;
136
137if $(HAIKU_ARCH) in x86_64 arm {
138	# Cannot relink everything as a shared object on x86_64 as shared library
139	# code is required to be position-independent. Instead create a copy of the
140	# executable kernel image and change the ELF header type to DYN. A bit of
141	# a hack, but avoids having to recompile a PIC copy of the kernel code.
142	# kernel.so is only used when linking modules to provide symbol information,
143	# this is sufficient for that purpose.
144	KernelSo kernel.so : kernel_$(TARGET_ARCH) ;
145} else {
146	KernelLd kernel.so :
147		kernel_cache.o
148		kernel_core.o
149		kernel_debug.o
150		kernel_device_manager.o
151		kernel_disk_device_manager.o
152		kernel_fs.o
153		kernel_messaging.o
154		kernel_posix.o
155		kernel_slab.o
156		kernel_util.o
157		kernel_vm.o
158
159		kernel_arch_$(TARGET_KERNEL_ARCH).o
160		kernel_platform_$(TARGET_KERNEL_PLATFORM).o
161
162		linkhack.so
163
164		# kernel libroot parts
165		kernel_os_main.o
166		kernel_os_arch_$(TARGET_ARCH).o
167		kernel_lib_posix.o
168		kernel_lib_posix_arch_$(TARGET_ARCH).o
169		kernel_misc.o
170
171		: $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/kernel.ld
172		: -Bdynamic -shared -export-dynamic -dynamic-linker /foo/bar
173		  $(TARGET_KERNEL_PIC_LINKFLAGS)
174	;
175}
176
177NotFile kernel ;
178Depends kernel : kernel_$(TARGET_ARCH) ;
179Depends kernel.so : kernel ;
180	# kernel.so will be rebuilt with the kernel
181
182# propagate the container update variable from kernel to kernel_$(TARGET_ARCH)
183PropagateContainerUpdateTargetFlags kernel_$(TARGET_ARCH) : kernel ;
184
185# Copy kernel and update the copy's revision section. We link everything
186# against the original, but the copy will end up on the disk image (this way
187# we avoid unnecessary dependencies). The copy will be located in a subdirectory.
188if $(TARGET_PLATFORM) = haiku {
189	MakeLocate <revisioned>kernel_$(TARGET_ARCH)
190		: [ FDirName $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET) revisioned ] ;
191	CopySetHaikuRevision <revisioned>kernel_$(TARGET_ARCH)
192		: kernel_$(TARGET_ARCH) ;
193}
194
195
196SubInclude HAIKU_TOP src system kernel arch ;
197SubInclude HAIKU_TOP src system kernel cache ;
198SubInclude HAIKU_TOP src system kernel device_manager ;
199SubInclude HAIKU_TOP src system kernel debug ;
200SubInclude HAIKU_TOP src system kernel disk_device_manager ;
201SubInclude HAIKU_TOP src system kernel fs ;
202SubInclude HAIKU_TOP src system kernel lib ;
203SubInclude HAIKU_TOP src system kernel messaging ;
204SubInclude HAIKU_TOP src system kernel posix ;
205SubInclude HAIKU_TOP src system kernel slab ;
206SubInclude HAIKU_TOP src system kernel util ;
207SubInclude HAIKU_TOP src system kernel vm ;
208
209if $(TARGET_KERNEL_PLATFORM) {
210	SubInclude HAIKU_TOP src system kernel platform $(TARGET_KERNEL_PLATFORM) ;
211}
212