1 if test "${ACTION}" = ""; then
4 FULL_PRODUCT_NAME="VLC.framework"
5 CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
6 VLC_BUILD_DIR="../../.."
9 rm -fr ${FULL_PRODUCT_NAME}
13 if test "${ACTION}" = "build"; then
14 vlc_config="${VLC_SRC_DIR}/vlc-config"
17 target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
18 target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
19 target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
22 ##########################
23 # @function install_library(src_lib, dest_dir)
24 # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
25 # @param src_lib source library to copy to the destination directory
26 # @param dest_dir destination directory where the src_lib should be copied to
28 if [ ${3} = "library" ]; then
29 install_name="@loader_path/lib"
31 install_name="@loader_path/modules"
34 if [ "${4}" != "" ]; then
37 lib_dest="${2}/`basename ${1}`"
40 if test -e ${1} && ((! test -e ${lib_dest}) || test ${1} -nt ${lib_dest} ); then
43 # Lets copy the library from the source folder to our new destination folder
46 # Update the dynamic library so it will know where to look for the other libraries
47 echo "Installing ${3} `basename ${lib_dest}`"
49 # Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
50 install_name_tool -change /usr/local/lib/libvlc.1.dylib @loader_path/../lib/libvlc.dylib ${lib_dest}
51 install_name_tool -change @executable_path/lib/vlc_libintl.dylib @loader_path/../lib/vlc_libintl.dylib ${lib_dest}
52 install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest}
54 # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
55 for linked_lib in `otool -L ${lib_dest} | grep '(' | sed 's/\((.*)\)//'`; do
56 ref_lib=`echo "${linked_lib}" | sed 's:executable_path/:loader_path/../:'`
58 if test "${ref_lib}" != "${linked_lib}"; then
59 install_name_tool -change ${linked_lib} ${ref_lib} ${lib_dest}
61 if test `echo "${ref_lib}" | grep "^@loader_path"`; then
62 linked_libs="${linked_libs} ${ref_lib}"
67 # @function install_library
68 ##########################
70 ##########################
71 # Build the modules folder (Same as VLC.framework/modules in Makefile)
72 echo "Building modules folder..."
73 # Figure out what modules are available to install
74 for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
75 # Check to see that the reported module actually exists
76 if test -n ${module}; then
77 module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
78 install_library ${module_src} ${target_modules} "module"
81 # Build the modules folder
82 ##########################
84 ##########################
85 # Create a symbolic link in the root of the framework
86 mkdir -p ${target_lib}
87 mkdir -p ${target_modules}
89 pushd `pwd` > /dev/null
90 cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
92 ln -sf Versions/Current/${lib} .
93 ln -sf Versions/Current/${modules} .
96 # Create a symbolic link in the root of the framework
97 ##########################
99 ##########################
100 # Build the library folder (Same as VLC.framework/lib in Makefile)
101 echo "Building library folder..."
102 for linked_lib in ${linked_libs} ; do
103 case "${linked_lib}" in
104 @loader_path/../lib/*)
105 ref_lib=`echo ${linked_lib} | sed 's:@loader_path/../lib/::'`
106 if test -e ${VLC_BUILD_DIR}/extras/contrib/vlc-lib/${ref_lib}; then
107 src_lib=${VLC_BUILD_DIR}/extras/contrib/vlc-lib/${ref_lib}
108 elif test -e ${VLC_BUILD_DIR}/src/.libs/${ref_lib}; then
109 src_lib=${VLC_BUILD_DIR}/src/.libs/${ref_lib}
111 install_library ${src_lib} ${target_lib} "library"
115 # Build the library folder
116 ##########################
117 install_library "${VLC_BUILD_DIR}/src/.libs/libvlc-control.dylib" ${target_lib} "library"