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