#!/bin/tcsh

# Delete the current deployed library if needed. deleting version also deletes symlinks.

rm -dRfv ${DEPLOYED_BUILD_LIBRARY_VERSION_PATH}

# Create build structure if needed

mkdir -p ${BUILD_SHARED_ROOT_PATH}
mkdir -p ${BUILD_SHARED_BUNDLES_PATH}
mkdir -p ${BUILD_SHARED_LIBRARIES_PATH}
mkdir -p ${BUILD_SHARED_TOOLS_PATH}
mkdir -p ${BUILD_SHARED_TESTS_PATH}

# Create library structure if needed

mkdir -p ${DEPLOYED_BUILD_PLATFORM_PATH}
mkdir -p ${DEPLOYED_BUILD_PRODUCT_NAME_PATH}
mkdir -p ${DEPLOYED_BUILD_LIBRARY_VERSION_PATH}
mkdir -p ${DEPLOYED_BUILD_HEADER_VERSION_PATH}
mkdir -p ${DEPLOYED_BUILD_HEADER_PRODUCT_NAME_PATH}
mkdir -p ${DEPLOYED_BUILD_PRIVATEHEADER_PRODUCT_NAME_PATH}
mkdir -p ${DEPLOYED_BUILD_RESOURCES_PATH}

# Symlink public headers

cp -Rf ${BUILT_PRODUCTS_DIR}${PUBLIC_HEADERS_FOLDER_PATH}/*.h ${DEPLOYED_BUILD_HEADER_PRODUCT_NAME_PATH}
ln -sFfh ${DEPLOYED_BUILD_HEADER_VERSION_PATH} ${DEPLOYED_BUILD_PRODUCT_NAME_HEADER_PATH}

# Symlink private headers

cp -Rf ${BUILT_PRODUCTS_DIR}${PRIVATE_HEADERS_FOLDER_PATH}/*.h ${DEPLOYED_BUILD_PRIVATEHEADER_PRODUCT_NAME_PATH}
ln -sFfh ${DEPLOYED_BUILD_PRIVATEHEADER_VERSION_PATH} ${DEPLOYED_BUILD_PRODUCT_NAME_PRIVATEHEADER_PATH}

# Symlink library

cp -Rf ${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME} ${DEPLOYED_BUILD_LIBRARY_VERSION_PATH}/${FULL_PRODUCT_NAME}
ln -sFfh ${DEPLOYED_BUILD_LIBRARY_VERSION_PATH}/${FULL_PRODUCT_NAME} ${DEPLOYED_BUILD_PRODUCT_NAME_PATH}/${FULL_PRODUCT_NAME}
