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