2005-10-29 20:27:43 +04:00
|
|
|
rule SetupKernel
|
|
|
|
{
|
2006-08-17 16:18:11 +04:00
|
|
|
# Usage SetupKernel <sources_or_objects> : <extra_cc_flags> : <include_private_headers> ;
|
2005-10-29 20:27:43 +04:00
|
|
|
#
|
|
|
|
# <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be
|
|
|
|
# set for the sources and the sources some header
|
|
|
|
# dependencies might be missing.
|
|
|
|
|
|
|
|
local sources = [ FGristFiles $(1) ] ;
|
|
|
|
local objects = $(sources:S=$(SUFOBJ)) ;
|
|
|
|
|
|
|
|
# add private kernel headers
|
2006-08-17 16:18:11 +04:00
|
|
|
if $(3) != false {
|
|
|
|
SourceSysHdrs $(sources) : $(TARGET_PRIVATE_KERNEL_HEADERS) ;
|
|
|
|
}
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
local object ;
|
|
|
|
for object in $(objects) {
|
|
|
|
# add kernel flags for the object
|
|
|
|
ObjectCcFlags $(object) : $(TARGET_KERNEL_CCFLAGS) $(2) ;
|
|
|
|
ObjectC++Flags $(object) : $(TARGET_KERNEL_C++FLAGS) $(2) ;
|
2008-01-11 03:36:44 +03:00
|
|
|
ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ;
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
# override warning flags
|
2013-08-01 10:51:16 +04:00
|
|
|
TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH) on $(object)
|
|
|
|
= $(TARGET_KERNEL_WARNING_CCFLAGS) ;
|
|
|
|
TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) on $(object)
|
2005-10-29 20:27:43 +04:00
|
|
|
= $(TARGET_KERNEL_WARNING_C++FLAGS) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rule KernelObjects
|
|
|
|
{
|
|
|
|
SetupKernel $(1) : $(2) ;
|
|
|
|
Objects $(1) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule KernelLd
|
|
|
|
{
|
|
|
|
# KernelLd <name> : <objs> : <linkerscript> : <args> ;
|
|
|
|
|
2013-08-01 10:51:16 +04:00
|
|
|
LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ;
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
LINKFLAGS on $(1) = $(4) ;
|
|
|
|
if $(3) { LINKFLAGS on $(1) += --script=$(3) ; }
|
|
|
|
|
2011-06-19 15:43:24 +04:00
|
|
|
# Remove any preset LINKLIBS, but link against libgcc.a. Linking against
|
|
|
|
# libsupc++ is opt-out.
|
|
|
|
local libs ;
|
2014-07-15 15:43:51 +04:00
|
|
|
if ! [ on $(1) return $(HAIKU_NO_LIBSUPC++) ] {
|
2012-08-16 16:47:49 +04:00
|
|
|
libs += $(TARGET_KERNEL_LIBSUPC++) ;
|
2011-06-19 15:43:24 +04:00
|
|
|
}
|
2012-08-16 16:47:49 +04:00
|
|
|
LINKLIBS on $(1) = $(libs) $(TARGET_KERNEL_LIBGCC) ;
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2013-10-12 20:42:57 +04:00
|
|
|
HAIKU_TARGET_IS_EXECUTABLE on $(1) = 1 ;
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# TODO: Do we really want to invoke SetupKernel here? The objects should
|
|
|
|
# have been compiled with KernelObjects anyway, so we're doing that twice.
|
|
|
|
SetupKernel $(2) ;
|
|
|
|
|
|
|
|
# Show that we depend on the libraries we need
|
|
|
|
LocalClean clean : $(1) ;
|
|
|
|
LocalDepends all : $(1) ;
|
|
|
|
Depends $(1) : $(2) ;
|
|
|
|
|
2009-05-22 18:51:16 +04:00
|
|
|
MakeLocateDebug $(1) ;
|
2006-06-13 20:08:55 +04:00
|
|
|
|
|
|
|
on $(1) XRes $(1) : $(RESFILES) ;
|
|
|
|
if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
|
|
|
|
SetType $(1) ;
|
|
|
|
MimeSet $(1) ;
|
|
|
|
SetVersion $(1) ;
|
|
|
|
}
|
2005-10-29 20:27:43 +04:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:51:16 +04:00
|
|
|
actions KernelLd bind VERSION_SCRIPT
|
2005-10-29 20:27:43 +04:00
|
|
|
{
|
2009-05-22 18:51:16 +04:00
|
|
|
$(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \
|
|
|
|
--version-script=$(VERSION_SCRIPT)
|
2005-10-29 20:27:43 +04:00
|
|
|
}
|
|
|
|
|
2012-07-19 20:53:46 +04:00
|
|
|
rule KernelSo target : source
|
|
|
|
{
|
|
|
|
# KernelSo <target> : <source>
|
|
|
|
|
|
|
|
Depends $(target) : <build>copyattr $(source) ;
|
|
|
|
|
|
|
|
MakeLocateDebug $(1) ;
|
|
|
|
KernelSo1 $(target) : <build>copyattr $(source) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions KernelSo1
|
|
|
|
{
|
|
|
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
|
|
|
|
$(2[1]) --data $(2[2]) $(1) &&
|
2013-08-01 10:51:16 +04:00
|
|
|
$(HAIKU_ELFEDIT_$(TARGET_PACKAGING_ARCH)) --output-type dyn $(1)
|
2012-07-19 20:53:46 +04:00
|
|
|
}
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
rule KernelAddon
|
|
|
|
{
|
2006-09-18 14:02:13 +04:00
|
|
|
# KernelAddon <name> : <sources> : <static-libraries> : <res> ;
|
2005-12-15 16:01:25 +03:00
|
|
|
#
|
|
|
|
local target = $(1) ;
|
2006-09-18 14:02:13 +04:00
|
|
|
local sources = $(2) ;
|
|
|
|
local libs = $(3) ;
|
|
|
|
AddResources $(1) : $(4) ;
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2005-12-15 16:01:25 +03:00
|
|
|
local kernel ;
|
|
|
|
local beginGlue ;
|
|
|
|
local endGlue ;
|
|
|
|
on $(target) {
|
|
|
|
# platform supported?
|
2005-10-29 20:27:43 +04:00
|
|
|
if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2005-12-15 16:01:25 +03:00
|
|
|
# determine which kernel and glue code to link against
|
|
|
|
if $(PLATFORM) = haiku {
|
|
|
|
kernel = <nogrist>kernel.so ;
|
|
|
|
beginGlue = $(HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE) ;
|
|
|
|
endGlue = $(HAIKU_KERNEL_ADDON_END_GLUE_CODE) ;
|
2007-08-03 01:13:56 +04:00
|
|
|
} else if $(PLATFORM) = haiku_host {
|
|
|
|
kernel = /boot/develop/lib/x86/kernel.so ;
|
|
|
|
beginGlue = $(HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE) ;
|
|
|
|
endGlue = $(HAIKU_KERNEL_ADDON_END_GLUE_CODE) ;
|
2005-12-15 16:01:25 +03:00
|
|
|
} else {
|
|
|
|
kernel = /boot/develop/lib/x86/_KERNEL_ ;
|
|
|
|
}
|
2005-10-29 20:27:43 +04:00
|
|
|
}
|
|
|
|
|
2005-12-15 16:01:25 +03:00
|
|
|
# add glue code
|
|
|
|
LINK_BEGIN_GLUE on $(target) = $(beginGlue) ;
|
|
|
|
LINK_END_GLUE on $(target) = $(endGlue) ;
|
|
|
|
Depends $(target) : $(beginGlue) $(endGlue) ;
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2005-12-15 16:01:25 +03:00
|
|
|
# compile and link
|
2013-08-30 00:24:36 +04:00
|
|
|
SetupKernel $(sources) : : false ;
|
2008-04-20 07:08:29 +04:00
|
|
|
local linkFlags = -nostdlib -Xlinker --no-undefined
|
2012-07-19 20:53:46 +04:00
|
|
|
-Xlinker -soname=\"$(target:G=)\" $(TARGET_KERNEL_ADDON_LINKFLAGS) ;
|
2005-12-15 16:01:25 +03:00
|
|
|
LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] $(linkFlags) ;
|
|
|
|
Main $(target) : $(sources) ;
|
|
|
|
LinkAgainst $(target) : $(libs) $(kernel) ;
|
2005-10-29 20:27:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rule KernelMergeObject
|
|
|
|
{
|
|
|
|
# KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ;
|
|
|
|
# Compiles source files and merges the object files to an object file.
|
|
|
|
# <name>: Name of the object file to create. No grist will be added.
|
|
|
|
# <sources>: Sources to be compiled. Grist will be added.
|
|
|
|
# <extra CFLAGS>: Additional flags for compilation.
|
|
|
|
# <other objects>: Object files or static libraries to be merged. No grist
|
|
|
|
# will be added.
|
|
|
|
#
|
|
|
|
|
|
|
|
SetupKernel $(2) : $(3) ;
|
|
|
|
Objects $(2) ;
|
|
|
|
MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule KernelStaticLibrary
|
|
|
|
{
|
|
|
|
# Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ;
|
|
|
|
# This is designed to take a set of sources and libraries and create
|
2013-05-05 17:04:08 +04:00
|
|
|
# a static library.
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2006-08-17 16:18:11 +04:00
|
|
|
SetupKernel $(2) : $(3) : false ;
|
2005-10-29 20:27:43 +04:00
|
|
|
Library $(1) : $(2) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule KernelStaticLibraryObjects
|
|
|
|
{
|
|
|
|
# Usage KernelStaticLibrary <name> : <sources> ;
|
|
|
|
# This is designed to take a set of sources and libraries and create
|
|
|
|
# a file called <name>
|
|
|
|
|
|
|
|
# Show that we depend on the libraries we need
|
|
|
|
SetupKernel $(2) ;
|
|
|
|
LocalClean clean : $(1) ;
|
|
|
|
LocalDepends all : $(1) ;
|
|
|
|
Depends $(1) : $(2) ;
|
|
|
|
|
|
|
|
MakeLocateDebug $(1) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions KernelStaticLibraryObjects
|
|
|
|
{
|
2007-02-18 01:42:16 +03:00
|
|
|
# Force recreation of the archive to avoid build errors caused by
|
|
|
|
# stale dependencies after renaming or deleting object files.
|
|
|
|
$(RM) "$(1)"
|
2013-08-01 10:51:16 +04:00
|
|
|
$(HAIKU_AR_$(TARGET_PACKAGING_ARCH)) -r "$(1)" "$(2)" ;
|
2005-10-29 20:27:43 +04:00
|
|
|
}
|