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