Remove framework-only links when packaging VLC-release.app
[vlc.git] / projects / macosx / framework / Pre-Compile.sh
index c8a54b6..4065f4a 100644 (file)
@@ -21,7 +21,6 @@ if test "${ACTION}" = "VLC-release.app"; then
 fi
 
 if test "${ACTION}" = "build"; then    
-    vlc_config="${VLC_SRC_DIR}/vlc-config"
     lib="lib"
     modules="modules"
     share="share"
@@ -36,23 +35,23 @@ if test "${ACTION}" = "build"; then
     # @description Installs the specified library into the destination folder, automatically changes the references to dependencies
     # @param src_lib     source library to copy to the destination directory
     # @param dest_dir    destination directory where the src_lib should be copied to
-    install_library() {    
+    install_library() { 
+   
         if [ ${3} = "library" ]; then
-            install_name="@loader_path/lib"
+            local install_name="@loader_path/lib"
         elif [ ${3} = "module" ]; then
-            install_name="@loader_path/modules"
+            local install_name="@loader_path/modules"
         fi
-        
         if [ "${5}" != "" ]; then
-            lib_dest="${2}/${5}"
+            local lib_dest="${2}/${5}"
         else
-            lib_dest="${2}/`basename ${1}`"
+            local lib_dest="${2}/`basename ${1}`"
         fi
 
         if [ "${4}" != "" ]; then
-            lib_install_prefix="${4}"
+            local lib_install_prefix="${4}"
         else
-            lib_install_prefix="@loader_path/../lib"
+            local lib_install_prefix="@loader_path/../lib"
         fi
         
         if test -e ${1} && ((! test -e ${lib_dest}) || test ${1} -nt ${lib_dest} ); then
@@ -72,18 +71,15 @@ if test "${ACTION}" = "build"; then
     
             # Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
             for linked_lib in `otool -L ${lib_dest}  | grep '(' | sed 's/\((.*)\)//'`; do
-                name=`basename ${linked_lib}`
+                local name=`basename ${linked_lib}`
                 case "${linked_lib}" in
-                    */vlc_install_dir/lib/* | */extras/contrib/lib/*)
+                    */vlc_build_dir/*  | *vlc* | */extras/contrib/lib/*)
                         if test -e ${linked_lib}; then
-                            install_name_tool -change ${linked_lib} "${lib_install_prefix}/${name}" ${lib_dest}
+                            install_name_tool -change "$linked_lib" "${lib_install_prefix}/${name}" "${lib_dest}"
                             linked_libs="${linked_libs} ${ref_lib}"
-
                             install_library ${linked_lib} ${target_lib} "library"
                         fi
                         ;;
-                    *)
-                        ;;
                 esac
             done
          fi
@@ -91,15 +87,27 @@ if test "${ACTION}" = "build"; then
     # @function install_library
     ##########################
 
+    ##########################
+    # Hack for VLC-release.app
+    if [ "$FULL_PRODUCT_NAME" = "VLC-release.app" ] ; then
+        prefix=".libs/"
+        install_library "${VLC_BUILD_DIR}/src/${prefix}vlc" "${target}" "bin" "@loader_path/lib"
+        mv ${target}/vlc ${target}/VLC
+        chmod +x ${target}/VLC
+        suffix="dylib"
+    else
+        prefix=""
+        suffix="so"
+    fi
+
     ##########################
     # Build the modules folder (Same as VLCKit.framework/modules in Makefile)
     echo "Building modules folder..."
     # Figure out what modules are available to install
-    for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
+    for module in `find ${VLC_BUILD_DIR}/modules -name *.${suffix}` ; do
         # Check to see that the reported module actually exists
         if test -n ${module}; then
-            module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
-            install_library ${module_src} ${target_modules} "module"
+            install_library ${module} ${target_modules} "module"
         fi
     done
     # Build the modules folder
@@ -109,28 +117,23 @@ if test "${ACTION}" = "build"; then
     # Create a symbolic link in the root of the framework
     mkdir -p ${target_lib}
     mkdir -p ${target_modules}
-    
-    pushd `pwd` > /dev/null 
-    cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
-    
-    ln -sf Versions/Current/${lib} .
-    ln -sf Versions/Current/${modules} .
-    
-    popd > /dev/null 
-    # Create a symbolic link in the root of the framework
-    ##########################
-    
+
+    if [ "$FULL_PRODUCT_NAME" != "VLC-release.app" ] ; then
+        pushd `pwd` > /dev/null
+        cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
+
+        ln -sf Versions/Current/${lib} .
+        ln -sf Versions/Current/${modules} .
+
+        popd > /dev/null
+    fi
+
     ##########################
     # Build the library folder
-    echo "Building library folder..."
+    echo "Building library folder... ${linked_libs}"
     for linked_lib in ${linked_libs} ; do
         case "${linked_lib}" in
-            */extras/contrib/lib/*.dylib)
-                if test -e ${linked_lib}; then
-                    install_library ${linked_lib} ${target_lib} "library"
-                fi
-                ;;
-            */vlc_install_dir/lib/*.dylib)
+            */extras/contrib/lib/*.dylib|*/vlc_install_dir/lib/*.dylib)
                 if test -e ${linked_lib}; then
                     install_library ${linked_lib} ${target_lib} "library"
                 fi
@@ -138,20 +141,14 @@ if test "${ACTION}" = "build"; then
         esac
     done
 
-    install_library "${VLC_BUILD_DIR}/src/.libs/libvlc-control.dylib" ${target_lib} "library"
-    install_library "${VLC_BUILD_DIR}/src/.libs/libvlc.dylib" ${target_lib} "library"
 
-    ##########################
-    # Hack for VLC-release.app
-    if [ "$FULL_PRODUCT_NAME" = "VLC-release.app" ] ; then
-        install_library "${VLC_BUILD_DIR}/.libs/vlc" "${target}" "bin" "@loader_path/lib"
-    fi
+    install_library "${VLC_BUILD_DIR}/src/${prefix}libvlc-control.dylib" ${target_lib} "library"
+    install_library "${VLC_BUILD_DIR}/src/${prefix}libvlc.dylib" ${target_lib} "library"
 
     ##########################
     # Build the share folder
     echo "Building share folder..."
-    pbxcp="/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks"
+    pbxcp="/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -resolve-src-symlinks"
     mkdir -p ${target_share}
-    $pbxcp ${VLC_BUILD_DIR}/share/luameta ${target_share}
-    $pbxcp ${VLC_BUILD_DIR}/share/luaplaylist ${target_share}
+    $pbxcp ${VLC_SRC_DIR}/share/lua ${target_share}
 fi