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# TODO: <relpath> no longer needed! 69 local target = $(1) ; 70 local sources = $(3) ; 71 local libs = $(4) ; 72 73 local kernel ; 74 local beginGlue ; 75 local endGlue ; 76 on $(target) { 77 # platform supported? 78 if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 79 return ; 80 } 81 82 # determine which kernel and glue code to link against 83 if $(PLATFORM) = haiku { 84 kernel = <nogrist>kernel.so ; 85 beginGlue = $(HAIKU_KERNEL_ADDON_BEGIN_GLUE_CODE) ; 86 endGlue = $(HAIKU_KERNEL_ADDON_END_GLUE_CODE) ; 87 } else { 88 kernel = /boot/develop/lib/x86/_KERNEL_ ; 89 } 90 } 91 92 # add glue code 93 LINK_BEGIN_GLUE on $(target) = $(beginGlue) ; 94 LINK_END_GLUE on $(target) = $(endGlue) ; 95 Depends $(target) : $(beginGlue) $(endGlue) ; 96 97 # compile and link 98 SetupKernel $(sources) : $(TARGET_KERNEL_PIC_FLAGS) ; 99 local linkFlags = -nostdlib -Xlinker -soname=\"$(target)\" ; 100 LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] $(linkFlags) ; 101 Main $(target) : $(sources) ; 102 LinkAgainst $(target) : $(libs) $(kernel) ; 103} 104 105rule KernelMergeObject 106{ 107 # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 108 # Compiles source files and merges the object files to an object file. 109 # <name>: Name of the object file to create. No grist will be added. 110 # <sources>: Sources to be compiled. Grist will be added. 111 # <extra CFLAGS>: Additional flags for compilation. 112 # <other objects>: Object files or static libraries to be merged. No grist 113 # will be added. 114 # 115 116 SetupKernel $(2) : $(3) ; 117 Objects $(2) ; 118 MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 119} 120 121rule KernelStaticLibrary 122{ 123 # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 124 # This is designed to take a set of sources and libraries and create 125 # a file called lib<name>.a 126 127 SetupKernel $(2) : $(3) ; 128 Library $(1) : $(2) ; 129} 130 131rule KernelStaticLibraryObjects 132{ 133 # Usage KernelStaticLibrary <name> : <sources> ; 134 # This is designed to take a set of sources and libraries and create 135 # a file called <name> 136 137 # Show that we depend on the libraries we need 138 SetupKernel $(2) ; 139 LocalClean clean : $(1) ; 140 LocalDepends all : $(1) ; 141 Depends $(1) : $(2) ; 142 143 MakeLocateDebug $(1) ; 144} 145 146actions KernelStaticLibraryObjects 147{ 148 $(HAIKU_AR) -r "$(1)" "$(2)" ; 149} 150