Build_Darwin_Bundle.sh 5.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/bin/sh

cp -r OpenFlipper/Icons OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents
cp -r OpenFlipper/Shaders OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents
cp -r OpenFlipper/Textures OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents
cp -r OpenFlipper/Fonts OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents

if [ -d /usr/local/Trolltech/Qt-4.4.3/plugins ]; then
  cp -r /usr/local/Trolltech/Qt-4.4.3/plugins OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents/qtplugins
else
  echo "Unable to find qt Plugin directory"
fi

#Create Frameworks directory
if [ ! -d OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents/Frameworks ]; then
   mkdir OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents/Frameworks
   echo Created OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents/Frameworks
fi

Jan Möbius's avatar
Jan Möbius committed
20
cp -r Arch/macx/Resources OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents 
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

# Copy All basic libs to Frameworks 
for i in $(find . -name *.dylib | grep -v "Plugin-" | grep Release ); do
   cp $i OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents/Frameworks
done;

pushd .

cd OpenFlipper/Darwin_32_Release/OpenFlipper.app/Contents/MacOS

# extract Qt dependencies and place them in Frameworks directory
# and change the executables path to the right dir
for i in $(otool -L OpenFlipper | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep Qt) ; do
        NEW=$(echo $i | awk -F "/" '{print $NF}')
        OLD=$(echo $i)

        cp $OLD ../Frameworks

        install_name_tool -change $OLD @executable_path/../Frameworks/$NEW  OpenFlipper

done

# extract opt/local dependencies and place them in Frameworks directory
# and change the executables path to the right dir
for i in $(otool -L OpenFlipper | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep "/opt/local" ) ; do
        NEW=$(echo $i | awk -F "/" '{print $NF}')
        OLD=$(echo $i)
        cp $OLD ../Frameworks
        install_name_tool -change $OLD @executable_path/../Frameworks/$NEW  OpenFlipper

done

# Change OpenFlippers own dependencies to OpenMesh ACG and Pluginlib
# and change the executables path to the right dir
for i in $(otool -L OpenFlipper | awk -F " " '{print $1}' | grep OpenFlipper ) ; do
        NEW=$(echo $i | awk -F "/" '{print $NF}')
        OLD=$(echo $i)
        install_name_tool -change $OLD @executable_path/../Frameworks/$NEW  OpenFlipper
done

cd ..

cd qtplugins

 # Change paths in the qtplugins
 for DIR in $(ls -1 ); do
   if [ -d $DIR ]; then
     cd $DIR

     for file in $(ls -1 ); do
       for i in $(otool -L $file | awk -F " " '{print $1}' | grep Qt ) ; do
         NEW=$(echo $i | awk -F "/" '{print $NF}')
         OLD=$(echo $i)
         install_name_tool -change $OLD @executable_path/../Frameworks/$NEW $file
       done
     done

     cd ..

   fi

 done

cd ..

pushd .

cd Plugins
cd Darwin 
cd 32
cd Release

# extract opt/local dependencies for Plugins and place them in Frameworks directory up to level 5
for file in $(ls -1 ); do
  if [ ! -d $file ]; then

	  for i in $(otool -L $file | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep -v "/usr/lib" | grep -v "libPlugin-") ; do
        	NEW=$(echo $i | awk -F "/" '{print $NF}')
	        OLD=$(echo $i)
		if [ ! -e ../../../../Frameworks/$NEW ]; then
			if [ -e $OLD ]; then
				cp -n $OLD ../../../../Frameworks
			fi
		fi
		
	  done
  fi
done

popd

cd Frameworks

#Check files in framework dir for dependencies and copy them to the Frameworks directory
for file in $(ls -1 ); do
  for i in $(otool -L $file | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep -v "/usr/lib" ) ; do
       	NEW=$(echo $i | awk -F "/" '{print $NF}')
        OLD=$(echo $i)

	if [ ! -e ../Frameworks/$NEW ]; then
		if [ -e $OLD ]; then
			cp -n $OLD ../Frameworks
		fi
	fi                                  	

  done
done

# Change paths in the framework files
for file in $(ls -1 ); do
  for i in $(otool -L $file | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep -v "/usr/lib") ; do
        NEW=$(echo $i | awk -F "/" '{print $NF}')
        OLD=$(echo $i)
        install_name_tool -change $OLD @executable_path/../Frameworks/$NEW $file
  done
done

# Change ids in the qt framework files
for file in $(ls -1 ); do 
 COUNT=1;

 for i in $(otool -L $file | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep -v "/usr/lib" ) ; do
        
        NEW=$(echo $i | awk -F "/" '{print $NF}')

        if [ $COUNT == 2 ]; then
          install_name_tool -id @executable_path/../Frameworks/$NEW $file
        fi

        COUNT=$((COUNT+1))
  done

done


cd ..

pushd .

cd Plugins
cd Darwin 
cd 32
cd Release


 # Change paths in the plugins
 for file in $(ls -1 ); do
   if [ ! -d $file ]; then
     for i in $(otool -L $file | awk -F " " '{print $1}' | grep -v System | grep -v Developer | grep -v "/usr/lib") ; do
          NEW=$(echo $i | awk -F "/" '{print $NF}')
          OLD=$(echo $i)
          install_name_tool -change $OLD @executable_path/../Frameworks/$NEW $file
     done
   fi
 done

popd 

find . -name *.svn | xargs rm -rf 

popd