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_PACKAGING_ARCH)) { 80 SourceSysHdrs $(sources) : 81 $(HAIKU_BOOT_C++_HEADERS_DIR_$(TARGET_PACKAGING_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 # add boot flags for the object 94 ObjectCcFlags $(object) : $(HAIKU_BOOT_CCFLAGS) $(HAIKU_BOOT_$(platform)_CCFLAGS) $(2) ; 95 ObjectC++Flags $(object) : $(HAIKU_BOOT_C++FLAGS) $(HAIKU_BOOT_$(platform)_C++FLAGS) $(2) ; 96 ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ; 97 ASFLAGS on $(object) = $(HAIKU_BOOT_CCFLAGS) $(HAIKU_BOOT_$(platform)_CCFLAGS) ; 98 99 # override regular CCFLAGS/C++FLAGS, as we don't want them 100 TARGET_CCFLAGS_$(TARGET_PACKAGING_ARCH) on $(object) = ; 101 TARGET_C++FLAGS_$(TARGET_PACKAGING_ARCH) on $(object) = ; 102 103 # override warning flags 104 TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH) on $(object) 105 = $(TARGET_KERNEL_WARNING_CCFLAGS) ; 106 TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) on $(object) 107 = $(TARGET_KERNEL_WARNING_C++FLAGS) ; 108 } 109} 110 111rule BootObjects 112{ 113 SetupBoot $(1) : $(2) ; 114 Objects $(1) ; 115} 116 117rule BootLd 118{ 119 # BootLd <name> : <objs> : <linkerscript> : <args> ; 120 121 LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ; 122 123 LINKFLAGS on $(1) = $(HAIKU_BOOT_$(TARGET_BOOT_PLATFORM:U)_LDFLAGS) $(4) ; 124 if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 125 126 # Remove any preset LINKLIBS, but link against libgcc.a. Linking against 127 # libsupc++ is opt-out. 128 local libs ; 129 if ! [ on $(1) return $(HAIKU_NO_LIBSUPC++) ] { 130 libs += [ TargetBootLibsupc++ true ] ; 131 Depends $(1) : [ TargetBootLibsupc++ ] ; 132 } 133 LINKLIBS on $(1) = $(libs) [ TargetBootLibgcc true ] ; 134 Depends $(1) : [ TargetBootLibgcc ] ; 135 136 # TODO: Do we really want to invoke SetupBoot here? The objects should 137 # have been compiled with BootObjects anyway, so we're doing that twice. 138 SetupBoot $(2) ; 139 140 # Show that we depend on the libraries we need 141 LocalClean clean : $(1) ; 142 LocalDepends all : $(1) ; 143 Depends $(1) : $(2) ; 144 145 MakeLocateDebug $(1) ; 146 147 on $(1) XRes $(1) : $(RESFILES) ; 148 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] { 149 SetType $(1) ; 150 MimeSet $(1) ; 151 SetVersion $(1) ; 152 } 153} 154 155actions BootLd bind VERSION_SCRIPT 156{ 157 $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \ 158 --version-script=$(VERSION_SCRIPT) 159} 160 161rule BootMergeObject 162{ 163 # BootMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 164 # Compiles source files and merges the object files to an object file. 165 # <name>: Name of the object file to create. No grist will be added. 166 # <sources>: Sources to be compiled. Grist will be added. 167 # <extra CFLAGS>: Additional flags for compilation. 168 # <other objects>: Object files or static libraries to be merged. No grist 169 # will be added. 170 # 171 172 SetupBoot $(2) : $(3) ; 173 Objects $(2) ; 174 MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 175 LINKFLAGS on $(1) += $(HAIKU_BOOT_$(TARGET_BOOT_PLATFORM:U)_LDFLAGS) ; 176} 177 178rule BootStaticLibrary 179{ 180 # Usage BootStaticLibrary <name> : <sources> : <extra cc flags> ; 181 # This is designed to take a set of sources and libraries and create 182 # a file called lib<name>.a 183 184 SetupBoot $(2) : $(3) : false ; 185 Library $(1) : $(2) ; 186} 187 188rule BootStaticLibraryObjects 189{ 190 # Usage BootStaticLibrary <name> : <sources> ; 191 # This is designed to take a set of sources and libraries and create 192 # a file called <name> 193 194 # Show that we depend on the libraries we need 195 SetupBoot $(2) ; 196 LocalClean clean : $(1) ; 197 LocalDepends all : $(1) ; 198 Depends $(1) : $(2) ; 199 200 MakeLocateDebug $(1) ; 201} 202 203actions BootStaticLibraryObjects 204{ 205 # Force recreation of the archive to avoid build errors caused by 206 # stale dependencies after renaming or deleting object files. 207 $(RM) "$(1)" 208 $(HAIKU_AR_$(TARGET_PACKAGING_ARCH)) -r "$(1)" "$(2)" ; 209} 210 211rule BuildMBR binary : source 212{ 213 SEARCH on $(source) = $(SUBDIR) ; 214 MakeLocateDebug $(binary) ; 215 Depends $(binary) : $(source) ; 216} 217 218actions BuildMBR 219{ 220 $(RM) $(1) 221 $(HAIKU_CC_$(HAIKU_PACKAGING_ARCH)) $(HAIKU_LINKFLAGS_$(HAIKU_PACKAGING_ARCH)) \ 222 $(2) -o $(1) $(MBRFLAGS) -nostdlib -m32 -Wl,--oformat,binary -Wl,-z,notext \ 223 -Xlinker -S -Xlinker -N -Xlinker --entry=start -Xlinker -Ttext=0x600 224} 225