iOS:Fix to build IoTivity 1.3.1 provisioning
[iotivity.git] / tools / darwin / mkfwk_ios.sh
1 #!/bin/sh
2 #===============================================================================
3 # Author:    Pete Goodliffe
4 # Copyright: (c) Copyright 2009 Pete Goodliffe
5 # Licence:   Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 #===============================================================================
18 #VERSION_IOS="${MAJOR_VERSION}.${MINOR_VERSION}.${RELEASE_NUMBER}.${BUILD_NUMBER}"
19 VERSION_IOS="0.9.0.1"
20
21
22 OUTDIR=$PWD/out/ios
23 BUILD=release
24 LIBCOAP=libcoap
25 SDKLIB=liboctbstack
26 LIBC_COMMON=libc_common
27 LIBCJSON=libcjson
28 LIBCONNECTIVITY_ABSTRACTION_INTERNAL=libconnectivity_abstraction_internal
29 LIBCONNECTIVITY_ABSTRACTION=libconnectivity_abstraction
30 LIBESMEDIATORRICH=libESMediatorRich
31 LIBLOGGER=liblogger
32 LIBMBEDCRYPTO=libmbedcrypto
33 LIBMBEDTLS=libmbedtls
34 LIBMBEDX509=libmbedx509
35 LIBNOTIFICATION_CONSUMER_WRAPPER=libnotification_consumer_wrapper
36 LIBNOTIFICATION_CONSUMER=libnotification_consumer
37 LIBNOTIFICATION_PROVIDER_WRAPPER=libnotification_provider_wrapper
38 LIBNOTIFICATION_PROVIDER=libnotification_provider
39 LIBOC_LOGGER_INTERNAL=liboc_logger_internal
40 LIBOC_LOGGER=liboc_logger
41 LIBOCLIB=liboc
42 LIBOCPROVISION=libocprovision
43 LIBOCSRM=libocsrm
44 LIBOCTBSTACK_INTERNAL=liboctbstack_internal
45 LIBRCS_CLIENT=librcs_client
46 LIBRCS_COMMON=librcs_common
47 LIBRCS_CONTAINER=librcs_container
48 LIBRCS_SERVER=librcs_server
49 LIBRESOURCE_DIRECTORY=libresource_directory
50 LIBROUTINGMANAGER=libroutingmanager
51 LIBSCENE_MANAGER=libscene_manager
52 LIBOCPMAPI_INTERNAL=libocpmapi_internal
53 LIBOCPMAPI=libocpmapi
54
55 LIPO="xcrun -sdk iphoneos lipo"
56
57
58 VERSION_TYPE=Alpha
59 FRAMEWORK_NAME=iotivity
60 FRAMEWORK_VERSION=A
61 FRAMEWORK_CURRENT_VERSION=${VERSION_IOS}
62 FRAMEWORK_COMPATIBILITY_VERSION=${VERSION_IOS}
63 FRAMEWORKDIR=out/ios
64
65 FRAMEWORK_BUNDLE=$FRAMEWORKDIR/$FRAMEWORK_NAME.framework
66 rm -rf $FRAMEWORK_BUNDLE
67
68 echo "Framework: Setting up directories..."
69 mkdir -p $FRAMEWORK_BUNDLE
70 mkdir -p $FRAMEWORK_BUNDLE/Versions
71 mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION
72 mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Resources
73 mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Headers
74 mkdir -p $FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/Documentation
75
76 echo "Framework: Creating symlinks..."
77 ln  -s $FRAMEWORK_VERSION               $FRAMEWORK_BUNDLE/Versions/Current
78 ln  -s Versions/Current/Headers         $FRAMEWORK_BUNDLE/Headers
79 ln  -s Versions/Current/Resources       $FRAMEWORK_BUNDLE/Resources
80 ln  -s Versions/Current/Documentation   $FRAMEWORK_BUNDLE/Documentation
81 ln  -s Versions/Current/$FRAMEWORK_NAME $FRAMEWORK_BUNDLE/$FRAMEWORK_NAME
82 FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_NAME
83
84 lipolite()
85 {
86    PREV="$PWD"
87    cd "$1"
88    ar -x "$2"
89    cd "$PREV"
90 }
91
92
93 echo "Extracting libraries..."
94 mkdir $OUTDIR/objs
95
96 ARCHS="armv7 armv7s arm64 i386 x86_64"
97 FATFILE=""
98
99 for ARCH in $ARCHS
100 do
101 echo "extracting $ARCH"
102 mkdir $OUTDIR/objs/$ARCH
103 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCOAP.a"
104 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBC_COMMON.a"
105 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCJSON.a"
106 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCONNECTIVITY_ABSTRACTION_INTERNAL.a"
107 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCONNECTIVITY_ABSTRACTION.a"
108 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBESMEDIATORRICH.a"
109 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBLOGGER.a"
110 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOCLIB.a"
111 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBMBEDCRYPTO.a"
112 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBMBEDTLS.a"
113 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBMBEDX509.a"
114 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBNOTIFICATION_CONSUMER_WRAPPER.a"
115 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBNOTIFICATION_CONSUMER.a"
116 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBNOTIFICATION_PROVIDER_WRAPPER.a"
117 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBNOTIFICATION_PROVIDER.a"
118 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOC_LOGGER_INTERNAL.a"
119 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOC_LOGGER.a"
120 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOCPROVISION.a"
121 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOCSRM.a"
122 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOCTBSTACK_INTERNAL.a"
123 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$SDKLIB.a"
124 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBRCS_CLIENT.a"
125 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBRCS_COMMON.a"
126 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBRCS_CONTAINER.a"
127 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBRCS_SERVER.a"
128 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBRESOURCE_DIRECTORY.a"
129 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBROUTINGMANAGER.a"
130 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBSCENE_MANAGER.a"
131 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOCPMAPI_INTERNAL.a"
132 lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBOCPMAPI.a"
133 ar -r $OUTDIR/objs/$ARCH.a $OUTDIR/objs/$ARCH/*.o
134 done
135
136
137 echo "Lipoing library into $FRAMEWORK_INSTALL_NAME..."
138 $LIPO \
139        -create \
140        -arch armv7 "$OUTDIR/objs/armv7.a" \
141        -arch armv7s "$OUTDIR/objs/armv7s.a" \
142        -arch arm64 "$OUTDIR/objs/arm64.a" \
143        -arch i386 "$OUTDIR/objs/i386.a" \
144        -arch x86_64  "$OUTDIR/objs/x86_64.a" \
145        -output "$FRAMEWORK_INSTALL_NAME" \
146   || abort "Lipo $1 failed"
147
148 echo rm -rf objs
149 find $OUTDIR/objs -name "*.o" | xargs rm
150
151 echo "Framework: Copying includes..."
152 cp -r  resource/include/*.h  $FRAMEWORK_BUNDLE/Headers
153 cp -r  resource/include/*.hpp  $FRAMEWORK_BUNDLE/Headers
154 cp -r  resource/oc_logger/include/*.h  $FRAMEWORK_BUNDLE/Headers
155 cp -r  resource/oc_logger/include/*.hpp  $FRAMEWORK_BUNDLE/Headers
156 cp -r  resource/csdk/stack/include/*.h  $FRAMEWORK_BUNDLE/Headers
157 cp -r  resource/csdk/include/*.h  $FRAMEWORK_BUNDLE/Headers
158 cp -r  resource/csdk/connectivity/api/*.h  $FRAMEWORK_BUNDLE/Headers
159 cp -r  resource/csdk/security/include/*.h  $FRAMEWORK_BUNDLE/Headers
160 cp -r  resource/csdk/security/include/experimental/*.h  $FRAMEWORK_BUNDLE/Headers
161 cp -r  resource/csdk/security/include/internal/*.h  $FRAMEWORK_BUNDLE/Headers
162 cp -r  resource/csdk/security/provisioning/include/*.h  $FRAMEWORK_BUNDLE/Headers
163 cp -r  resource/csdk/security/provisioning/include/internal/*.h  $FRAMEWORK_BUNDLE/Headers
164 cp -r  resource/c_common/experimental/*.h  $FRAMEWORK_BUNDLE/Headers
165 cp -r  resource/c_common/*.h  $FRAMEWORK_BUNDLE/Headers
166 cp -r  resource/csdk/resource-directory/include/*.h  $FRAMEWORK_BUNDLE/Headers
167 cp -r  resource/oc_logger/include/targets/oc_ostream_logger.h  $FRAMEWORK_BUNDLE/Headers
168 cp -r  $OUTDIR/arm64/$BUILD/resource/c_common/iotivity_config.h  $FRAMEWORK_BUNDLE/Headers
169
170 echo "Framework: Creating plist..."
171 cat > $FRAMEWORK_BUNDLE/Resources/Info.plist <<EOF
172 <?xml version="1.0" encoding="UTF-8"?>
173 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
174 <plist version="1.0">
175 <dict>
176       <key>CFBundleDevelopmentRegion</key>
177       <string>English</string>
178       <key>CFBundleExecutable</key>
179       <string>${FRAMEWORK_NAME}</string>
180       <key>CFBundleIdentifier</key>
181       <string>org.iotivity</string>
182       <key>CFBundleInfoDictionaryVersion</key>
183       <string>6.0</string>
184       <key>CFBundlePackageType</key>
185       <string>FMWK</string>
186       <key>CFBundleSignature</key>
187       <string>????</string>
188       <key>CFBundleVersion</key>
189       <string>${FRAMEWORK_CURRENT_VERSION}</string>
190 </dict>
191 </plist>
192 EOF
193
194 echo
195 echo "    ================================================================="
196 echo "    Done"
197 echo