Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 216 lines (172 sloc) 4.96 kB
37773be @sedrik Added the Erlang build scripts
sedrik authored
1 #!/bin/bash
2
3 PROJECT=EmbErl
4
fdb4941 Merged upstream
fredrik.andersson authored
5 VERSION=R14B01
37773be @sedrik Added the Erlang build scripts
sedrik authored
6 OTP_SRC=otp_src_$VERSION
7 OTP_SRC_TAR=${OTP_SRC}.tar.gz
8
11d6673 Further steps to set up Toolchain correctly
Uwe Dauernheim authored
9 XCOMP_CONF=erl-xcomp-arm-darwin.conf
37773be @sedrik Added the Erlang build scripts
sedrik authored
10 XCOMP_CONF_PATH=xcomp/$XCOMP_CONF
11
11d6673 Further steps to set up Toolchain correctly
Uwe Dauernheim authored
12 TARGET_ERL_ROOT=/usr/local/erlang
37773be @sedrik Added the Erlang build scripts
sedrik authored
13
14 TAR_NAME="EmbErl_"
15
16 #standard configuration values
84d7c68 Remove default behaviour to strip binaries and add option for this.
Niclas Axelsson authored
17 STRIP_BIN=false
37773be @sedrik Added the Erlang build scripts
sedrik authored
18 STRIP_BEAM=false
19 SLIM_COMPILE=false
20 COMPRESS_COMPILE=false
fdb4941 Merged upstream
fredrik.andersson authored
21 COMPRESS_APP=true
37773be @sedrik Added the Erlang build scripts
sedrik authored
22
23 #standard gcc opt levels [1,2,3,s]
fdb4941 Merged upstream
fredrik.andersson authored
24 OPT_LEVEL=s
11d6673 Further steps to set up Toolchain correctly
Uwe Dauernheim authored
25 HOST=arm-apple-darwin10
37773be @sedrik Added the Erlang build scripts
sedrik authored
26
b316d22 Make strip command flexible
Uwe Dauernheim authored
27 #STRIP_CMD=${HOST}-strip
28 STRIP_CMD="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip"
29
37773be @sedrik Added the Erlang build scripts
sedrik authored
30 #Arguments parsing
31 while getopts ":scCoH:h" Option
32 do
33 case $Option in
34 s ) #echo "Stripping beam and Slim compiles"
35 STRIP_BEAM=true
36 SLIM_COMPILE=true
37 TAR_NAME=${TAR_NAME}s
38 ;;
84d7c68 Remove default behaviour to strip binaries and add option for this.
Niclas Axelsson authored
39 S ) #echo "Stipping binaries"
995cbc0 Fix bug with stripping of binaries-option
Niclas Axelsson authored
40 STRIP_BIN=true
84d7c68 Remove default behaviour to strip binaries and add option for this.
Niclas Axelsson authored
41 ;;
37773be @sedrik Added the Erlang build scripts
sedrik authored
42 c ) #echo "Compress compiling"
43 COMPRESS_COMPILE=true
44 TAR_NAME=${TAR_NAME}c
45 ;;
46 C ) #echo "Compressing Applications"
47 COMPRESS_APP=true
48 TAR_NAME=${TAR_NAME}C
49 ;;
50 o ) #echo "Optimization level $OPTARG"
51 OPT_LEVEL=$OPTARG
52 TAR_NAME=${TAR_NAME}o${OPTARG}
53 ;;
54 H ) #echo "Host $OPTARG"
55 HOST=$OPTARG
56 TAR_NAME=${TAR_NAME}H-${OPTARG}
57 ;;
58 h ) echo \
59 "./Emberl.sh [options]
60
61 Available options:
62 -s Strip beam files and compile with the slim flag
63 -c Compile beams using the compress flag
64 -C Compress applications into zip's
65 -o <arg> Compile the virtual machine with the <arg> optimization flag
66 -H <arg> Compile the virtual machine for the host <arg>
67 -h Display this help message "
68 exit 0
69 ;;
70 * ) echo "Unimplemented option chosen." # DEFAULT
71 ;;
72 esac
73 done
74
75 #Create the erl-xcomp configuration
76 cat $XCOMP_CONF.in > $XCOMP_CONF
c64a5b3 @burbas Add -e flag to sed so it does work with BSD/OSX
authored
77 sed -ie "s/@OPT_LEVEL@/${OPT_LEVEL}/" $XCOMP_CONF
78 sed -ie "s/@HOST@/${HOST}/" $XCOMP_CONF
37773be @sedrik Added the Erlang build scripts
sedrik authored
79
5bd9132 Small typo fix
Uwe Dauernheim authored
80 ## FUNCTION DECLARATION SPACE
37773be @sedrik Added the Erlang build scripts
sedrik authored
81
82 show()
83 {
84 cat <<EOF
85
86 *
87 * $1...
88 *
89
90 EOF
91 }
92
93 # END OF FUNCTION DECLARATION
94
95 WD=$(pwd)
96
97 #Do not do unnecessary work
98 if [ -e ${TAR_NAME}.tgz ]
99 then
100 show "The build exists.. see $TAR_NAME.tgz"
101 exit 0
102 fi
103
104 #Download the erlang source if it does not exist.
105 [ -e $OTP_SRC_TAR ] || (show "Downloading sources" && wget http://erlang.org/download/$OTP_SRC_TAR)
106
107 #Unpack
108 [ -d $OTP_SRC ] || (show "Unpacking $OTP_SRC" && tar xfz $OTP_SRC_TAR)
109
110 cp $XCOMP_CONF ${OTP_SRC}/$XCOMP_CONF_PATH
111
112
bbd327c Fix the linking issue
Uwe Dauernheim authored
113 show "Patching some files for arm-apple-darwin gcc compiler and iOS SDK compatibility"
114 patch -N -p1 < arm-apple-darwin.patch
b316d22 Make strip command flexible
Uwe Dauernheim authored
115
116
37773be @sedrik Added the Erlang build scripts
sedrik authored
117 #Enter the Build directory and do configure
118 #TODO: remove any SKIP files that were created previously
119 show "Configuring for cross compilation using $XCOMP_CONF_PATH"
120 pushd $OTP_SRC
bbd327c Fix the linking issue
Uwe Dauernheim authored
121 ./otp_build configure --xcomp-conf=$XCOMP_CONF_PATH
37773be @sedrik Added the Erlang build scripts
sedrik authored
122
123 if [[ "$SLIM_COMPILE" == "true" || "$COMPRESS_COMPILE" == "true" ]]
124 then
125 NEW_COMPILE_OPTS=""
126
127 if [ "$SLIM_COMPILE" == "true" ]
128 then
129 NEW_COMPILE_OPTS="$NEW_COMPILE_OPTS \+slim"
130 fi
131
132 if [ "$COMPRESS_COMPILE" == "true" ]
133 then
134 NEW_COMPILE_OPTS="$NEW_COMPILE_OPTS \+compressed"
135 fi
136
6e99ded Fix hardcoded target host
Niclas Axelsson authored
137 OTP_MK="make/${HOST}/otp.mk"
37773be @sedrik Added the Erlang build scripts
sedrik authored
138 show "Patching $OTP_MK to edit erlc options"
c64a5b3 @burbas Add -e flag to sed so it does work with BSD/OSX
authored
139 sed -ie "s/ \+debug_info/$NEW_COMPILE_OPTS/" $OTP_MK
37773be @sedrik Added the Erlang build scripts
sedrik authored
140 fi
141
142 #Put SKIP files in the apps we don't want.
143 show "Selecting applications to keep"
144 KEEPSIES=$(tr '\n' ' ' < ../keep)
145 for APP in $(ls lib); do
b316d22 Make strip command flexible
Uwe Dauernheim authored
146 [ -d lib/$APP ] &&
37773be @sedrik Added the Erlang build scripts
sedrik authored
147 echo "Not listed in keep file" >> lib/$APP/SKIP
148 done
149 for KEEP in $KEEPSIES; do
150 show "Keeping $KEEP"
b316d22 Make strip command flexible
Uwe Dauernheim authored
151 rm -f lib/$KEEP/SKIP
37773be @sedrik Added the Erlang build scripts
sedrik authored
152 done
153
154 show "Creating bootstrap and building"
155 ./otp_build boot
156
157 for KEEP in $KEEPSIES; do
158 show "Removing prebuilt files in $KEEP"
159 rm lib/$KEEP/ebin/*.beam
160 done
161
162 show "Creating release"
163 ./otp_build release
164
1b2c48d @sedrik Added the Erlang build scripts
sedrik authored
165 echo $(pwd)
166
11d6673 Further steps to set up Toolchain correctly
Uwe Dauernheim authored
167 pushd release/${HOST}/ 2> /dev/null || (show "Building release failed!" ; exit 1)
37773be @sedrik Added the Erlang build scripts
sedrik authored
168
169 show "Running Install script to setup paths and executables"
170 ./Install -cross -minimal $TARGET_ERL_ROOT
171 rm Install
172
173 if [ $STRIP_BEAM == true ]
174 then
175 show "Stripping beam files"
4ab888a Fix hardcoded OTP versino
Uwe Dauernheim authored
176 erl -eval "beam_lib:strip_release('${WD}/otp_src_${VERSION}/release/${HOST}')" -s init stop
37773be @sedrik Added the Erlang build scripts
sedrik authored
177 fi
178
179 if [ $STRIP_BIN == true ]
180 then
181 show "Stripping erts binaries"
b316d22 Make strip command flexible
Uwe Dauernheim authored
182 $STRIP_CMD erts-*/bin/*
37773be @sedrik Added the Erlang build scripts
sedrik authored
183 fi
184
185 show "Removing source code, documentation, and examples"
186 for DIR in $(ls | grep erts) lib/*; do
187 rm -rf ${DIR}/src
188 rm -rf ${DIR}/include
189 rm -rf ${DIR}/doc
190 rm -rf ${DIR}/man
191 rm -rf ${DIR}/examples
192 done
193 rm -rf usr/include
194 rm -rf misc
195
196 if [ $COMPRESS_APP = true ]
197 then
198 show "Compressing erlang applications"
199 pushd lib
200 for APP in $(ls); do
201 zip -r ${APP}.zip $APP
202 mv ${APP}.zip ${APP}.ez
203 rm -f -r $APP
204 done
205 popd
206 fi
207
208 show "Creating tarball"
209 tar czf ${WD}/${TAR_NAME}.tgz .
210
211 popd
1b2c48d @sedrik Added the Erlang build scripts
sedrik authored
212 popd
b316d22 Make strip command flexible
Uwe Dauernheim authored
213
214 ## Test the resulted binaries for TARGET compatability
714a045 Also ship compiler lib
Uwe Dauernheim authored
215 file ./otp_src_R14B01/bin/${HOST}/erlexec
Something went wrong with that request. Please try again.