1 2rule SetupKernel 3{ 4 # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 5 # 6 # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be 7 # set for the sources and the sources some header 8 # dependencies might be missing. 9 10 local sources = [ FGristFiles $(1) ] ; 11 local objects = $(sources:S=$(SUFOBJ)) ; 12 13 # add private kernel headers 14 SourceSysHdrs $(sources) : $(TARGET_PRIVATE_KERNEL_HEADERS) ; 15 16 local object ; 17 for object in $(objects) { 18 # add kernel flags for the object 19 ObjectCcFlags $(object) : $(TARGET_KERNEL_CCFLAGS) $(2) ; 20 ObjectC++Flags $(object) : $(TARGET_KERNEL_C++FLAGS) $(2) ; 21 22 # override warning flags 23 TARGET_WARNING_CCFLAGS on $(object) = $(TARGET_KERNEL_WARNING_CCFLAGS) ; 24 TARGET_WARNING_C++FLAGS on $(object) 25 = $(TARGET_KERNEL_WARNING_C++FLAGS) ; 26 } 27} 28 29rule KernelObjects 30{ 31 SetupKernel $(1) : $(2) ; 32 Objects $(1) ; 33} 34 35rule KernelLd 36{ 37 # KernelLd <name> : <objs> : <linkerscript> : <args> ; 38 39 LINK on $(1) = $(TARGET_LD) ; 40 41 LINKFLAGS on $(1) = $(4) ; 42 if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 43 44 # Remove any preset LINKLIBS, but link against libgcc.a 45 LINKLIBS on $(1) = $(TARGET_STATIC_LIBSUPC++) $(TARGET_GCC_LIBGCC) ; 46 47 # TODO: Do we really want to invoke SetupKernel here? The objects should 48 # have been compiled with KernelObjects anyway, so we're doing that twice. 49 SetupKernel $(2) ; 50 51 # Show that we depend on the libraries we need 52 LocalClean clean : $(1) ; 53 LocalDepends all : $(1) ; 54 Depends $(1) : $(2) ; 55 56 MakeLocateDebug $(1) ; 57} 58 59actions KernelLd 60{ 61 $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; 62} 63 64rule KernelAddon 65{ 66 # KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 67 68 local sources = $(3) ; 69 70 # platform supported? 71 on $(1) { 72 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 73 return ; 74 } 75 } 76 77 # When building for Haiku, we link against kernel.so, otherwise 78 # against the system kernel. 79 local kernel ; 80 if [ on $(1) return $(PLATFORM) ] = haiku { 81 kernel = <nogrist>kernel.so ; 82 } else { 83 kernel = /boot/develop/lib/x86/_KERNEL_ ; 84 } 85 86 SetupKernel $(sources) : -fno-pic ; 87 88 Addon $(1) : $(2) : $(sources) ; 89 LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 90 LinkAgainst $(1) : $(4) $(kernel) ; 91} 92 93rule KernelMergeObject 94{ 95 # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 96 # Compiles source files and merges the object files to an object file. 97 # <name>: Name of the object file to create. No grist will be added. 98 # <sources>: Sources to be compiled. Grist will be added. 99 # <extra CFLAGS>: Additional flags for compilation. 100 # <other objects>: Object files or static libraries to be merged. No grist 101 # will be added. 102 # 103 104 SetupKernel $(2) : $(3) ; 105 Objects $(2) ; 106 MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 107} 108 109rule KernelStaticLibrary 110{ 111 # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 112 # This is designed to take a set of sources and libraries and create 113 # a file called lib<name>.a 114 115 SetupKernel $(2) : $(3) ; 116 Library $(1) : $(2) ; 117} 118 119rule KernelStaticLibraryObjects 120{ 121 # Usage KernelStaticLibrary <name> : <sources> ; 122 # This is designed to take a set of sources and libraries and create 123 # a file called <name> 124 125 # Show that we depend on the libraries we need 126 SetupKernel $(2) ; 127 LocalClean clean : $(1) ; 128 LocalDepends all : $(1) ; 129 Depends $(1) : $(2) ; 130 131 MakeLocateDebug $(1) ; 132} 133 134actions KernelStaticLibraryObjects 135{ 136 $(HAIKU_AR) -r "$(1)" "$(2)" ; 137} 138