1 2rule SetupBoot 3{ 4 # Usage SetupBoot <sources_or_objects> : <extra_cc_flags> : <include_private_headers> ; 5 # 6 # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be 7 # set for the sources and the sources some header 8 # dependencies might be missing. 9 10 local sources = [ FGristFiles $(1) ] ; 11 local objects = $(sources:S=$(SUFOBJ)) ; 12 13 # add private kernel headers 14 if $(3) != false { 15 SourceSysHdrs $(sources) : $(TARGET_PRIVATE_KERNEL_HEADERS) ; 16 } 17 18 local object ; 19 for object in $(objects) { 20 # add boot flags for the object 21 ObjectCcFlags $(object) : $(TARGET_BOOT_CCFLAGS) $(2) ; 22 ObjectC++Flags $(object) : $(TARGET_BOOT_C++FLAGS) $(2) ; 23 ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ; 24 ASFLAGS on $(object) = $(TARGET_BOOT_CCFLAGS) ; 25 26 # override warning flags 27 TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH) on $(object) 28 = $(TARGET_KERNEL_WARNING_CCFLAGS) ; 29 TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) on $(object) 30 = $(TARGET_KERNEL_WARNING_C++FLAGS) ; 31 } 32} 33 34rule BootObjects 35{ 36 SetupBoot $(1) : $(2) ; 37 Objects $(1) ; 38} 39 40rule BootLd 41{ 42 # BootLd <name> : <objs> : <linkerscript> : <args> ; 43 44 LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ; 45 46 LINKFLAGS on $(1) = $(4) ; 47 if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 48 49 # Remove any preset LINKLIBS, but link against libgcc.a. Linking against 50 # libsupc++ is opt-out. 51 local libs ; 52 if ! [ on $(1) return HAIKU_NO_LIBSUPC++ ] { 53 libs += $(TARGET_BOOT_LIBSUPC++) ; 54 } 55 LINKLIBS on $(1) = $(libs) $(TARGET_BOOT_LIBGCC) ; 56 57 # TODO: Do we really want to invoke SetupBoot here? The objects should 58 # have been compiled with BootObjects anyway, so we're doing that twice. 59 SetupBoot $(2) ; 60 61 # Show that we depend on the libraries we need 62 LocalClean clean : $(1) ; 63 LocalDepends all : $(1) ; 64 Depends $(1) : $(2) ; 65 66 MakeLocateDebug $(1) ; 67 68 on $(1) XRes $(1) : $(RESFILES) ; 69 if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] { 70 SetType $(1) ; 71 MimeSet $(1) ; 72 SetVersion $(1) ; 73 } 74} 75 76actions BootLd bind VERSION_SCRIPT 77{ 78 $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \ 79 --version-script=$(VERSION_SCRIPT) 80} 81 82rule BootMergeObject 83{ 84 # BootMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 85 # Compiles source files and merges the object files to an object file. 86 # <name>: Name of the object file to create. No grist will be added. 87 # <sources>: Sources to be compiled. Grist will be added. 88 # <extra CFLAGS>: Additional flags for compilation. 89 # <other objects>: Object files or static libraries to be merged. No grist 90 # will be added. 91 # 92 93 SetupBoot $(2) : $(3) ; 94 Objects $(2) ; 95 MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 96 LINKFLAGS on $(1) += $(TARGET_BOOT_LINKFLAGS) ; 97} 98 99rule BootStaticLibrary 100{ 101 # Usage BootStaticLibrary <name> : <sources> : <extra cc flags> ; 102 # This is designed to take a set of sources and libraries and create 103 # a file called lib<name>.a 104 105 SetupBoot $(2) : $(3) : false ; 106 Library $(1) : $(2) ; 107} 108 109rule BootStaticLibraryObjects 110{ 111 # Usage BootStaticLibrary <name> : <sources> ; 112 # This is designed to take a set of sources and libraries and create 113 # a file called <name> 114 115 # Show that we depend on the libraries we need 116 SetupBoot $(2) ; 117 LocalClean clean : $(1) ; 118 LocalDepends all : $(1) ; 119 Depends $(1) : $(2) ; 120 121 MakeLocateDebug $(1) ; 122} 123 124actions BootStaticLibraryObjects 125{ 126 # Force recreation of the archive to avoid build errors caused by 127 # stale dependencies after renaming or deleting object files. 128 $(RM) "$(1)" 129 $(HAIKU_AR_$(TARGET_PACKAGING_ARCH)) -r "$(1)" "$(2)" ; 130} 131