1SubDir HAIKU_TOP src system boot ; 2 3SetupFeatureObjectsDir $(TARGET_BOOT_PLATFORM) ; 4 5DEFINES += _BOOT_MODE ; 6 7if $(TARGET_ARCH) = x86_64 && $(TARGET_BOOT_PLATFORM) = efi { 8 SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) libroot os arch 9 x86_64 ] ; 10} else { 11 SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) libroot os arch 12 $(TARGET_KERNEL_ARCH) ] ; 13} 14 15SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) libroot posix string ] ; 16SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) libroot posix stdlib ] ; 17SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) libroot posix locale ] ; 18SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) kernel lib ] ; 19 20UsePrivateHeaders [ FDirName libroot locale ] ; 21 22local extraSources = ; 23if $(TARGET_GCC_VERSION_$(TARGET_PACKAGING_ARCH)[1]) = 2 { 24 extraSources += atomic.S ; 25} 26 27BootMergeObject boot_libroot.o : 28 abs.c 29 ctype.cpp 30 LocaleData.cpp 31 qsort.c 32 kernel_vsprintf.cpp 33 memchr.c 34 memcmp.c 35 memmove.c 36 strdup.cpp 37 strndup.cpp 38 strlen.cpp 39 strnlen.cpp 40 strcmp.c 41 strcasecmp.c 42 strncmp.c 43 strcat.c 44 strcpy.c 45 strerror.c 46 strlcat.c 47 strlcpy.c 48 strchr.c 49 strrchr.c 50 strtol.c 51 strtoul.c 52 $(extraSources) 53; 54 55AddResources haiku_loader : boot_loader.rdef ; 56 57BootLd boot_loader_$(TARGET_BOOT_PLATFORM) : 58 boot_platform_$(TARGET_BOOT_PLATFORM).o 59 boot_arch_$(TARGET_KERNEL_ARCH).o 60 boot_loader.a 61 boot_net.a 62 boot_partitions.a 63 64 # file systems 65 boot_bfs.a 66 boot_amiga_ffs.a 67 boot_tarfs.a 68 boot_fatfs.a 69 boot_packagefs.a 70 71 boot_loader.a 72 # a second time, so undefined references in the file systems can be 73 # resolved 74 75 # needed by tarfs, packagefs, and video_splash.cpp 76 boot_zlib.a 77 78 # libroot functions needed by the stage2 boot loader 79 boot_libroot.o 80 81 : $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/boot_loader_$(TARGET_BOOT_PLATFORM).ld 82 : $(TARGET_BOOT_LDFLAGS) 83; 84 85rule BuildCoffLoader { 86 local coffLoader = $(1) ; 87 local bootLoader = $(2) ; 88 # XXX: eventually switch on arch 89 COFF_FORMAT on $(coffLoader) = xcoff-powermac ; 90 HACK_COFF on $(coffLoader) = <build>hack-coff ; 91 92 Depends $(coffLoader) : <build>hack-coff ; 93 Depends $(coffLoader) : $(bootLoader) ; 94 MakeLocateDebug $(coffLoader) ; 95} 96 97actions BuildCoffLoader bind HACK_COFF { 98 rm -f $(1) 99 # get the address of the COFF entry 100 $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O symbolsrec $(2) $(2).syms 101 EP=`grep _coff_start $(2).syms | tr -d '\r' | cut -d'$' -f2` 102 rm -f $(2).syms 103 # copy to XCOFF format and patch the entry point 104 $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(COFF_FORMAT) --set-start="0x${EP}" $(2) $(1) 105 #$(CP) $(2) $(1) 106 # fill-in some fields objcopy missed 107 $(HACK_COFF) $(1) 108} 109 110BuildCoffLoader boot_loader_$(TARGET_BOOT_PLATFORM)_coff : boot_loader_$(TARGET_BOOT_PLATFORM) ; 111 112rule BuildBiosLoader { 113 local haikuLoader = $(1) ; 114 local bootLoader = $(2) ; 115 116 Depends $(haikuLoader) : $(bootLoader) ; 117 MakeLocateDebug $(haikuLoader) ; 118 119 on $(1) ResAttr $(1) : $(RESFILES) : false ; 120 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] { 121 SetType $(1) ; 122 MimeSet $(1) ; 123 } 124} 125 126actions BuildBiosLoader { 127 rm -f $(1) 128 $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O binary $(2) $(1) 129} 130 131BuildBiosLoader haiku_loader : boot_loader_$(TARGET_BOOT_PLATFORM) ; 132 133# different target for PXE, to be build with TARGET_BOOT_PLATFORM=pxe_ia32 jam pxehaiku-loader 134BuildBiosLoader pxehaiku-loader : boot_loader_$(TARGET_BOOT_PLATFORM) ; 135 136rule BuildEFILoader { 137 local efiLoader = $(1) ; 138 local bootLoader = $(2) ; 139 140 Depends $(efiLoader) : $(bootLoader) ; 141 MakeLocateDebug $(efiLoader) ; 142} 143 144actions BuildEFILoader { 145 rm -f $(1) 146 $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ 147 -j .rel -j .rela -j .reloc --target=efi-app-x86_64 $(2) $(1) 148} 149 150BuildEFILoader haiku_loader.efi : boot_loader_$(TARGET_BOOT_PLATFORM) ; 151 152SubInclude HAIKU_TOP src system boot arch $(TARGET_KERNEL_ARCH) ; 153SubInclude HAIKU_TOP src system boot loader ; 154SubInclude HAIKU_TOP src system boot platform ; 155