Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ 0e85a031

History | View | Annotate | Download (13.8 KB)

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

    
8
#set some defaults
9
IO=${IO:-"httpevent"}
10
MONL=${MONL:-1}
11
ML=${ML:-1}
12

    
13
#by default build an check
14
BUILD_ALL=1
15

    
16
LIBTOOLIZE_PATH=`whereis -b libtoolize`
17
if [ "$LIBTOOLIZE_PATH" = "libtoolize:" ]; then
18
	echo "Can't find libtoolize. Try sudo apt-get install libtool"
19
	exit
20
fi
21

    
22
YASM_PATH=`whereis -b yasm`
23
if [ "$YASM_PATH" = "yasm:" ]; then
24
	echo "Can't find yasm assembler. Try sudo apt-get install yasm"
25
	exit
26
fi
27

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

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

    
68
#clean all external libraries if CLEAN_EXTERNAL_BUILD=1
69
if [ -n "$CLEAN_EXTERNAL_BUILD" ]; then
70
	#remove previuos versions of external libs builds
71
	rm -r -f $EXTERN_DIR
72
fi
73

    
74
mkdir $EXTERN_DIR
75

    
76
TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2/temp_bzip2_install"
77
if [ -n "$BUILD_BZ2" ]; then
78
	#we have to build it either because of user will or because does not exist system wide
79
	if [ -z "$LOCAL_BZ2" ]; then
80
		#does not exist systemwide
81
		if [ -n "$BUILD_ALL" -a ! -e "$TEMP_BZ2" ]; then
82
			#we erase and rebuild since the installation is not there
83
			cd "$BASE_UL_DIR/$EXTERN_DIR"
84
			rm -r -f bzip2
85
			rm -f bzip2-1.0.5.tar.gz
86
			#get and compile latest bzip2 library
87
			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
88
			cd bzip2
89
			#make and install in local folder
90
			$MAKE; $MAKE install PREFIX="$TEMP_BZ2"
91
		fi
92
		#previous local install is existing, just set pointer to it
93
		#or override location if it was set as systemwide
94
		LOCAL_BZ2=$TEMP_BZ2
95
	fi
96
fi
97

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

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

    
132
TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install"
133
if [ -n "$BUILD_MP3LAME" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MP3LAME" ]; then
134
	cd "$BASE_UL_DIR/$EXTERN_DIR"
135
	rm -r -f mp3lame
136
	#get and compile latest mp3lame library
137
	rm -f lame-3.98.4.tar.gz
138
	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;
139
	cd mp3lame
140
	#make and install in local folder
141
	./configure --disable-gtktest --disable-frontend --prefix="$TEMP_MP3LAME"
142
	$MAKE; $MAKE install
143
fi
144

    
145
TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install"
146
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
147
	echo "Compilation of ffmpeg dependancies failed. Check your internet connection and errors. Exiting."
148
fi
149
if [ -n "$BUILD_FFMPEG" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FFMPEG" ]; then
150
	cd "$BASE_UL_DIR/$EXTERN_DIR"
151
	rm -r -f ffmpeg
152
	#get and compile ffmpeg with x264 support
153
	#get latest snapshot
154
	#rm -f ffmpeg-checkout-snapshot.tar.bz2
155
	#wget http://ffmpeg.org/releases/ffmpeg-checkout-snapshot.tar.bz2; tar xjf ffmpeg-checkout-snapshot.tar.bz2; mv ffmpeg-checkout-20* ffmpeg
156
	#do not get latest snapshot
157
	#get a release tarball instead
158
	rm -f ffmpeg-0.6.tar.bz2
159
	wget http://ffmpeg.org/releases/ffmpeg-0.6.tar.bz2; tar xjf ffmpeg-0.6.tar.bz2; mv ffmpeg-0.6 ffmpeg
160
	#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
161
	#do not get latest snapshot
162
	#get instead a specific one because allows output video rate resampling
163
	#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
164
	cd ffmpeg
165
	./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"
166
	$MAKE; $MAKE install
167
fi
168

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

    
181
TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl/temp_sdl_install"
182
if [ -n "$BUILD_SDL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL" ]; then
183
	cd "$BASE_UL_DIR/$EXTERN_DIR"
184
	rm -r -r sdl
185
	#get and compile SDL lib
186
	rm -f SDL-1.2.14.tar.gz
187
	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
188
	cd sdl
189
	#make and install in local folder
190
	./configure --disable-video-directfb --prefix="$TEMP_SDL"
191
	$MAKE; $MAKE install
192
fi
193

    
194
if [ -n "$BUILD_SDLIMAGE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_image.a" ]; then
195
	cd "$BASE_UL_DIR/$EXTERN_DIR"
196
	rm -r -r sdlimage
197
	#get and compile SDLIMAGE lib
198
	rm -f SDL_image-1.2.10.tar.gz
199
	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
200
	cd sdlimage
201
	#make and install in local SDL folder
202
	./configure --prefix="$TEMP_SDL"
203
	$MAKE; $MAKE install
204
fi
205

    
206
# SDL_ttf depends on freetype
207
TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install"
208
if [ -n "$BUILD_FREETYPE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FREETYPE" ]; then
209
	cd "$BASE_UL_DIR/$EXTERN_DIR"
210
	rm -r -r freetype
211
	#get and compile SDLTTF lib
212
	rm -f freetype-2.1.10.tar.gz
213
	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
214
	cd freetype
215
	#make and install in local folder
216
	./configure --prefix="$TEMP_FREETYPE"
217
	$MAKE; $MAKE install
218
fi
219

    
220
if [ -n "$BUILD_SDLTTF" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_ttf.a" ]; then
221
	cd "$BASE_UL_DIR/$EXTERN_DIR"
222
	rm -r -r sdlttf
223
	#get and compile SDLTTF lib
224
	rm -f SDL_ttf-2.0.10.tar.gz
225
	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
226
	cd sdlttf
227
	#make and install in local SDL folder
228
	./configure --with-freetype-prefix="$TEMP_FREETYPE" --with-sdl-prefix="$TEMP_SDL" --prefix="$TEMP_SDL"
229
	$MAKE; $MAKE install
230
fi
231

    
232
TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install"
233
if [ -n "$BUILD_CURL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_CURL" ]; then
234
	cd "$BASE_UL_DIR/$EXTERN_DIR"
235
	rm -r -r curl
236
	#get and compile CURL lib
237
	rm -f curl-7.21.0.tar.bz2
238
	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
239
	cd curl
240
	#make and install in local folder
241
	./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"
242
	$MAKE; $MAKE install
243
fi
244

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

    
266
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
267
echo "path for ZLIB dependancy is set to $LOCAL_Z"
268
echo "-----"
269

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

    
291
#CHUNKER_STREAMER
292
echo "----------------COMPILING CHUNKER STREAMER"
293
cd "$BASE_UL_DIR"
294
cd chunker_streamer
295
$MAKE clean
296
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
297
echo "----------------FINISHED COMPILING CHUNKER STREAMER"
298

    
299
#CHUNKER_PLAYER
300
echo "----------------COMPILING CHUNKER PLAYER"
301
cd "$BASE_UL_DIR"
302
cd chunker_player
303
$MAKE clean
304
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
305
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
306

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

    
331
#check if all is ok
332
echo "============== RESULTS ==================="
333

    
334
cd "$BASE_UL_DIR/chunker_streamer"
335
if [ -f "chunker_streamer" ]; then
336
	echo "chunker_streamer OK"
337
	C_STREAMER_EXE=`ls -la chunker_streamer`
338
	echo "$C_STREAMER_EXE"
339
	#now we want the bare name
340
	C_STREAMER_EXE=`ls chunker_streamer`
341
else
342
	echo "chunker_streamer FAIL"
343
fi
344

    
345
cd "$BASE_UL_DIR/chunker_player"
346
if [ -f "chunker_player" ]; then
347
	echo "chunker_player OK"
348
	C_PLAYER_EXE=`ls -la chunker_player`
349
	echo "$C_PLAYER_EXE"
350
	#now we want the bare name
351
	C_PLAYER_EXE=`ls chunker_player`
352
else
353
	echo "chunker_player FAIL"
354
fi
355

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

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

    
399
echo "Finished build UL script"
400