1# BeOS specific rules 2 3 4rule AddStringDataResource 5{ 6 # AddStringDataResource <target> : <resourceID> : <dataString> 7 # Adds a single resource to the resources of an executable/library. 8 # <target>: The executable/library. 9 # <resourceID>: A resource ID string as understood by xres (type:id[:name]). 10 # <dataString>: The string <dataString> will be written to the resource. 11 # Defaults to "". 12 # 13 local target = $(1) ; 14 local resourceID = $(2) ; 15 local dataString = $(3:E="") ; 16 17 # the resource file 18 local resources 19 = [ FGristFiles $(target:B)-added-string-data-resources.rsrc ] ; 20 21 # add the resource file to the target, if not yet done 22 if ! [ on $(resources) return $(RESOURCES_ADDED) ] { 23 RESOURCES_ADDED on $(resources) = true ; 24 MakeLocateArch $(resources) ; 25 Depends $(resources) : <build>xres ; 26 AddStringDataResource1 $(resources) : <build>xres ; 27 AddResources $(target) : $(resources) ; 28 } 29 30 RESOURCE_STRINGS on $(resources) 31 += "-a "$(resourceID)" -s \""$(dataString)"\"" ; 32} 33 34actions together AddStringDataResource1 35{ 36 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 37 $(2[1]) -o "$(1)" $(RESOURCE_STRINGS) 38} 39 40 41rule AddFileDataResource 42{ 43 # AddFileDataResource <target> : <resourceID> : [ <dataFile> ] 44 # Adds a single resource to the resources of an executable/library. 45 # <target>: The executable/library. 46 # <resourceID>: A resource ID string as understood by xres (type:id[:name]). 47 # <dataFile>: The data to be written into the resource will be read from 48 # that file. 49 # Note that this is supposed to be a build target, not a path 50 # name - if you need to add a data file in a different path, you 51 # have to locate it first. 52 # 53 local target = $(1) ; 54 local resourceID = $(2) ; 55 local dataFile = $(3) ; 56 57 # the resource file 58 local resources 59 = <added-resources>file-data-$(resourceID)-$(dataFile).rsrc ; 60 61 # add it to the resources of the given target 62 AddResources $(target) : $(resources) ; 63 64 # if the rule for creating the resource file has not been invoked yet, do it 65 if ! [ on $(resources) return $(RESOURCES_DEFINED) ] { 66 RESOURCES_DEFINED on $(resources) = true ; 67 RESOURCE_ID on $(resources) = $(resourceID) ; 68 MakeLocateArch $(resources) ; 69 70 Depends $(resources) : <build>xres $(dataFile) ; 71 AddFileDataResource1 $(resources) : <build>xres $(dataFile) ; 72 } 73} 74 75actions AddFileDataResource1 76{ 77 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 78 $(2[1]) -o "$(1)" -a "$(RESOURCE_ID)" "$(2[2])" ; 79} 80 81rule XRes 82{ 83 # XRes <target> : <resource files> 84 if $(2) 85 { 86 Depends $(1) : <build>xres $(2) ; 87 XRes1 $(1) : <build>xres $(2) ; 88 } 89} 90 91actions XRes1 92{ 93 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 94 $(2[1]) -o "$(1)" "$(2[2-])" ; 95} 96 97rule SetVersion 98{ 99 # SetVersion <target> 100 101 Depends $(1) : <build>setversion ; 102 SetVersion1 $(1) : <build>setversion ; 103} 104 105actions SetVersion1 106{ 107 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 108 $(2[1]) "$(1)" -system $(HAIKU_BUILD_VERSION) -short "$(HAIKU_BUILD_DESCRIPTION)" ; 109} 110 111rule SetType 112{ 113 # SetType <target> 114 115 Depends $(1) : <build>settype ; 116 SetType1 $(1) : <build>settype ; 117} 118 119actions SetType1 120{ 121 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 122 $(2[1]) -t $(TARGET_EXECUTABLE_MIME_TYPE) "$(1)" ; 123} 124 125rule MimeSet 126{ 127 # MimeSet <target> 128 129 Depends $(1) : <build>mimeset ; 130 MimeSet1 $(1) : <build>mimeset ; 131} 132 133actions MimeSet1 134{ 135 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 136 $(2[1]) -f "$(1)" ; 137} 138 139rule ResComp 140{ 141 # ResComp <resource file> : <rdef file> ; 142 # 143 # <resource file> and <rdef file> must be gristed. 144 145 # get compiler and defines for the platform 146 local cc ; 147 local defines ; 148 local localIncludesOption ; 149 150 on $(1) { # use on $(1) variable values 151 defines = $(DEFINES) ; 152 153 if $(PLATFORM) = host { 154 defines += $(HOST_DEFINES) ; 155 cc = $(HOST_CC) ; 156 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ; 157 } else { 158 defines += $(TARGET_DEFINES) ; 159 cc = $(TARGET_CC) ; 160 localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ; 161 } 162 } 163 164 DEFINES on $(1) = $(defines) ; 165 CCDEFS on $(1) = [ FDefines $(defines) ] ; 166 HDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) : $(localIncludesOption) ] ; 167 RCHDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) : "-I " ] ; 168 CC on $(1) = $(cc) ; 169 170 # set up other vars 171 SEARCH on $(2) += $(SEARCH_SOURCE) ; 172 MakeLocateArch $(1) ; 173 Depends $(1) : $(2) <build>rc ; 174 LocalClean clean : $(1) ; 175 ResComp1 $(1) : <build>rc $(2) ; 176} 177 178# Note: We pipe the file into the preprocessor, since *.rdef files are 179# considered linker scripts. 180actions ResComp1 181{ 182 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 183 cat $(2[2]) | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o $(1) - 184} 185