Using a layout for about box.
[mldemos:baraks-mldemos.git] / packageOSX.sh
1 #!/bin/sh
2
3 appName='MLDemos'
4 myPath=$appName'.app/Contents/'
5 opencvPath='/Users/basilio/Code/OpenCV-2.2.0/build/lib/Release/'
6 #opencvPath='/usr/local/lib/'
7
8 names=( libopencv_core libopencv_legacy libopencv_highgui libopencv_ml libopencv_features2d libopencv_imgproc libopencv_calib3d libopencv_video libopencv_flann)
9 namesQT=( QtGui QtCore QtNetwork QtSvg QtXml QtWebKit phonon QtDBus QtXmlPatterns)
10 namesQTadd=( QtWebKit phonon QtDBus QtXmlPatterns)
11 framework='@executable_path/../Frameworks/'
12 frameworkQT='.framework/Versions/4/'
13
14 #first we deploy
15 echo 'macdeployqt-4.6' $appName'.app'
16 eval 'macdeployqt-4.6' $appName'.app'
17
18 # we start with changing the links in the executable
19 for name in ${names[@]}
20 do
21         echo 'install_name_tool -change '$opencvPath$name'.dylib' $framework$name'.dylib' $myPath'MacOS/'$appName
22         eval 'install_name_tool -change '$opencvPath$name'.dylib' $framework$name'.dylib' $myPath'MacOS/'$appName
23 done;
24 echo '\n'
25
26 # then we copy the opencv library files
27 for name in ${names[@]}
28 do
29         echo 'cp '$opencvPath$name'.dylib ' $myPath'/Frameworks/'
30         eval 'cp '$opencvPath$name'.dylib ' $myPath'/Frameworks/'
31 done;
32 echo '\n'
33
34 # now we change the id on the libs we have copied inside the package
35 for name in ${names[@]}
36 do
37         echo 'install_name_tool -id '$framework$name'.dylib' $myPath'Frameworks/'$name'.dylib'
38         eval 'install_name_tool -id '$framework$name'.dylib' $myPath'Frameworks/'$name'.dylib'
39 done;
40 echo '\n'
41
42 # then we change the links in the libs we have copied inside the package
43 for name in ${names[@]}
44 do
45         for name2 in ${names[@]}
46         do
47                 echo 'install_name_tool -change '$opencvPath$name'.dylib' $framework$name'.dylib' $myPath'Frameworks/'$name2'.dylib'
48                 eval 'install_name_tool -change '$opencvPath$name'.dylib' $framework$name'.dylib' $myPath'Frameworks/'$name2'.dylib'
49         done;
50         echo '\n'
51 done;
52
53 for name in ${namesQT[@]}
54 do
55         for name2 in ${names[@]}
56         do
57                 echo 'install_name_tool -change '$name$frameworkQT$name $framework$name$frameworkQT$name $myPath'Frameworks/'$name2'.dylib'
58                 eval 'install_name_tool -change '$name$frameworkQT$name $framework$name$frameworkQT$name $myPath'Frameworks/'$name2'.dylib'
59         done;
60         echo '\n'
61 done;
62
63 #¬†copy frameworks from namesQTadd to the package
64 #¬†will need to create the folders Resources and Versions/4/ first
65 for name in ${namesQTadd[@]}
66 do
67                 echo 'mkdir '$myPath'Frameworks/'$name'.framework'
68                 eval 'mkdir '$myPath'Frameworks/'$name'.framework'
69                 echo 'mkdir '$myPath'Frameworks/'$name'.framework/Resources'
70                 eval 'mkdir '$myPath'Frameworks/'$name'.framework/Resources'
71                 echo 'mkdir '$myPath'Frameworks/'$name'.framework/Versions'
72                 eval 'mkdir '$myPath'Frameworks/'$name'.framework/Versions'
73                 echo 'mkdir '$myPath'Frameworks/'$name'.framework/Versions/4'
74                 eval 'mkdir '$myPath'Frameworks/'$name'.framework/Versions/4'
75                 echo 'cp /Library/Frameworks/'$name$frameworkQT$name $myPath'Frameworks/'$name$frameworkQT$name
76                 eval 'cp /Library/Frameworks/'$name$frameworkQT$name $myPath'Frameworks/'$name$frameworkQT$name
77 done;
78
79 for name in ${namesQT[@]}
80 do
81         for name2 in ${namesQTadd[@]}
82         do
83                 echo 'install_name_tool -change '$name$frameworkQT$name $framework$name$frameworkQT$name $myPath'Frameworks/'$name2$frameworkQT$name2
84                 eval 'install_name_tool -change '$name$frameworkQT$name $framework$name$frameworkQT$name $myPath'Frameworks/'$name2$frameworkQT$name2
85         done;
86         echo '\n'
87 done;
88
89
90 # last we go through our plugins to change these guys as well
91 echo 'mkdir '$myPath'MacOS/plugins'
92 eval 'mkdir '$myPath'MacOS/plugins'
93 echo 'mkdir '$myPath'MacOS/help'
94 eval 'mkdir '$myPath'MacOS/help'
95 echo 'cp plugins/*.dylib '$myPath'MacOS/plugins/'
96 eval 'cp plugins/*.dylib '$myPath'MacOS/plugins/'
97 echo 'cp help/* '$myPath'MacOS/help/'
98 eval 'cp help/* '$myPath'MacOS/help/'
99
100 for filename in plugins/*.dylib
101 do
102         # copy the file in the proper folder
103         for name in ${names[@]}
104         do
105                 echo 'install_name_tool -change '$opencvPath$name'.dylib' $framework$name'.dylib' $myPath'MacOS/'$filename
106                 eval 'install_name_tool -change '$opencvPath$name'.dylib' $framework$name'.dylib' $myPath'MacOS/'$filename
107         done;
108         for name in ${namesQT[@]}
109         do
110                 echo 'install_name_tool -change '$name$frameworkQT$name $framework$name$frameworkQT$name $myPath'MacOS/'$filename
111                 eval 'install_name_tool -change '$name$frameworkQT$name $framework$name$frameworkQT$name $myPath'MacOS/'$filename
112         done;
113         echo '\n'
114 done;
115
116 #echo 'otool -L' $myPath'MacOS/'$appName
117 #eval 'otool -L' $myPath'MacOS/'$appName
118 #for filename in plugins/*.dylib
119 #do
120 #       echo 'otool -L' $myPath'Resources/'$filename
121 #       eval 'otool -L' $myPath'Resources/'$filename
122 #done;
123