3 rule AddFileDataAttribute target : attrName : attrType : dataFile
5 # AddFileAttribute <target> : <attrName> : <attrType> : <dataFile> ;
6 # Adds a single attribute to a file, retrieving the attribute data from
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
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.
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
21 local id = [ NextID ] ;
23 = [ FGristFiles $(target:G=)-attr-$(attrName)-$(attrType)-$(id) ] ;
25 ATTRIBUTE_NAME on $(attrMetaFile) = $(attrName) ;
26 ATTRIBUTE_TYPE on $(attrMetaFile) = $(attrType) ;
27 MakeLocateArch $(attrMetaFile) ;
28 CreateAttributeMetaFile $(attrMetaFile) ;
30 Depends $(target) : <build>addattr $(attrMetaFile) $(dataFile) ;
31 AddFileDataAttribute1 $(target)
32 : <build>addattr $(attrMetaFile) $(dataFile) ;
35 actions CreateAttributeMetaFile
37 echo "-t $(ATTRIBUTE_TYPE)" "$(ATTRIBUTE_NAME)" > "$(1)"
40 actions AddFileDataAttribute1
42 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
43 $(2[1]) -f $(2[3]) `cat $(2[2])` $(1)
46 rule AddStringDataResource
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.
56 local resourceID = $(2) ;
57 local dataString = $(3:E="") ;
61 = [ FGristFiles $(target:B)-added-string-data-resources.rsrc ] ;
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) ;
72 RESOURCE_STRINGS on $(resources)
73 += "-a "$(resourceID)" -s \""$(dataString)"\"" ;
76 actions together AddStringDataResource1
78 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
79 $(2[1]) -o "$(1)" $(RESOURCE_STRINGS)
82 rule AddFileDataResource
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
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.
95 local resourceID = $(2) ;
96 local dataFile = $(3) ;
100 = <added-resources>file-data-$(resourceID)-$(dataFile).rsrc ;
102 # add it to the resources of the given target
103 AddResources $(target) : $(resources) ;
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) ;
111 Depends $(resources) : <build>xres $(dataFile) ;
112 AddFileDataResource1 $(resources) : <build>xres $(dataFile) ;
116 actions AddFileDataResource1
118 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
119 $(2[1]) -o "$(1)" -a "$(RESOURCE_ID)" "$(2[2])" ;
124 # XRes <target> : <resource files>
127 Depends $(1) : <build>xres $(2) ;
128 XRes1 $(1) : <build>xres $(2) ;
134 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
135 $(2[1]) -o "$(1)" "$(2[2-])" ;
140 # SetVersion <target>
142 Depends $(1) : <build>setversion ;
143 SetVersion1 $(1) : <build>setversion ;
148 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
149 $(2[1]) "$(1)" -system $(HAIKU_BUILD_VERSION) -short "$(HAIKU_BUILD_DESCRIPTION)" ;
152 rule SetType target : type
154 # SetType <target> [ : <type> ]
155 # Sets the MIME type on the target. If none is given, the executable MIME
158 TARGET_MIME_TYPE on $(target) = $(type:E=$(TARGET_EXECUTABLE_MIME_TYPE)) ;
160 Depends $(target) : <build>settype ;
161 SetType1 $(target) : <build>settype ;
166 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
167 $(2[1]) -t $(TARGET_MIME_TYPE) "$(1)" ;
174 Depends $(target) : <build>mimeset <mimedb>mime_db ;
175 MimeSet1 $(target) : <build>mimeset <mimedb>mime_db ;
181 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
182 $(2[1]) -f --mimedb "$(2[2])" "$(1)"
186 rule CreateAppMimeDBEntries target
188 # MimeSetApp <target> ;
189 # Create the app meta MIME DB entries for the given target. The
190 # HAIKU_MIME_DB_ENTRIES variable on <target> is set to the generated
191 # resulting target directory that contains the MIME DB entries.
193 local appGrist = $(target:G) ;
194 local appMimeDB = $(target:BS)_mimedb ;
195 appMimeDB = $(appMimeDB:G=mimedb-app-$(appGrist:E=)) ;
196 MakeLocateDebug $(appMimeDB) ;
197 Depends $(appMimeDB) : <build>mimeset $(target) <mimedb>mime_db ;
198 CreateAppMimeDBEntries1 $(appMimeDB)
199 : <build>mimeset $(target) <mimedb>mime_db ;
201 HAIKU_MIME_DB_ENTRIES on $(target) = $(appMimeDB) ;
205 actions CreateAppMimeDBEntries1
207 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
210 $(RM) -rf "$appMimeDB"
211 $(MKDIR) "$appMimeDB"
212 $(2[1]) -f --apps --mimedb "$appMimeDB" --mimedb "$(2[3])" "$(2[2])"
218 # ResComp <resource file> : <rdef file> ;
220 # <resource file> and <rdef file> must be gristed.
222 # get compiler and defines for the platform
225 local localIncludesOption ;
227 on $(1) { # use on $(1) variable values
228 defines = $(DEFINES) ;
230 if $(PLATFORM) = host {
231 defines += $(HOST_DEFINES) ;
233 localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ;
235 defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH))
237 cc = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ;
239 = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ;
243 DEFINES on $(1) = $(defines) ;
244 CCDEFS on $(1) = [ FDefines $(defines) ] ;
245 HDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS)
246 : $(localIncludesOption) ] ;
247 RCHDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS)
252 SEARCH on $(2) += $(SEARCH_SOURCE) ;
253 MakeLocateArch $(1) ;
254 Depends $(1) : $(2) <build>rc ;
255 LocalClean clean : $(1) ;
256 ResComp1 $(1) : <build>rc $(2) ;
259 # Note: We pipe the input files into the preprocessor, since *.rdef files are
260 # considered linker scripts, and thus we can use preprocessor features.
263 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
264 cat "$(2[2-])" | $(CC) -E $(CCDEFS) $(HDRS) - | egrep -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o "$(1)" -
267 rule ResAttr attributeFile : _resourceFiles : deleteAttributeFile
269 # ResAttr <attribute file> : <resource files> [ : <delete file> ] ;
271 # <attribute file> and <resource files> must be gristed.
272 # <resource files> can also be .rdef files -- they will be compiled first in
274 # <clear file> is a boolean that specifies wether or not the target file
275 # should be removed before writing. Defaults to true.
277 local resourceFiles ;
279 deleteAttributeFile ?= true ;
280 deleteAttributeFile1 on $(1) = $(deleteAttributeFile) ;
282 for resourceFile in $(_resourceFiles) {
283 # if the specified resource file is an .rdef file, we compile it first
284 if $(resourceFile:S) = ".rdef" {
285 local rdefFile = $(resourceFile) ;
286 resourceFile = $(rdefFile:S=.rsrc) ;
287 ResComp $(resourceFile) : $(rdefFile) ;
289 SEARCH on $(resourceFile) += $(SEARCH_SOURCE) ;
292 resourceFiles += $(resourceFile) ;
295 MakeLocateArch $(attributeFile) ;
296 Depends $(attributeFile) : $(resourceFiles) <build>resattr ;
297 LocalClean clean : $(attributeFile) ;
298 ResAttr1 $(attributeFile) : <build>resattr $(resourceFiles) ;
303 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
304 if [ \\"$(deleteAttributeFile1)\\" = "true" ]; then
307 $(2[1]) -O -o "$(1)" "$(2[2-])"