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