1rule MultiBootSubDirSetup bootTargets 2{ 3 local result ; 4 local bootTarget ; 5 bootTargets ?= $(HAIKU_BOOT_TARGETS) ; 6 for bootTarget in $(bootTargets) { 7 local bootTargetObject = $(bootTarget:G=<boot-target-object>) ; 8 result += $(bootTargetObject) ; 9 10 TARGET_BOOT_PLATFORM on $(bootTargetObject) = $(bootTarget) ; 11 12 SOURCE_GRIST on $(bootTargetObject) 13 = $(SOURCE_GRIST:E=)!$(bootTarget) ; 14 15 HDRGRIST on $(bootTargetObject) 16 = $(HDRGRIST:E=)!$(bootTarget) ; 17 18 local var ; 19 for var in TARGET_ARCH { 20 $(var) on $(architectureObject) = $($(var)_$(architecture)) ; 21 } 22 23 # Clone the current config variable values and the variables SubDir 24 # resets. 25 for var in $(AUTO_SET_UP_CONFIG_VARIABLES) SUBDIR$(SUBDIRRESET) { 26 $(var) on $(architectureObject) = $($(var)) ; 27 } 28 29 local hostTarget = HOST TARGET ; 30 local objectDirVars = 31 COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS) 32 ; 33 objectDirVars = 34 COMMON_PLATFORM_LOCATE_TARGET 35 $(hostTarget)_$(objectDirVars)_LOCATE_TARGET 36 LOCATE_TARGET 37 LOCATE_SOURCE 38 SEARCH_SOURCE 39 ; 40 41 for var in $(objectDirVars) { 42 $(var) on $(bootTargetObject) = ; 43 } 44 45 on $(bootTargetObject) { 46 SetupObjectsDir ; 47 SetupFeatureObjectsDir $(bootTarget) ; 48 49 for var in $(objectDirVars) { 50 $(var) on $(bootTargetObject) = $($(var)) ; 51 } 52 } 53 } 54 55 return $(result) ; 56} 57 58rule MultiBootGristFiles files 59{ 60 return $(files:G=$(TARGET_BOOT_PLATFORM)) ; 61} 62 63rule SetupBoot 64{ 65 # Usage SetupBoot <sources_or_objects> : <extra_cc_flags> : <include_private_headers> ; 66 # 67 # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be 68 # set for the sources and the sources some header 69 # dependencies might be missing. 70 71 local sources = [ FGristFiles $(1) ] ; 72 local objects = $(sources:S=$(SUFOBJ)) ; 73 74 # add private kernel headers 75 if $(3) != false { 76 SourceSysHdrs $(sources) : $(TARGET_PRIVATE_KERNEL_HEADERS) ; 77 } 78 79 if $(HAIKU_BOOT_C++_HEADERS_DIR_$(TARGET_KERNEL_ARCH)) { 80 SourceSysHdrs $(sources) : 81 $(HAIKU_BOOT_C++_HEADERS_DIR_$(TARGET_KERNEL_ARCH)) ; 82 } 83 84 # MultiBootSubDirSetup sets the target boot platform on the target object, 85 # so this will be correct here in SetupBoot. 86 # This does mean, however, that MultiBootSubDirSetup needs to be used in 87 # all Jamfiles for things to work correctly. 88 # Also means ArchitectureRules need to use platform specific variables, 89 # rather than the previously generic TARGET_BOOT_CCFLAGS and friends. 90 local platform = $(TARGET_BOOT_PLATFORM:U) ; 91 local object ; 92 for object in $(objects) { 93 TARGET_PACKAGING_ARCH on $(object) = $(TARGET_KERNEL_ARCH) ; 94 95 # add boot flags for the object 96 ObjectCcFlags $(object) : $(HAIKU_BOOT_CCFLAGS) $(HAIKU_BOOT_$(platform)_CCFLAGS) $(2) ; 97 ObjectC++Flags $(object) : $(HAIKU_BOOT_C++FLAGS) $(HAIKU_BOOT_$(platform)_C++FLAGS) $(2) ; 98 ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ; 99 ASFLAGS on $(object) = $(HAIKU_BOOT_CCFLAGS) $(HAIKU_BOOT_$(platform)_CCFLAGS) ; 100 101 # override regular CCFLAGS/C++FLAGS, as we don't want them 102 TARGET_CCFLAGS_$(TARGET_KERNEL_ARCH) on $(object) = ; 103 TARGET_C++FLAGS_$(TARGET_KERNEL_ARCH) on $(object) = ; 104 105 # override warning flags 106 TARGET_WARNING_CCFLAGS_$(TARGET_KERNEL_ARCH) on $(object) 107 = $(TARGET_KERNEL_WARNING_CCFLAGS) ; 108 TARGET_WARNING_C++FLAGS_$(TARGET_KERNEL_ARCH) on $(object) 109 = $(TARGET_KERNEL_WARNING_C++FLAGS) ; 110 } 111} 112 113rule BootObjects 114{ 115 SetupBoot $(1) : $(2) ; 116 Objects $(1) ; 117} 118 119rule BootLd 120{ 121 # BootLd <name> : <objs> : <linkerscript> : <args> ; 122 123 LINK on $(1) = $(TARGET_LD_$(TARGET_KERNEL_ARCH)) ; 124 125 LINKFLAGS on $(1) = $(HAIKU_BOOT_$(TARGET_BOOT_PLATFORM:U)_LDFLAGS) $(4) ; 126 if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 127 128 # Remove any preset LINKLIBS, but link against libgcc.a. Linking against 129 # libsupc++ is opt-out. 130 local libs ; 131 if ! [ on $(1) return $(HAIKU_NO_LIBSUPC++) ] { 132 libs += [ TargetBootLibsupc++ true ] ; 133 Depends $(1) : [ TargetBootLibsupc++ ] ; 134 } 135 LINKLIBS on $(1) = $(libs) [ TargetBootLibgcc $(TARGET_KERNEL_ARCH) : true ] ; 136 Depends $(1) : [ TargetBootLibgcc $(TARGET_KERNEL_ARCH) ] ; 137 138 # TODO: Do we really want to invoke SetupBoot here? The objects should 139 # have been compiled with BootObjects anyway, so we're doing that twice. 140 SetupBoot $(2) ; 141 142 # Show that we depend on the libraries we need 143 LocalClean clean : $(1) ; 144 LocalDepends all : $(1) ; 145 Depends $(1) : $(2) ; 146 147 MakeLocateDebug $(1) ; 148 149 on $(1) XRes $(1) : $(RESFILES) ; 150 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] { 151 SetType $(1) ; 152 MimeSet $(1) ; 153 SetVersion $(1) ; 154 } 155} 156 157actions BootLd bind VERSION_SCRIPT 158{ 159 $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \ 160 --version-script=$(VERSION_SCRIPT) 161} 162 163rule BootMergeObject 164{ 165 # BootMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 166 # Compiles source files and merges the object files to an object file. 167 # <name>: Name of the object file to create. No grist will be added. 168 # <sources>: Sources to be compiled. Grist will be added. 169 # <extra CFLAGS>: Additional flags for compilation. 170 # <other objects>: Object files or static libraries to be merged. No grist 171 # will be added. 172 # 173 174 SetupBoot $(2) : $(3) ; 175 Objects $(2) ; 176 MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 177 LINKFLAGS on $(1) += $(HAIKU_BOOT_$(TARGET_BOOT_PLATFORM:U)_LDFLAGS) ; 178} 179 180rule BootStaticLibrary 181{ 182 # Usage BootStaticLibrary <name> : <sources> : <extra cc flags> ; 183 # This is designed to take a set of sources and libraries and create 184 # a file called lib<name>.a 185 186 SetupBoot $(2) : $(3) : false ; 187 Library $(1) : $(2) ; 188} 189 190rule BootStaticLibraryObjects 191{ 192 # Usage BootStaticLibrary <name> : <sources> ; 193 # This is designed to take a set of sources and libraries and create 194 # a file called <name> 195 196 # Show that we depend on the libraries we need 197 SetupBoot $(2) ; 198 LocalClean clean : $(1) ; 199 LocalDepends all : $(1) ; 200 Depends $(1) : $(2) ; 201 202 MakeLocateDebug $(1) ; 203} 204 205actions BootStaticLibraryObjects 206{ 207 # Force recreation of the archive to avoid build errors caused by 208 # stale dependencies after renaming or deleting object files. 209 $(RM) "$(1)" 210 $(HAIKU_AR_$(TARGET_KERNEL_ARCH)) -r "$(1)" "$(2)" ; 211} 212 213rule BuildMBR binary : source 214{ 215 SEARCH on $(source) = $(SUBDIR) ; 216 MakeLocateDebug $(binary) ; 217 Depends $(binary) : $(source) ; 218} 219 220actions BuildMBR 221{ 222 $(RM) $(1) 223 $(HAIKU_CC_$(HAIKU_PACKAGING_ARCH)) $(HAIKU_LINKFLAGS_$(HAIKU_PACKAGING_ARCH)) \ 224 $(2) -o $(1) $(MBRFLAGS) -nostdlib -m32 -Wl,--oformat,binary -Wl,-z,notext \ 225 -Xlinker -S -Xlinker -N -Xlinker --entry=start -Xlinker -Ttext=0x600 226} 227