Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ f5887924

History | View | Annotate | Download (13.7 KB)

1
#!/bin/bash
2
SCRIPT=$(readlink -f $0)
3
BASE_UL_DIR=`dirname $SCRIPT`
4
EXTERN_DIR="external_libs"
5
MAKE="make -j 4"
6
cd "$BASE_UL_DIR"
7

    
8
#by default build an check
9
BUILD_ALL=1
10

    
11
LIBTOOLIZE_PATH=`whereis -b libtoolize`
12
if [ "$LIBTOOLIZE_PATH" = "libtoolize:" ]; then
13
	echo "Can't find libtoolize. Try sudo apt-get install libtool"
14
	exit
15
fi
16

    
17
YASM_PATH=`whereis -b yasm`
18
if [ "$YASM_PATH" = "yasm:" ]; then
19
	echo "Can't find yasm assembler. Try sudo apt-get install yasm"
20
	exit
21
fi
22

    
23
#try to find libbz2 in your system
24
LOCAL_BZ2_A=`locate -l 1 libbz2.a`
25
if [ "$LOCAL_BZ2_A" = "" ]; then
26
	if [ -f "/usr/lib/libbz2.a" ]; then
27
		echo "You have file libbz2.a in default system"
28
		echo "setting path for it to default /usr/lib/libbz2.a"
29
		LOCAL_BZ2="/usr"
30
	else
31
		echo "you seem not to have file libbz2.a. Will be built locally."
32
		BUILD_BZ2=1
33
	fi
34
else
35
	LOCAL_BZ2=`dirname $LOCAL_BZ2_A`/..
36
	if [ ! -e "$LOCAL_BZ2/lib/libbz2.a" ]; then
37
		#wrong location and/or folders structure
38
		LOCAL_BZ2=""
39
		BUILD_BZ2=1
40
	fi
41
fi
42

    
43
#try to find libz in your system
44
LOCAL_Z_A=`locate -l 1 libz.a`
45
if [ "$LOCAL_Z_A" = "" ]; then
46
	if [ -f "/usr/lib/libz.a" ]; then
47
		echo "You have file libz.a in default system"
48
		echo "setting path for it to default /usr/lib/libz.a"
49
		LOCAL_Z="/usr"
50
	else
51
		echo "you seem not to have file libz.a. Will be built locally."
52
		BUILD_Z=1
53
	fi
54
else
55
	LOCAL_Z=`dirname $LOCAL_Z_A`/..
56
	if [ ! -e "$LOCAL_Z/lib/libz.a" ]; then
57
		#wrong location and/or folders structure
58
		LOCAL_Z=""
59
		BUILD_Z=1
60
	fi
61
fi
62

    
63
#clean all external libraries if CLEAN_EXTERNAL_BUILD=1
64
if [ -n "$CLEAN_EXTERNAL_BUILD" ]; then
65
	#remove previuos versions of external libs builds
66
	rm -r -f $EXTERN_DIR
67
fi
68

    
69
mkdir $EXTERN_DIR
70

    
71
TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2/temp_bzip2_install"
72
if [ -n "$BUILD_BZ2" ]; then
73
	#we have to build it either because of user will or because does not exist system wide
74
	if [ -z "$LOCAL_BZ2" ]; then
75
		#does not exist systemwide
76
		if [ -n "$BUILD_ALL" -a ! -e "$TEMP_BZ2" ]; then
77
			#we erase and rebuild since the installation is not there
78
			cd "$BASE_UL_DIR/$EXTERN_DIR"
79
			rm -r -f bzip2
80
			rm -f bzip2-1.0.5.tar.gz
81
			#get and compile latest bzip2 library
82
			wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz; tar xzf bzip2-1.0.5.tar.gz; mv bzip2-1.0.5 bzip2
83
			cd bzip2
84
			#make and install in local folder
85
			$MAKE; $MAKE install PREFIX="$TEMP_BZ2"
86
		fi
87
		#previous local install is existing, just set pointer to it
88
		#or override location if it was set as systemwide
89
		LOCAL_BZ2=$TEMP_BZ2
90
	fi
91
fi
92

    
93
TEMP_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib/temp_zlib_install"
94
if [ -n "$BUILD_Z" ]; then
95
	#we have to build it either because of user will or because does not exist system wide
96
	if [ -z "$LOCAL_Z" ]; then
97
		#does not exist systemwide
98
		if [ -n "$BUILD_ALL" -a ! -e "$TEMP_Z" ]; then
99
			cd "$BASE_UL_DIR/$EXTERN_DIR"
100
			rm -r -f zlib
101
			rm -f zlib-1.2.5.tar.gz
102
			#get and compile latest zlib library
103
			wget http://zlib.net/zlib-1.2.5.tar.gz; tar xzf zlib-1.2.5.tar.gz; mv zlib-1.2.5 zlib
104
			cd zlib
105
			#make and install in local folder
106
			./configure --prefix="$TEMP_Z"
107
			$MAKE; $MAKE install
108
		fi
109
		#previous local install is existing, just set pointer to it
110
		#or override location if it was set as systemwide
111
		LOCAL_Z=$TEMP_Z
112
	fi
113
fi
114

    
115
TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install"
116
if [ -n "$BUILD_X264" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_X264" ]; then
117
	cd "$BASE_UL_DIR/$EXTERN_DIR"
118
	rm -r -f x264
119
	#get and compile latest x264 library
120
	git clone git://git.videolan.org/x264.git
121
	cd x264
122
	#make and install in local folder
123
	./configure --prefix="$TEMP_X264"
124
	$MAKE; $MAKE install
125
fi
126

    
127
TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install"
128
if [ -n "$BUILD_MP3LAME" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MP3LAME" ]; then
129
	cd "$BASE_UL_DIR/$EXTERN_DIR"
130
	rm -r -f mp3lame
131
	#get and compile latest mp3lame library
132
	rm -f lame-3.98.4.tar.gz
133
	wget http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download; tar xzf lame-3.98.4.tar.gz; mv lame-3.98.4 mp3lame;
134
	cd mp3lame
135
	#make and install in local folder
136
	./configure --disable-gtktest --disable-frontend --prefix="$TEMP_MP3LAME"
137
	$MAKE; $MAKE install
138
fi
139

    
140
TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install"
141
if [ ! -e "$TEMP_X264/lib/libx264.a" ] || [ ! -e "$TEMP_MP3LAME/lib/libmp3lame.a" ] || [ ! -e "$LOCAL_Z/lib/libz.a" ] || [ ! -e "$LOCAL_BZ2/lib/libbz2.a" ]; then
142
	echo "Compilation of ffmpeg dependancies failed. Check your internet connection and errors. Exiting."
143
fi
144
if [ -n "$BUILD_FFMPEG" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FFMPEG" ]; then
145
	cd "$BASE_UL_DIR/$EXTERN_DIR"
146
	rm -r -f ffmpeg
147
	#get and compile ffmpeg with x264 support
148
	#get latest snapshot
149
	#rm -f ffmpeg-checkout-snapshot.tar.bz2
150
	#wget http://ffmpeg.org/releases/ffmpeg-checkout-snapshot.tar.bz2; tar xjf ffmpeg-checkout-snapshot.tar.bz2; mv ffmpeg-checkout-20* ffmpeg
151
	#do not get latest snapshot
152
	#get a release tarball instead
153
	rm -f ffmpeg-0.6.tar.bz2
154
	wget http://ffmpeg.org/releases/ffmpeg-0.6.tar.bz2; tar xjf ffmpeg-0.6.tar.bz2; mv ffmpeg-0.6 ffmpeg
155
	#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
156
	#do not get latest snapshot
157
	#get instead a specific one because allows output video rate resampling
158
	#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
159
	cd ffmpeg
160
	./configure --enable-gpl --enable-nonfree --enable-version3 --enable-libmp3lame --enable-libx264 --enable-pthreads --extra-cflags="-I../x264/temp_x264_install/include -I../mp3lame/temp_mp3lame_install/include -I$LOCAL_BZ2/include  -I$LOCAL_Z/include" --extra-ldflags="-L../x264/temp_x264_install/lib -L../mp3lame/temp_mp3lame_install/lib -L$LOCAL_BZ2/lib -L$LOCAL_Z/lib" --disable-doc --disable-ffplay --disable-ffprobe --disable-ffserver --prefix="$TEMP_FFMPEG"
161
	$MAKE; $MAKE install
162
fi
163

    
164
TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install"
165
if [ -n "$BUILD_MHD" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MHD" ]; then
166
	cd "$BASE_UL_DIR/$EXTERN_DIR"
167
	rm -r -f libmicrohttpd
168
	#get and compile libmicrohttpd lib
169
	svn --non-interactive checkout https://ng.gnunet.org/svn/libmicrohttpd
170
	cd libmicrohttpd
171
	autoreconf -fi
172
	./configure --disable-curl --disable-https --enable-messages --disable-client-side --prefix="$TEMP_MHD"
173
	$MAKE; $MAKE install
174
fi
175

    
176
TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl/temp_sdl_install"
177
if [ -n "$BUILD_SDL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL" ]; then
178
	cd "$BASE_UL_DIR/$EXTERN_DIR"
179
	rm -r -r sdl
180
	#get and compile SDL lib
181
	rm -f SDL-1.2.14.tar.gz
182
	wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz; tar xzf SDL-1.2.14.tar.gz; mv SDL-1.2.14 sdl
183
	cd sdl
184
	#make and install in local folder
185
	./configure --disable-video-directfb --prefix="$TEMP_SDL"
186
	$MAKE; $MAKE install
187
fi
188

    
189
if [ -n "$BUILD_SDLIMAGE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_image.a" ]; then
190
	cd "$BASE_UL_DIR/$EXTERN_DIR"
191
	rm -r -r sdlimage
192
	#get and compile SDLIMAGE lib
193
	rm -f SDL_image-1.2.10.tar.gz
194
	wget http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.10.tar.gz; tar xzf SDL_image-1.2.10.tar.gz; mv SDL_image-1.2.10 sdlimage
195
	cd sdlimage
196
	#make and install in local SDL folder
197
	./configure --prefix="$TEMP_SDL"
198
	$MAKE; $MAKE install
199
fi
200

    
201
# SDL_ttf depends on freetype
202
TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install"
203
if [ -n "$BUILD_FREETYPE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FREETYPE" ]; then
204
	cd "$BASE_UL_DIR/$EXTERN_DIR"
205
	rm -r -r freetype
206
	#get and compile SDLTTF lib
207
	rm -f freetype-2.1.10.tar.gz
208
	wget http://mirror.lihnidos.org/GNU/savannah/freetype/freetype-2.1.10.tar.gz; tar xzf freetype-2.1.10.tar.gz; mv freetype-2.1.10 freetype
209
	cd freetype
210
	#make and install in local folder
211
	./configure --prefix="$TEMP_FREETYPE"
212
	$MAKE; $MAKE install
213
fi
214

    
215
if [ -n "$BUILD_SDLTTF" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_ttf.a" ]; then
216
	cd "$BASE_UL_DIR/$EXTERN_DIR"
217
	rm -r -r sdlttf
218
	#get and compile SDLTTF lib
219
	rm -f SDL_ttf-2.0.10.tar.gz
220
	wget http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.10.tar.gz; tar xzf SDL_ttf-2.0.10.tar.gz; mv SDL_ttf-2.0.10 sdlttf
221
	cd sdlttf
222
	#make and install in local SDL folder
223
	./configure --with-freetype-prefix="$TEMP_FREETYPE" --with-sdl-prefix="$TEMP_SDL" --prefix="$TEMP_SDL"
224
	$MAKE; $MAKE install
225
fi
226

    
227
TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install"
228
if [ -n "$BUILD_CURL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_CURL" ]; then
229
	cd "$BASE_UL_DIR/$EXTERN_DIR"
230
	rm -r -r curl
231
	#get and compile CURL lib
232
	rm -f curl-7.21.0.tar.bz2
233
	wget http://curl.haxx.se/download/curl-7.21.0.tar.bz2; tar xjf curl-7.21.0.tar.bz2; mv curl-7.21.0 curl
234
	cd curl
235
	#make and install in local folder
236
	./configure --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --without-libssh2 --without-ssl --without-krb4 --enable-static --disable-shared --without-zlib --without-libidn --prefix="$TEMP_CURL"
237
	$MAKE; $MAKE install
238
fi
239

    
240
#set needed paths to external libraries
241
echo "-----"
242
LOCAL_X264=$TEMP_X264
243
echo "path for X264 dependancy set to $LOCAL_X264"
244
LOCAL_MP3LAME=$TEMP_MP3LAME
245
echo "path for MP3LAME dependancy set to $LOCAL_MP3LAME"
246
LOCAL_FFMPEG=$TEMP_FFMPEG
247
echo "path for FFMPEG dependancy set to $LOCAL_FFMPEG"
248
LOCAL_MHD=$TEMP_MHD
249
echo "path for LIBMICROHTTPD dependancy set to $LOCAL_MHD"
250
LOCAL_ABS_SDL=$TEMP_SDL
251
echo "path for SDL dependancy set to $LOCAL_ABS_SDL"
252
LOCAL_SDLIMAGE=$TEMP_SDL
253
echo "path for SDLIMAGE dependancy set to $LOCAL_SDLIMAGE"
254
LOCAL_SDLTTF=$TEMP_SDL
255
echo "path for SDLTTF dependancy set to $LOCAL_SDLTTF"
256
LOCAL_FREETYPE=$TEMP_FREETYPE
257
echo "path for FREETYPE dependancy set to $LOCAL_FREETYPE"
258
LOCAL_CURL=$TEMP_CURL
259
echo "path for CURL dependancy set to $LOCAL_CURL"
260

    
261
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
262
echo "path for ZLIB dependancy is set to $LOCAL_Z"
263
echo "-----"
264

    
265
#compile the UL external applications
266
#chunker_streamer and chunker_player
267
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse" ]; then
268
	LOCAL_CONFUSE="$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse"
269
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
270
else
271
	LOCAL_CONFUSE_A=`locate -l 1 libconfuse.a`
272
	if [ "$LOCAL_CONFUSE_A" = "" ]; then
273
		if [ -f "/usr/lib/libconfuse.a" ]; then
274
			echo "You have file libconfuse.a in default system"
275
			echo "setting path for it to default /usr/lib/libconfuse.a"
276
			LOCAL_CONFUSE="/usr"
277
		else
278
			echo "you seem not to have file libconfuse.a. EXITING."
279
			exit
280
		fi
281
	else
282
		LOCAL_CONFUSE=`dirname $LOCAL_CONFUSE_A`/..
283
	fi
284
fi
285

    
286
#CHUNKER_STREAMER
287
echo "----------------COMPILING CHUNKER STREAMER"
288
cd "$BASE_UL_DIR"
289
cd chunker_streamer
290
$MAKE clean
291
LOCAL_X264=$LOCAL_X264 LOCAL_MP3LAME=$LOCAL_MP3LAME LOCAL_FFMPEG=$LOCAL_FFMPEG LOCAL_BZ2=$LOCAL_BZ2 LOCAL_Z=$LOCAL_Z LOCAL_CONFUSE=$LOCAL_CONFUSE LOCAL_CURL=$LOCAL_CURL $MAKE
292
echo "----------------FINISHED COMPILING CHUNKER STREAMER"
293

    
294
#CHUNKER_PLAYER
295
echo "----------------COMPILING CHUNKER PLAYER"
296
cd "$BASE_UL_DIR"
297
cd chunker_player
298
$MAKE clean
299
LOCAL_X264=$LOCAL_X264 LOCAL_MP3LAME=$LOCAL_MP3LAME LOCAL_FFMPEG=$LOCAL_FFMPEG LOCAL_BZ2=$LOCAL_BZ2 LOCAL_Z=$LOCAL_Z LOCAL_CONFUSE=$LOCAL_CONFUSE LOCAL_MHD=$LOCAL_MHD LOCAL_ABS_SDL=$LOCAL_ABS_SDL LOCAL_SDLIMAGE=$LOCAL_SDLIMAGE LOCAL_FREETYPE=$LOCAL_FREETYPE LOCAL_SDLTTF=$LOCAL_SDLTTF $MAKE
300
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
301

    
302
#compile a version of offerstreamer with UL enabled
303
#static needs fix??
304
cd "$BASE_UL_DIR/../OfferStreamer"
305
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent" ]; then
306
	LOCAL_EVENT="$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent"
307
	echo "found LIBEVENT in $LOCAL_EVENT"
308
else
309
	LOCAL_EVENT_A=`locate -l 1 libevent.a`
310
	if [ "$LOCAL_EVENT_A" = "" ]; then
311
		if [ -f "/usr/lib/libevent.a" ]; then
312
			echo "You have file libevent.a in default system"
313
			echo "setting path for it to default /usr/lib/libevent.a"
314
			LOCAL_EVENT="/usr"
315
		else
316
			echo "you seem not to have file libevent.a. EXITING."
317
			exit
318
		fi
319
	else
320
		LOCAL_EVENT=`dirname $LOCAL_EVENT_A`/..
321
	fi
322
fi
323
$MAKE clean
324
ULPLAYER=$BASE_UL_DIR ULPLAYER_EXTERNAL_LIBS=$EXTERN_DIR LIBEVENT_DIR=$LOCAL_EVENT ML=1 STATIC=1 MONL=$MONL IO=$IO DEBUG= THREADS=$THREADS $MAKE
325

    
326
#check if all is ok
327
echo "============== RESULTS ==================="
328

    
329
cd "$BASE_UL_DIR/chunker_streamer"
330
if [ -f "chunker_streamer" ]; then
331
	echo "chunker_streamer OK"
332
	C_STREAMER_EXE=`ls -la chunker_streamer`
333
	echo "$C_STREAMER_EXE"
334
	#now we want the bare name
335
	C_STREAMER_EXE=`ls chunker_streamer`
336
else
337
	echo "chunker_streamer FAIL"
338
fi
339

    
340
cd "$BASE_UL_DIR/chunker_player"
341
if [ -f "chunker_player" ]; then
342
	echo "chunker_player OK"
343
	C_PLAYER_EXE=`ls -la chunker_player`
344
	echo "$C_PLAYER_EXE"
345
	#now we want the bare name
346
	C_PLAYER_EXE=`ls chunker_player`
347
else
348
	echo "chunker_player FAIL"
349
fi
350

    
351
cd "$BASE_UL_DIR/../OfferStreamer"
352
echo "Check if the http binary is among these offerstreamers:"
353
ls -la offerstreamer* | grep -v ".o$"
354
echo "Your UL-enabled offerstreamer should be..."
355
O_TARGET_EXE=`ls offerstreamer* | grep -v ".o$" | grep $IO`
356
echo "$O_TARGET_EXE"
357
if [ -f "$O_TARGET_EXE" ]; then
358
	echo "...and i found it."
359
else
360
	echo "...but sadly it appears build FAILED!."
361
fi
362

    
363
#packaging for distribution
364
cd "$BASE_UL_DIR/chunker_player"
365
if [ -f "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" -a -f "$C_PLAYER_EXE" ]; then
366
	echo "============== PACKAGING NAPAPLAYER ==================="
367
	rm -f -r napaplayer
368
	rm -f -r napaplayer.tar.gz
369
	mkdir napaplayer
370
	mkdir napaplayer/icons
371
	cp icons/* napaplayer/icons/
372
	cp channels.conf napaplayer/
373
	cp napalogo*.bmp napaplayer/
374
	cp *.ttf napaplayer/
375
	cp "$C_PLAYER_EXE" napaplayer/
376
	cp "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" napaplayer/
377
	cd napaplayer/
378
	ln -s "$O_TARGET_EXE" ./offerstreamer
379
	cd ..
380
	tar cvfz napaplayer.tar.gz napaplayer
381
	if [ -s "napaplayer.tar.gz" ]; then
382
		#it has size>0. OK!
383
		echo "Here is your napaplayer tarball. Enjoy!"
384
		ls -la napaplayer.tar.gz
385
	else
386
		echo "Sorry something went wrong during packaging napaplayer."
387
	fi
388
else
389
	echo ""
390
	echo "Not packaging napaplayer since build failed."
391
fi
392

    
393
echo "Finished build UL script"
394