files.jam   [plain text]


# Copyright (c) 1999,2000 Apple Computer, Inc.
# All rights reserved.

# Define reasonable root values, to be overridden by default

# Build intermediates go into TEMP_ROOT which defaults to
# build/intermediates in current directory, or OBJROOT if defined
TEMP_ROOT default = $(OBJROOT) ;
TEMP_ROOT default = .$(/)build$(/)intermediates ;

# Builds go into the BUILD_ROOT which defaults to
# build/products in current directory, or SYMROOT if defined
BUILD_ROOT default = $(SYMROOT) ;
BUILD_ROOT default = .$(/)build$(/)products ;

# Installation root defaults to root, or DSTROOT if defined
INSTALL_ROOT default = $(DSTROOT) ;
INSTALL_ROOT default = / ;

# Set initial values for installation information and framework version
BUILD_PHASING default = YES ;
export INSTALL_OWNER default = $(USER) ;
export INSTALL_GROUP default = $(GROUP) ;
export INSTALL_MODE_FLAG default = "a-w,a+rX" ;
export FRAMEWORK_VERSION default = "A" ;
STRIP_INSTALLED_PRODUCT default = YES ;
REMOVE_CVS_FROM_RESOURCES default = YES ;
COPY_PHASE_STRIP default = YES ;
CLONE_HEADERS default = YES ;
PREBINDING default = YES ;

# Set initial optimization level, debug, and profile settings
export OPTIMIZATION_LEVEL default = 0 ;
export DEBUGGING_SYMBOLS default = YES ;
export PROFILING_CODE default = NO ;

# Default settings for Java builds
JAVA_ARCHIVE_CLASSES default = YES ;
JAVA_ARCHIVE_TYPE default = JAR ;
JAVA_APP_STUB default = /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub ;
JAVA_JAR_FLAGS default = cv ;
JAVA_SOURCE_SUBDIR default = . ;
JAVA_FRAMEWORK_RESOURCES_DIRS default = Resources ;
export JAVA_FRAMEWORK_JARS default = ;
JAVA_USE_DEPENDENCIES default = YES ;
JAVA_ZIP_FLAGS default = -urg ;

# BeginProduct <product>
#
# Initializes the directory and file list variables
#
# Variable references:
# BUILD_ROOT			Base directory for builds
# BUILD_PATH			Subdirectory in root where product is located
# TARGET_NAME			Name of the target that builds this product
# PRODUCT_NAME			Name of the product that's built
# TEMP_ROOT			Base directory for intermediates
# BASE_PROJECT_HEADER_DIR	Base directory for project headers
# HEADER_SUBDIRECTORY		Path prefix in header #include lines
# INSTALL_ROOT			Base directory for installations
# INSTALL_PATH			Subdirectory where product is installed
# PUBLIC_HEADER_DIR		Location for public headers
#
# Variables set:
# HEADER_SUBDIRECTORY		Base product name
# BUILD_DIR			Target-specific directory for builds
# TEMP_DIR			For target-specific intermediates
# PROJECT_HEADER_DIR		Project header file directory in $(TEMP_DIR)
# OBJECT_FILE_DIR		Object file directory in $(TEMP_DIR)
# CLASS_FILE_DIR		Class file directory in $(TEMP_DIR)
# DERIVED_FILE_DIR		Derived source directory in $(TEMP_DIR)
# INSTALL_DIR			Directory in $(INSTALL_ROOT) for installations
# HEADER_SEARCH_PATHS		Project header directories prepended
# FRAMEWORK_SEARCH_PATHS	Product build root appended
# DERIVED_FILES			Initialized empty
# OBJECT_FILES			Initialized empty
# LINKED_FILES			Initialized empty
# PRODUCT_FILES			Initialized with product
# PRECOMP_TRUSTFILE		TrustedPrecomps.txt in $(TEMP_DIR)
#
rule BeginProduct
{
    # define the header subdirectory early since we'll use it to
    # compute the project header directory
    HEADER_SUBDIRECTORY = $(1:B) ;

    # default mapping of build actions to build variants
    switch $(ACTION) {
        case build : BUILD_COMPONENTS default = headers build ;
        case install : BUILD_COMPONENTS default = headers build ;
        case installhdrs : BUILD_COMPONENTS default = headers ;
        case installsrc : BUILD_COMPONENTS default = source ;
    }
    # Set reasonable optimization flags for installs if not already set
    OPTIMIZATION_CFLAGS default = -O ;
    # C++ options match C options by default
    OTHER_CPLUSPLUSFLAGS default = $(OTHER_CFLAGS) ;
    WARNING_CPLUSPLUSFLAGS default = $(WARNING_CFLAGS) ;
    # Set up architecture options for product
    INCLUDED_ARCHS default = $(SUPPORTED_ARCHITECTURES) ;
    SUPPORTED_ARCHITECTURE_FLAGS = ;
    ARCHS = ;
    if ! $(RC_ARCHS) {
	$(NATIVE_ARCH) = YES ;
        RC_$(NATIVE_ARCH) = YES ;
    }
    for SUPPORTED_ARCHITECTURE in $(SUPPORTED_ARCHITECTURES) {
        if $($(SUPPORTED_ARCHITECTURE)) = YES
         && ( $(SUPPORTED_ARCHITECTURE) in $(INCLUDED_ARCHS) )
         && ( $(SUPPORTED_ARCHITECTURE) in $(VALID_ARCHS) ) {
            SUPPORTED_ARCHITECTURE_FLAGS += -arch $(SUPPORTED_ARCHITECTURE) ;
            ARCHS += $(SUPPORTED_ARCHITECTURE) ;
        }
    }
    ARCH_FLAGS default = $(SUPPORTED_ARCHITECTURE_FLAGS) ;
    # Initialize the directory variables
    SOURCE_DIR default = $(INSTALL_ROOT) ;
    if $(BUILD_PATH) {
        BUILD_DIR default = $(BUILD_ROOT)$(/)$(BUILD_PATH) ;
    }
    else {
        BUILD_DIR default = $(BUILD_ROOT) ;
    }
    TEMP_DIR default = $(TEMP_ROOT)$(/)$(TARGET_NAME).build ;
    if $(CLONE_HEADERS) = YES {
        BASE_PROJECT_HEADER_DIR default = $(BUILD_DIR)$(/)ProjectHeaders ;
        if $(HEADER_SUBDIRECTORY) {
            PROJECT_HEADER_DIR default = $(BASE_PROJECT_HEADER_DIR)$(/)$(HEADER_SUBDIRECTORY) ;
        }
        else {
            PROJECT_HEADER_DIR default = $(BASE_PROJECT_HEADER_DIR) ;
        }
    }
    OBJECT_FILE_DIR default = $(TEMP_DIR)$(/)Objects ;
    export CLASS_FILE_DIR default = $(TEMP_DIR)$(/)JavaClasses ;
    if $(JAVA_ARCHIVE_CLASSES) != YES && ( $(PRODUCT_TYPE) != Tool || $(PRODUCT_TYPE) != Library ) {
        export PRODUCT_CLASS_FILE_DIR default = $(BUILD_DIR)$(/)$(PRODUCT_NAME) ;
    }
    FILE_LIST default = $(OBJECT_FILE_DIR)$(/)LinkFileList ;
    DERIVED_FILE_DIR default = $(TEMP_DIR)$(/)DerivedSources ;
    if $(INSTALL_PATH) {
        INSTALL_DIR default = $(INSTALL_ROOT)$(/)$(INSTALL_PATH) ;
    }
    else {
        INSTALL_DIR default = $(INSTALL_ROOT) ;
    }
    # Initialize the search paths
    if $(CLONE_HEADERS) = YES {
        HEADER_SEARCH_PATHS = $(PROJECT_HEADER_DIR) $(BUILD_DIR)$(/)include $(HEADER_SEARCH_PATHS) ;
        FRAMEWORK_SEARCH_PATHS = $(BASE_PROJECT_HEADER_DIR) $(BUILD_ROOT) $(FRAMEWORK_SEARCH_PATHS) ;
    }
    else {
        HEADER_SEARCH_PATHS = $(BUILD_DIR)$(/)include $(HEADER_SEARCH_PATHS) ;
        FRAMEWORK_SEARCH_PATHS = $(BUILD_ROOT) $(FRAMEWORK_SEARCH_PATHS) ;
    }
    LIBRARY_SEARCH_PATHS = $(BUILD_ROOT) $(LIBRARY_SEARCH_PATHS) ;
    # Initialize the file lists
    DERIVED_FILES = ;
    OBJECT_FILES = ;
    LINKED_FILES = ;
    if $(ACTION) != installsrc {
        PRODUCT_FILES = $(1) ;
    }
    if $(OS) in MACOS DARWIN {
	PRECOMP_TRUSTFILE default = $(TEMP_DIR)$(/)TrustedPrecomps.txt ;
    }
    DEPENDS all : $(PRODUCT_NAME) ;
    if ! $(PRODUCT_NAME:G=) = $(1:G=) {
        DEPENDS $(PRODUCT_NAME) : $(1) ;
    }
}

# EndProduct <product>
#
# Sets LOCATE for intermediates and creates required directories.
rule EndProduct
{
    # Create required directories.  This is done here to allow
    # variables to be overridden before this rule is evaluated.
    Mkdir $(BUILD_DIR) ;
    if $(PROJECT_HEADER_DIR) {
        Mkdir $(PROJECT_HEADER_DIR) ;
    }
    Mkdir $(OBJECT_FILE_DIR) ;
    Mkdir $(CLASS_FILE_DIR) ;
    Mkdir $(DERIVED_FILE_DIR) ;
    # ensure that the product goes into the correct place
    LOCATE on $(1) $(PRODUCT_FILES) = $(BUILD_DIR) ;
    LOCATE on $(1:D) $(PRODUCT_FILES:D:G) = $(BUILD_DIR) ;
    for FILE in $(1) $(PRODUCT_FILES) {
        if $(FILE:D) != "" {
            Mkdir $(FILE:D) ;
            DEPENDS $(FILE) : $(FILE:D) ;
        } else {
            DEPENDS $(FILE) : $(BUILD_DIR) ;
        }
    }
    # ensure that anytime we build the primary product we also build
    # the resource directories, inner executables, etc.
    if ! $(1) = $(PRODUCT_FILES) {
        INCLUDES $(1) : $(PRODUCT_FILES) ;
    }
    # ensure that the derived source files go into the correct place
    # If any source files were in subdirectories, we must ensure
    # that the corresponding derived source subdirectory is created before
    # the file is compiled.
    LOCATE on $(DERIVED_FILES) = $(DERIVED_FILE_DIR) ;
    DERIVED_PATHS = $(DERIVED_FILE_DIR) ;
    for FILE in $(DERIVED_FILES) {
        if $(FILE:D) != "" {
            local JUST_GRIST = $(FILE:G) ;
            local JUST_DIRECTORY = $(FILE:D) ;
            local DIRECTORY = $(JUST_DIRECTORY:G=Derived$(JUST_GRIST)) ;
            Mkdir $(DIRECTORY) ;
            local FULL_DERIVED_DIR default = $(DERIVED_FILE_DIR)$(/)$(JUST_DIRECTORY) ;
            if ! ( $(FULL_DERIVED_DIR) in $(DERIVED_PATHS) ) {
                DERIVED_PATHS += $(FULL_DERIVED_DIR) ;
            }
            DEPENDS $(FILE) : $(DIRECTORY) ;
        } else {
            DEPENDS $(FILE) : $(DERIVED_FILE_DIR) ;
        }
    }
    # Run the hack script to build debug and profile variants, if appropriate.
    if $(BUILD_VARIANTS) && $(BLOCK_BUILD_VARIANTS) != YES {
        RunVariantHackScript varianthack : $(1) ;
    }
    # Basic definitions in place, define actions for this target
    Actions $(1) ;
}

# BeginWrappedProduct <product>
#
# Sets additional variables required for wrapped products,
# primarily to assign locations within the product wrapper.
# The WRAPPER variable is set locally within this rule for convenience.
#
# Variables set:
# WRAPPER_SUFFIX		Text to append to product wrapper based on WRAPPER_EXTENSION
# RESOURCE_DIR			Directory for resource files
# APPLESCRIPTS_DIR		Directory for Compiled AppleScript files
# PUBLIC_HEADER_DIR		Public header destination
# PRIVATE_HEADER_DIR	Private header destination
# CURRENT_VERSION_DIR		Subdirectory holding current version of versioned wrapper
# *_LINK			Link to directory in versioned wrapper
# *_LINK_PATH			Path used by link to directory in versioned wrapper
# 
rule BeginWrappedProduct
{
    # set up the basic product variables
    BeginProduct $(1) ;
    # set up new variables for the wrapper and derive suffix
    # from wrapper extension
    local WRAPPER = $(1:G=) ;
    if $(WRAPPER_EXTENSION) {
        WRAPPER_SUFFIX = .$(WRAPPER_EXTENSION) ;
    }
    if $(WRAPPER_SUFFIX) {
        $(WRAPPER) = $(WRAPPER:S=$(WRAPPER_SUFFIX)) ;
    }
    if $(PRODUCT_TYPE) = Application {
        # Application wrappers
        if $(PURE_JAVA) = YES {
            RESOURCE_DIR default = $(WRAPPER) ;
        }
        else {
            RESOURCE_DIR default = $(WRAPPER)$(/)Contents$(/)Resources ;
        }
        RESOURCE_LINK = "" ;
        APPLESCRIPTS_DIR default = $(RESOURCE_DIR)$(/)Scripts ;
        PUBLIC_HEADER_DIR default = $(WRAPPER)$(/)"Contents"$(/)Headers ;
        PUBLIC_HEADER_LINK default = "" ;
        PRIVATE_HEADER_DIR default = $(WRAPPER)$(/)"Contents"$(/)PrivateHeaders ;
        PRIVATE_HEADER_LINK default = "" ;
        CURRENT_VERSION_DIR default = "" ;
        CURRENT_VERSION_LINK default = "" ;
        if $(CLONE_HEADERS) = YES {
            WRAPPER_CLONE_DIR = $(BASE_PROJECT_HEADER_DIR)$(/)$(WRAPPER) ;
            PUBLIC_HEADER_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)"Contents"$(/)Headers ;
            PUBLIC_HEADER_CLONE_LINK default = "" ;
            PRIVATE_HEADER_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)"Contents"$(/)PrivateHeaders ;
            PRIVATE_HEADER_CLONE_LINK default = "" ;
            CURRENT_VERSION_CLONE_DIR default = "" ;
            CURRENT_VERSION_CLONE_LINK default = "" ;
        }
    } # application wrappers
    else if $(PRODUCT_TYPE) = Framework {
        # Framework wrappers
        RESOURCE_DIR default = $(WRAPPER)$(/)Versions$(/)$(FRAMEWORK_VERSION)$(/)Resources ;
        RESOURCE_LINK default = $(WRAPPER)$(/)Resources ;
        RESOURCE_LINK_PATH default = Versions$(/)Current$(/)Resources ;
        APPLESCRIPTS_DIR default = $(RESOURCE_DIR)$(/)Scripts ;
        HAS_PUBLIC_HEADERS = "NO" ;
        PUBLIC_HEADER_DIR default = $(WRAPPER)$(/)Versions$(/)$(FRAMEWORK_VERSION)$(/)Headers ;
        PUBLIC_HEADER_LINK default = $(WRAPPER)$(/)Headers ;
        PUBLIC_HEADER_LINK_PATH default = Versions$(/)Current$(/)Headers ;
        PRIVATE_HEADER_DIR default = $(WRAPPER)$(/)Versions$(/)$(FRAMEWORK_VERSION)$(/)PrivateHeaders ;
        PRIVATE_HEADER_LINK default = $(WRAPPER)$(/)PrivateHeaders ;
        PRIVATE_HEADER_LINK_PATH default = Versions$(/)Current$(/)PrivateHeaders ;
        CURRENT_VERSION_DIR default = $(WRAPPER:G=)$(/)Versions$(/)$(FRAMEWORK_VERSION) ;
        CURRENT_VERSION_LINK default = $(WRAPPER:G=)$(/)Versions$(/)Current ;
        CURRENT_VERSION_LINK_PATH default = Versions$(/)Current ;

        if $(CLONE_HEADERS) = YES {
            WRAPPER_CLONE_DIR = $(BASE_PROJECT_HEADER_DIR)$(/)$(WRAPPER) ;
            PUBLIC_HEADER_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)Versions$(/)$(FRAMEWORK_VERSION)$(/)Headers ;
            PUBLIC_HEADER_CLONE_LINK default = $(WRAPPER_CLONE_DIR)$(/)Headers ;
            PUBLIC_HEADER_CLONE_LINK_PATH default = Versions$(/)Current$(/)Headers ;
            PRIVATE_HEADER_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)Versions$(/)$(FRAMEWORK_VERSION)$(/)PrivateHeaders ;
            PRIVATE_HEADER_CLONE_LINK default = $(WRAPPER_CLONE_DIR)$(/)PrivateHeaders ;
            PRIVATE_HEADER_CLONE_LINK_PATH default = Versions$(/)Current$(/)PrivateHeaders ;
            CURRENT_VERSION_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)Versions$(/)$(FRAMEWORK_VERSION) ;
            CURRENT_VERSION_CLONE_LINK default = $(WRAPPER_CLONE_DIR)$(/)Versions$(/)Current ;
            CURRENT_VERSION_CLONE_LINK_PATH default = Versions$(/)Current ;
        }
        # Create current version directory and link now because
        # they are implicit and needed by almost everything else:
        # Current version dir
        PRODUCT_FILES += $(CURRENT_VERSION_DIR) ;
        NOUPDATE $(CURRENT_VERSION_DIR) ;
        # Current version link
        SymLink $(CURRENT_VERSION_LINK) : $(FRAMEWORK_VERSION) ;
        PRODUCT_FILES += $(CURRENT_VERSION_LINK) ;
        NOUPDATE $(CURRENT_VERSION_LINK) ;
        if $(CLONE_HEADERS) = YES {
            PRODUCT_FILES += $(CURRENT_VERSION_CLONE_DIR) ;
            NOUPDATE $(CURRENT_VERSION_CLONE_DIR) ;
            # Current version link
            SymLink $(CURRENT_VERSION_CLONE_LINK) : $(FRAMEWORK_VERSION) ;
            PRODUCT_FILES += $(CURRENT_VERSION_CLONE_LINK) ;
            NOUPDATE $(CURRENT_VERSION_CLONE_LINK) ;
            # Make sure someone depends on the clone current symlink so it will get created.
            DEPENDS $(PUBLIC_HEADER_CLONE_LINK) : $(CURRENT_VERSION_CLONE_LINK) ;
            DEPENDS $(PRIVATE_HEADER_CLONE_LINK) : $(CURRENT_VERSION_CLONE_LINK) ;
        }
    } # framework wrappers
    else {
        # Default bundle wrappers
        RESOURCE_DIR default = $(WRAPPER)$(/)"Contents"$(/)Resources ;
        RESOURCE_LINK default = "" ;
        APPLESCRIPTS_DIR default = $(RESOURCE_DIR)$(/)Scripts ;
        PUBLIC_HEADER_DIR default = $(WRAPPER)$(/)"Contents"$(/)Headers ;
        PUBLIC_HEADER_LINK default = "" ;
        PRIVATE_HEADER_DIR default = $(WRAPPER)$(/)"Contents"$(/)PrivateHeaders ;
        PRIVATE_HEADER_LINK default = "" ;
        CURRENT_VERSION_DIR default = "" ;
        CURRENT_VERSION_LINK default = "" ;

        if $(CLONE_HEADERS) = YES {
            WRAPPER_CLONE_DIR = $(BASE_PROJECT_HEADER_DIR)$(/)$(WRAPPER) ;
            PUBLIC_HEADER_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)"Contents"$(/)Headers ;
            PUBLIC_HEADER_CLONE_LINK default = "" ;
            PRIVATE_HEADER_CLONE_DIR default = $(WRAPPER_CLONE_DIR)$(/)"Contents"$(/)PrivateHeaders ;
            PRIVATE_HEADER_CLONE_LINK default = "" ;
           CURRENT_VERSION_CLONE_DIR default = "" ;
           CURRENT_VERSION_CLONE_LINK default = "" ;
        }
    } # all bundle layouts
    # define location for optional header documentation generation
    if $(GENERATE_HEADERDOC) = YES && $(RESOURCE_DIR) {
        HEADERDOC_DIR default = $(BUILD_DIR)$(/)$(RESOURCE_DIR)$(/)Documentation ;
        Mkdir $(HEADERDOC_DIR) ;
    }

    # wrapped products may define a location for unarchived classes
    if $(JAVA_ARCHIVE_CLASSES) != YES {
        export PRODUCT_CLASS_FILE_DIR default = $(BUILD_DIR)$(/)$(RESOURCE_DIR)$(/)Java ;
    }
}

rule EndWrappedProduct
{
    if $(OBJECT_FILES) {
        if $(INNER_PRODUCT) {
            DEPENDS $(INNER_PRODUCT) : $(OBJECT_FILES) ;
        }
        if $(PUBLIC_HEADER_DIR) && $(HAS_PUBLIC_HEADERS) = YES {
            DEPENDS $(OBJECT_FILES) : $(PUBLIC_HEADER_DIR) ;
        }
        if $(PUBLIC_HEADER_LINK) && $(HAS_PUBLIC_HEADERS) = YES {
            DEPENDS $(OBJECT_FILES) : $(PUBLIC_HEADER_LINK) ;
        }
        if $(PRIVATE_HEADER_DIR) && $(HAS_PRIVATE_HEADERS) = YES {
            DEPENDS $(OBJECT_FILES) : $(PRIVATE_HEADER_DIR) ;
        }
        if $(PRIVATE_HEADER_LINK) && $(HAS_PRIVATE_HEADERS) = YES {
            DEPENDS $(OBJECT_FILES) : $(PRIVATE_HEADER_LINK) ;
        }
        if $(CURRENT_VERSION_DIR) {
            DEPENDS $(OBJECT_FILES) : $(CURRENT_VERSION_DIR) ;
        }
        if $(CURRENT_VERSION_LINK) {
            DEPENDS $(OBJECT_FILES) : $(CURRENT_VERSION_LINK) ;
        }
    }
    if $(INNER_PRODUCT) {
        local WRAPPER = $(1) ;
        TouchConditionally $(WRAPPER) : $(INNER_PRODUCT) ;
    }
    EndProduct $(1) ;
}