# BeOS specific rules rule AddFileDataAttribute target : attrName : attrType : dataFile { # AddFileAttribute : : : ; # Adds a single attribute to a file, retrieving the attribute data from # a separate file. # : The file to which the attribute shall be added. # : The name of the attribute. # : Attribute type as supported by addattr (string, int, etc.) # : The data to be written to the attribute will be read from # that file. # Note that this is supposed to be a build target, not a path # name - if you need to add a data file in a different path, # you have to locate it first. # # We need to create a temporary file in which we store the attribute name # and type. Otherwise we wouldn't have these data available in the # addattr actions. local id = [ NextID ] ; local attrMetaFile = [ FGristFiles $(target:G=)-attr-$(attrName)-$(attrType)-$(id) ] ; ATTRIBUTE_NAME on $(attrMetaFile) = $(attrName) ; ATTRIBUTE_TYPE on $(attrMetaFile) = $(attrType) ; MakeLocateCommonPlatform $(attrMetaFile) ; CreateAttributeMetaFile $(attrMetaFile) ; Depends $(target) : addattr $(attrMetaFile) $(dataFile) ; AddFileDataAttribute1 $(target) : addattr $(attrMetaFile) $(dataFile) ; } actions CreateAttributeMetaFile { echo "-t $(ATTRIBUTE_TYPE)" "$(ATTRIBUTE_NAME)" > "$(1)" } actions AddFileDataAttribute1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) -f $(2[3]) `cat $(2[2])` $(1) } rule AddStringDataResource { # AddStringDataResource : : # Adds a single resource to the resources of an executable/library. # : The executable/library. # : A resource ID string as understood by xres (type:id[:name]). # : The string will be written to the resource. # Defaults to "". # local target = $(1) ; local resourceID = $(2) ; local dataString = $(3:E="") ; # the resource file local resources = [ FGristFiles $(target:B)-added-string-data-resources.rsrc ] ; # add the resource file to the target, if not yet done if ! [ on $(resources) return $(RESOURCES_ADDED) ] { RESOURCES_ADDED on $(resources) = true ; MakeLocateArch $(resources) ; Depends $(resources) : xres ; AddStringDataResource1 $(resources) : xres ; AddResources $(target) : $(resources) ; } RESOURCE_STRINGS on $(resources) += "-a "$(resourceID)" -s \""$(dataString)"\"" ; } actions together AddStringDataResource1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) -o "$(1)" $(RESOURCE_STRINGS) } rule AddFileDataResource { # AddFileDataResource : : [ ] # Adds a single resource to the resources of an executable/library. # : The executable/library. # : A resource ID string as understood by xres (type:id[:name]). # : The data to be written into the resource will be read from # that file. # Note that this is supposed to be a build target, not a path # name - if you need to add a data file in a different path, you # have to locate it first. # local target = $(1) ; local resourceID = $(2) ; local dataFile = $(3) ; # the resource file local resources = file-data-$(resourceID)-$(dataFile).rsrc ; # add it to the resources of the given target AddResources $(target) : $(resources) ; # if the rule for creating the resource file has not been invoked yet, do it if ! [ on $(resources) return $(RESOURCES_DEFINED) ] { RESOURCES_DEFINED on $(resources) = true ; RESOURCE_ID on $(resources) = $(resourceID) ; MakeLocateArch $(resources) ; Depends $(resources) : xres $(dataFile) ; AddFileDataResource1 $(resources) : xres $(dataFile) ; } } actions AddFileDataResource1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) -o "$(1)" -a "$(RESOURCE_ID)" "$(2[2])" ; } rule XRes { # XRes : if $(2) { Depends $(1) : xres $(2) ; XRes1 $(1) : xres $(2) ; } } actions XRes1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) -o "$(1)" "$(2[2-])" } rule SetVersion { # SetVersion Depends $(1) : setversion ; SetVersion1 $(1) : setversion ; } actions SetVersion1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) "$(1)" -system $(HAIKU_BUILD_VERSION) -short "$(HAIKU_BUILD_DESCRIPTION)" } rule SetType target : type { # SetType [ : ] # Sets the MIME type on the target. If none is given, the executable MIME # type is used. TARGET_MIME_TYPE on $(target) = $(type:E=$(TARGET_EXECUTABLE_MIME_TYPE)) ; Depends $(target) : settype ; SetType1 $(target) : settype ; } actions SetType1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) -t $(TARGET_MIME_TYPE) "$(1)" } rule MimeSet target { # MimeSet ; Depends $(target) : mimeset mime_db ; MimeSet1 $(target) : mimeset mime_db ; } actions MimeSet1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) \ $(2[1]) -f --mimedb "$(2[2])" "$(1)" } rule CreateAppMimeDBEntries target { # MimeSetApp ; # Create the app meta MIME DB entries for the given target. The # HAIKU_MIME_DB_ENTRIES variable on is set to the generated # resulting target directory that contains the MIME DB entries. local appGrist = $(target:G) ; local appMimeDB = $(target:BS)_mimedb ; appMimeDB = $(appMimeDB:G=mimedb-app-$(appGrist:E=)) ; MakeLocateDebug $(appMimeDB) ; Depends $(appMimeDB) : mimeset $(target) mime_db ; CreateAppMimeDBEntries1 $(appMimeDB) : mimeset $(target) mime_db ; HAIKU_MIME_DB_ENTRIES on $(target) = $(appMimeDB) ; } actions CreateAppMimeDBEntries1 { export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) appMimeDB="$(1)" $(RM) -rf "$appMimeDB" $(MKDIR) "$appMimeDB" $(2[1]) -f --apps --mimedb "$appMimeDB" --mimedb "$(2[3])" "$(2[2])" } rule ResComp { # ResComp : ; # # and must be gristed. # get compiler and defines for the platform local cc ; local defines ; local flags ; local localIncludesOption ; on $(1) { # use on $(1) variable values defines = $(DEFINES) ; if $(PLATFORM) = host { defines += $(HOST_DEFINES) ; cc = $(HOST_CC) ; flags += $(HOST_CCFLAGS) ; localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ; } else { defines += $(TARGET_DEFINES_$(TARGET_PACKAGING_ARCH)) $(TARGET_DEFINES) ; cc = $(TARGET_CC_$(TARGET_PACKAGING_ARCH)) ; flags += $(TARGET_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ; localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION_$(TARGET_PACKAGING_ARCH)) ; } } DEFINES on $(1) = $(defines) ; CCDEFS on $(1) = [ FDefines $(defines) ] ; CCFLAGS on $(1) = $(flags) ; HDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) : $(localIncludesOption) ] ; RCHDRS on $(1) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) : "-I " ] ; CC on $(1) = $(cc) ; # set up other vars SEARCH on $(2) += $(SEARCH_SOURCE) ; MakeLocateArch $(1) ; Depends $(1) : $(2) rc ; LocalClean clean : $(1) ; ResComp1 $(1) : rc $(2) ; } # Note: We pipe the input files into the preprocessor, since *.rdef files are # considered linker scripts, and thus we can use preprocessor features. actions ResComp1 { export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) cat "$(2[2-])" | $(CC) $(CCFLAGS) -E $(CCDEFS) $(HDRS) - \ | grep -E -v '^#' | $(2[1]) $(RCHDRS) --auto-names -o "$(1)" - } rule ResAttr attributeFile : _resourceFiles : deleteAttributeFile { # ResAttr : [ : ] ; # # and must be gristed. # can also be .rdef files -- they will be compiled first in # this case. # is a boolean that specifies wether or not the target file # should be removed before writing. Defaults to true. local resourceFiles ; local resourceFile ; deleteAttributeFile ?= true ; deleteAttributeFile1 on $(1) = $(deleteAttributeFile) ; for resourceFile in $(_resourceFiles) { # if the specified resource file is an .rdef file, we compile it first if $(resourceFile:S) = ".rdef" { local rdefFile = $(resourceFile) ; resourceFile = $(rdefFile:S=.rsrc) ; ResComp $(resourceFile) : $(rdefFile) ; } else { SEARCH on $(resourceFile) += $(SEARCH_SOURCE) ; } resourceFiles += $(resourceFile) ; } MakeLocateArch $(attributeFile) ; Depends $(attributeFile) : $(resourceFiles) resattr ; LocalClean clean : $(attributeFile) ; ResAttr1 $(attributeFile) : resattr $(resourceFiles) ; } actions ResAttr1 { export $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) if [ \\"$(deleteAttributeFile1)\\" = "true" ]; then $(RM) $(1) fi $(2[1]) -O -o "$(1)" "$(2[2-])" }