3 # Usage SetupKernel <sources_or_objects> : <extra_cc_flags> : <include_private_headers> ;
5 # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be
6 # set for the sources and the sources some header
7 # dependencies might be missing.
9 local sources = [ FGristFiles $(1) ] ;
10 local objects = $(sources:S=$(SUFOBJ)) ;
12 # add private kernel headers
14 SourceSysHdrs $(sources) : $(TARGET_PRIVATE_KERNEL_HEADERS) ;
18 for object in $(objects) {
19 # add kernel flags for the object
20 ObjectCcFlags $(object) : $(TARGET_KERNEL_CCFLAGS) $(2) ;
21 ObjectC++Flags $(object) : $(TARGET_KERNEL_C++FLAGS) $(2) ;
22 ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ;
24 # override warning flags
25 TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH) on $(object)
26 = $(TARGET_KERNEL_WARNING_CCFLAGS) ;
27 TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) on $(object)
28 = $(TARGET_KERNEL_WARNING_C++FLAGS) ;
34 SetupKernel $(1) : $(2) ;
40 # KernelLd <name> : <objs> : <linkerscript> : <args> ;
42 LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ;
44 LINKFLAGS on $(1) = $(4) ;
45 if $(3) { LINKFLAGS on $(1) += --script=$(3) ; }
47 # Remove any preset LINKLIBS, but link against libgcc.a. Linking against
48 # libsupc++ is opt-out.
50 if ! [ on $(1) return $(HAIKU_NO_LIBSUPC++) ] {
51 libs += [ TargetKernelLibsupc++ true ] ;
52 Depends $(1) : [ TargetKernelLibsupc++ ] ;
54 LINKLIBS on $(1) = $(libs) [ TargetKernelLibgcc true ] ;
55 Depends $(1) : [ TargetKernelLibgcc ] ;
57 HAIKU_TARGET_IS_EXECUTABLE on $(1) = 1 ;
59 # TODO: Do we really want to invoke SetupKernel here? The objects should
60 # have been compiled with KernelObjects anyway, so we're doing that twice.
63 # Show that we depend on the libraries we need
64 LocalClean clean : $(1) ;
65 LocalDepends all : $(1) ;
68 MakeLocateDebug $(1) ;
70 on $(1) XRes $(1) : $(RESFILES) ;
71 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
78 actions KernelLd bind VERSION_SCRIPT
80 $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \
81 --version-script=$(VERSION_SCRIPT)
84 rule KernelSo target : source
86 # KernelSo <target> : <source>
88 Depends $(target) : <build>copyattr $(source) ;
90 MakeLocateDebug $(1) ;
91 KernelSo1 $(target) : <build>copyattr $(source) ;
96 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
98 $(2[1]) --data $(2[2]) $(1) &&
99 $(HAIKU_ELFEDIT_$(TARGET_PACKAGING_ARCH)) --output-type dyn $(1)
104 # KernelAddon <name> : <sources> : <static-libraries> : <res> ;
106 local target = $(1) ;
107 local sources = $(2) ;
109 AddResources $(1) : $(4) ;
115 # platform supported?
116 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
120 # determine which kernel and glue code to link against
121 if $(PLATFORM) = haiku {
122 kernel = <nogrist>kernel.so ;
123 beginGlue = $(HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE) ;
125 = [ TargetKernelLibgcc ] $(HAIKU_KERNEL_ADDON_END_GLUE_CODE) ;
126 } else if $(PLATFORM) = haiku_host {
127 kernel = /boot/develop/lib/x86/kernel.so ;
128 beginGlue = $(HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE) ;
129 endGlue = $(HAIKU_KERNEL_ADDON_END_GLUE_CODE) ;
131 kernel = /boot/develop/lib/x86/_KERNEL_ ;
136 LINK_BEGIN_GLUE on $(target) = $(beginGlue) ;
137 LINK_END_GLUE on $(target) = $(endGlue) ;
138 Depends $(target) : $(beginGlue) $(endGlue) ;
141 SetupKernel $(sources) : : false ;
142 local linkFlags = -shared -nostdlib -Xlinker --no-undefined
143 -Xlinker -soname=\"$(target:G=)\" $(TARGET_KERNEL_ADDON_LINKFLAGS) ;
144 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] $(linkFlags) ;
145 Main $(target) : $(sources) ;
146 LinkAgainst $(target) : $(libs) $(kernel) ;
149 rule KernelMergeObject
151 # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ;
152 # Compiles source files and merges the object files to an object file.
153 # <name>: Name of the object file to create. No grist will be added.
154 # <sources>: Sources to be compiled. Grist will be added.
155 # <extra CFLAGS>: Additional flags for compilation.
156 # <other objects>: Object files or static libraries to be merged. No grist
160 SetupKernel $(2) : $(3) ;
162 MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ;
165 rule KernelStaticLibrary
167 # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ;
168 # This is designed to take a set of sources and libraries and create
171 SetupKernel $(2) : $(3) : false ;
172 Library $(1) : $(2) ;
175 rule KernelStaticLibraryObjects
177 # Usage KernelStaticLibrary <name> : <sources> ;
178 # This is designed to take a set of sources and libraries and create
179 # a file called <name>
181 # Show that we depend on the libraries we need
183 LocalClean clean : $(1) ;
184 LocalDepends all : $(1) ;
185 Depends $(1) : $(2) ;
187 MakeLocateDebug $(1) ;
190 actions KernelStaticLibraryObjects
192 # Force recreation of the archive to avoid build errors caused by
193 # stale dependencies after renaming or deleting object files.
195 $(HAIKU_AR_$(TARGET_PACKAGING_ARCH)) -r "$(1)" "$(2)" ;