rule SetupObjectsDir { local relPath = [ FDirName $(SUBDIR_TOKENS[2-]) ] ; COMMON_PLATFORM_LOCATE_TARGET = [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) $(relPath) ] ; local var ; for var in COMMON_ARCH COMMON_DEBUG DEBUG_$(HAIKU_DEBUG_LEVELS) { HOST_$(var)_LOCATE_TARGET = [ FDirName $(HOST_$(var)_OBJECT_DIR) $(relPath) ] ; TARGET_$(var)_LOCATE_TARGET = [ FDirName $(TARGET_$(var)_OBJECT_DIR) $(relPath) ] ; } LOCATE_TARGET = $(COMMON_PLATFORM_LOCATE_TARGET) ; LOCATE_SOURCE = $(LOCATE_TARGET) ; SEARCH_SOURCE = $(SUBDIR) $(LOCATE_SOURCE) $(HOST_COMMON_DEBUG_LOCATE_TARGET) # Also add the standard output $(TARGET_COMMON_DEBUG_LOCATE_TARGET) # dirs for generated sources. ; } rule SubIncludeGPL { # SubInclude rule that can be used to conditionally include GPL licensed # add-ons if $(INCLUDE_GPL_ADDONS) = 1 { SubInclude $(1) ; } } rule MakeLocateCommonPlatform { MakeLocate $(1) : $(COMMON_PLATFORM_LOCATE_TARGET) ; } rule MakeLocatePlatform { local files = $(1) ; local file ; for file in $(files) { if [ on $(file) return $(PLATFORM) ] = host { MakeLocate $(file) : $(HOST_COMMON_ARCH_LOCATE_TARGET) ; } else { MakeLocate $(file) : $(TARGET_COMMON_ARCH_LOCATE_TARGET) ; } } } rule MakeLocateArch { local files = $(1) ; local file ; for file in $(files) { if [ on $(file) return $(PLATFORM) ] = host { MakeLocate $(file) : $(HOST_COMMON_DEBUG_LOCATE_TARGET) ; } else { MakeLocate $(file) : $(TARGET_COMMON_DEBUG_LOCATE_TARGET) ; } } } rule MakeLocateDebug { local files = $(1) ; local file ; for file in $(files) { on $(file) { if $(PLATFORM) = host { MakeLocate $(file) : $(HOST_DEBUG_$(DEBUG)_LOCATE_TARGET) ; } else { MakeLocate $(file) : $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET) ; } } } } rule SearchAndReplace { # SearchAndReplace : : : # A code generator that searches and replaces text in a source file to # produce another. # : The file (a source file) being created by this # search and replace code generation. # : The file being used to generate . # : The string to search for in . # : The string to replace with in the new file. # # For example usage see the MarkAs Tracker add-on code. # local _new_file = [ FGristSourceFiles $(1) ] ; Depends all : $(_new_file) ; Depends $(_new_file) : $(2) ; MakeLocate $(_new_file) : $(LOCATE_SOURCE) ; SEARCH on $(_new_file) = $(LOCATE_SOURCE) ; Sed $(_new_file) : $(2) -e s/$(3)/$(4)/g ; Clean clean : $(_new_file) ; } rule Sed { # Sed : # : The file (a source file) being created by this # sed run. # : The parameters to sed in a list. The first item is # the source file being searched through, the rest # are standard sed parameters. # We don't care about the parameters to sed NoCare $(2[2-]) ; NotFile $(2[2-]) ; } actions Sed { $(SED) $(2[2-]) $(2[1]) > $(1) }