1 if test "${ACTION}" = ""; then
4 FULL_PRODUCT_NAME="VLCKit.framework"
5 CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
6 VLC_BUILD_DIR="../../.."
9 rm -fr ${FULL_PRODUCT_NAME}
11 # Hack to use that script with the current VLC-release.app
12 elif test "${ACTION}" = "release-makefile"; then
13 echo "running Pre-Compile.sh in release-makefile mode"
15 FULL_PRODUCT_NAME="${PRODUCT}"
16 if [ "$FULL_PRODUCT_NAME" = "VLC-Plugin.plugin" ] ; then
17 TARGET_BUILD_DIR="${src_dir}"
19 TARGET_BUILD_DIR="${build_dir}"
21 CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Contents/MacOS"
22 VLC_BUILD_DIR="${build_dir}"
23 VLC_SRC_DIR="${src_dir}"
25 RELEASE_MAKEFILE="yes"
28 if test "${ACTION}" = "build"; then
33 target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
34 target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
35 target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
36 target_share="${target}/${share}" # Should we consider using a different well-known folder like shared resources?
37 target_include="${target}/${include}" # Should we consider using a different well-known folder like shared resources?
40 ##########################
41 # @function vlc_install(src_lib, dest_dir, type, lib_install_prefix, destination_name)
42 # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
43 # @param src_lib source library to copy to the destination directory
44 # @param dest_dir destination directory where the src_lib should be copied to
50 local lib_install_prefix=${4}
51 local destination_name=${5}
53 if [ $type = "library" ]; then
54 local install_name="@loader_path/lib"
55 elif [ $type = "module" ]; then
56 local install_name="@loader_path/modules"
58 if [ "$destination_name" != "" ]; then
59 local lib_dest="$dest_dir/$destination_name"
61 local lib_dest="$dest_dir/`basename $src_lib`"
64 if [ "$lib_install_prefix" != "" ]; then
65 local lib_install_prefix="$lib_install_prefix"
67 local lib_install_prefix="@loader_path/../lib"
70 if test -e ${src_lib} && ((! test -e ${lib_dest}) || test ${src_lib} -nt ${lib_dest} ); then
74 # Lets copy the library from the source folder to our new destination folder
75 if [ "${type}" = "bin" ]; then
76 install -m 755 ${src_lib} ${lib_dest}
78 install -m 644 ${src_lib} ${lib_dest}
81 # Update the dynamic library so it will know where to look for the other libraries
82 echo "Installing ${type} `basename ${lib_dest}`"
84 if [ "${type}" = "lib" ]; then
85 # Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
86 install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest} > /dev/null
89 if [ "${type}" != "data" ]; then
90 # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
91 for linked_lib in `otool -L ${lib_dest} | grep '(' | sed 's/\((.*)\)//'`; do
92 local name=`basename ${linked_lib}`
93 case "${linked_lib}" in
94 */vlc_build_dir/* | */vlc_install_dir/* | *vlc* | */extras/contrib/lib/*)
95 if test -e ${linked_lib}; then
96 install_name_tool -change "$linked_lib" "${lib_install_prefix}/${name}" "${lib_dest}"
97 linked_libs="${linked_libs} ${ref_lib}"
98 vlc_install ${linked_lib} ${target_lib} "library"
106 # @function vlc_install
107 ##########################
112 ##########################
113 # Hack for VLC-release.app
114 if [ "$FULL_PRODUCT_NAME" = "VLC-release.app" ] ; then
115 vlc_install "${VLC_BUILD_DIR}/bin/${prefix}vlc" "${target}" "bin" "@loader_path/lib"
116 mv ${target}/vlc ${target}/VLC
117 chmod +x ${target}/VLC
118 elif [ "$FULL_PRODUCT_NAME" = "VLC-Plugin.plugin" ] ; then
119 # install Safari webplugin
120 vlc_install "${VLC_BUILD_DIR}/projects/mozilla/${prefix}npvlc.${suffix}" "${target}" "library" "@loader_path/lib"
121 mv ${target}/npvlc.${suffix} "${target}/VLC Plugin"
122 chmod +x "${target}/VLC Plugin"
124 vlc_install "${VLC_BUILD_DIR}/bin/${prefix}vlc" "${target}/bin" "bin" "@loader_path/../lib"
127 ##########################
128 # Build the modules folder (Same as VLCKit.framework/modules in Makefile)
129 echo "Building modules folder..."
130 # Figure out what modules are available to install
131 for module in `find ${VLC_BUILD_DIR}/modules -name *.${suffix}` ; do
132 # Check to see that the reported module actually exists
133 if test -n ${module}; then
134 vlc_install ${module} ${target_modules} "module"
138 # Install the module cache
139 vlc_install `ls ${VLC_BUILD_DIR}/modules/plugins-*.dat` ${target_modules} "data"
141 # Build the modules folder
142 ##########################
144 ##########################
145 # Create a symbolic link in the root of the framework
146 mkdir -p ${target_lib}
147 mkdir -p ${target_modules}
149 if [ "$RELEASE_MAKEFILE" != "yes" ] ; then
150 pushd `pwd` > /dev/null
151 cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
153 ln -sf Versions/Current/${lib} .
154 ln -sf Versions/Current/${modules} .
155 ln -sf Versions/Current/${include} .
156 ln -sf Versions/Current/${share} .
157 ln -sf Versions/Current/bin .
158 ln -sf ../modules Versions/Current/bin
159 ln -sf ../share Versions/Current/bin
164 ##########################
165 # Build the library folder
166 echo "Building library folder... ${linked_libs}"
167 for linked_lib in ${linked_libs} ; do
168 case "${linked_lib}" in
169 */extras/contrib/lib/*.dylib|*/vlc_install_dir/lib/*.dylib)
170 if test -e ${linked_lib}; then
171 vlc_install ${linked_lib} ${target_lib} "library"
177 vlc_install "${VLC_BUILD_DIR}/src/${prefix}libvlc.5.dylib" "${target_lib}" "library"
178 vlc_install "${VLC_BUILD_DIR}/src/${prefix}libvlccore.4.dylib" "${target_lib}" "library"
179 pushd `pwd` > /dev/null
180 cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}/lib
181 ln -sf libvlc.5.dylib libvlc.dylib
182 ln -sf libvlccore.4.dylib libvlccore.dylib
185 ##########################
186 # Build the share folder
187 echo "Building share folder..."
188 pbxcp="/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -resolve-src-symlinks"
189 mkdir -p ${target_share}
190 $pbxcp ${VLC_SRC_DIR}/share/lua ${target_share}
193 ##########################
195 if [ "$FULL_PRODUCT_NAME" = "VLC-release.app" ] ; then
196 echo "Exporting headers..."
197 mkdir -p ${target_include}/vlc
198 $pbxcp ${VLC_SRC_DIR}/include/vlc/*.h ${target_include}/vlc
200 echo "Headers not needed for this product"