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