Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ a0e0d6ff

History | View | Annotate | Download (24.4 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
which svn >/dev/null || { echo "CANNOT build UL Applications: svn missing. Please install subversion, then retry!"; exit 1; }
9
which libtoolize >/dev/null || { echo "CANNOT build UL Applications: libtool missing. Please install libtool, then retry!"; exit 1; }
10
which yasm >/dev/null || { echo "CANNOT build UL Applications: yasm missing. Please install yasm, then retry!"; exit 1; }
11
which git >/dev/null || { echo "CANNOT build UL Applications: git missing. Please install git, then retry!"; exit 1; }
12

    
13
#set some defaults
14
IO=${IO:-"httpevent"}
15
MONL=${MONL:-1}
16
ML=${ML:-1}
17

    
18
if [ "$HOSTARCH" = "mingw32" ]; then
19
	MINGW=1
20
fi
21

    
22
#by default build an check
23
BUILD_ALL=1
24

    
25
LIBTOOLIZE_PATH=`whereis -b libtoolize`
26
if [ "$LIBTOOLIZE_PATH" = "libtoolize:" ]; then
27
	echo "Can't find libtoolize. Try sudo apt-get install libtool"
28
	exit
29
fi
30

    
31
YASM_PATH=`whereis -b yasm`
32
if [ "$YASM_PATH" = "yasm:" ]; then
33
	echo "Can't find yasm assembler. Try sudo apt-get install yasm"
34
	exit
35
fi
36

    
37
mkdir $EXTERN_DIR
38

    
39
if [ -n "$MINGW" ]; then
40
	TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2_mingw"
41
	if [ ! -e "$TEMP_BZ2/lib/libbz2.a" ]; then
42
		#we erase and rebuild since the installation is not there
43
		cd "$BASE_UL_DIR/$EXTERN_DIR"
44
		rm -r -f bzip2_mingw
45
		#get the latest bzip2 library
46
		wget http://switch.dl.sourceforge.net/project/gnuwin32/bzip2/1.0.5/bzip2-1.0.5-bin.zip; unzip bzip2-1.0.5-bin.zip -d bzip2_mingw
47
		wget http://sunet.dl.sourceforge.net/project/gnuwin32/bzip2/1.0.5/bzip2-1.0.5-lib.zip; unzip -o bzip2-1.0.5-lib.zip -d bzip2_mingw
48
		rm -f bzip2-1.0.5-lib.zip; rm -f bzip2-1.0.5-bin.zip;
49
	fi
50
	LOCAL_BZ2=$TEMP_BZ2
51
else
52
	#try to find libbz2 in your system
53
	LOCAL_BZ2_A=`locate -l 1 libbz2.a`
54
	if [ "$LOCAL_BZ2_A" = "" ]; then
55
		if [ -f "/usr/lib/libbz2.a" ]; then
56
			echo "You have file libbz2.a in default system"
57
			echo "setting path for it to default /usr/lib/libbz2.a"
58
			LOCAL_BZ2="/usr"
59
		else
60
			echo "you seem not to have file libbz2.a. Will be built locally."
61
			BUILD_BZ2=1
62
		fi
63
	else
64
		LOCAL_BZ2=`dirname $LOCAL_BZ2_A`/..
65
		if [ ! -e "$LOCAL_BZ2/lib/libbz2.a" ]; then
66
			#wrong location and/or folders structure
67
			LOCAL_BZ2=""
68
			BUILD_BZ2=1
69
		fi
70
	fi
71
fi
72

    
73
if [ -n "$MINGW" ]; then
74
	TEMP_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib_mingw"
75
	if [ ! -e "$TEMP_Z/lib/libz.a" ]; then
76
		cd "$BASE_UL_DIR/$EXTERN_DIR"
77
		rm -r -f zlib_mingw;
78
		#get the latest zlib libraries
79
		wget http://sunet.dl.sourceforge.net/project/gnuwin32/zlib/1.2.3/zlib-1.2.3-bin.zip; unzip zlib-1.2.3-bin.zip -d zlib_mingw
80
		wget http://kent.dl.sourceforge.net/project/gnuwin32/zlib/1.2.3/zlib-1.2.3-lib.zip; unzip -o zlib-1.2.3-lib.zip -d zlib_mingw
81
		rm -f zlib-1.2.3-bin.zip; rm -f zlib-1.2.3-lib.zip;
82
	fi
83
	LOCAL_Z=$TEMP_Z
84
else
85
	LOCAL_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib/temp_zlib_install_linux"
86
	if [ -f "$LOCAL_Z/lib/libz.a" ]; then
87
		echo "libz.a found in $LOCAL_Z/lib"
88
	else
89
		#force building locally
90
		#does not exist systemwide
91
		cd "$BASE_UL_DIR/$EXTERN_DIR"
92
		rm -r -f zlib
93
		#get and compile latest zlib library
94
		wget http://zlib.net/zlib-1.2.5.tar.gz; tar xzf zlib-1.2.5.tar.gz; mv zlib-1.2.5 zlib; rm -f zlib-1.2.5.tar.gz
95
		cd zlib
96
		#make and install in local folder
97
		./configure --prefix="$LOCAL_Z"
98
		$MAKE; $MAKE install
99
	fi
100

    
101
	#clean all external libraries if CLEAN_EXTERNAL_BUILD=1
102
	if [ -n "$CLEAN_EXTERNAL_BUILD" ]; then
103
		#remove previuos versions of external libs builds
104
		rm -r -f $EXTERN_DIR
105
	fi
106
fi
107
LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_Z/include"
108
LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_Z/lib"
109

    
110
if [ ! -n "$MINGW" ]; then
111
	TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2/temp_bzip2_install_linux"
112
	if [ -n "$BUILD_BZ2" ]; then
113
		#we have to build it either because of user will or because does not exist system wide
114
		if [ -z "$LOCAL_BZ2" ]; then
115
			#does not exist systemwide
116
			if [ -n "$BUILD_ALL" -a ! -e "$TEMP_BZ2" ]; then
117
				#we erase and rebuild since the installation is not there
118
				cd "$BASE_UL_DIR/$EXTERN_DIR"
119
				rm -r -f bzip2
120
				#get and compile latest bzip2 library
121
				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; rm -f bzip2-1.0.5.tar.gz
122
				cd bzip2
123
				#make and install in local folder
124
				$MAKE; $MAKE install PREFIX="$TEMP_BZ2"
125
			fi
126
			#previous local install is existing, just set pointer to it
127
			#or override location if it was set as systemwide
128
			LOCAL_BZ2=$TEMP_BZ2
129
		fi
130
	fi
131
fi
132

    
133
if [ -n "$MINGW" ]; then
134

    
135
	# plibc
136
	LOCAL_PLIBC="$BASE_UL_DIR/$EXTERN_DIR/plibc"
137
	if [ -f "$BASE_UL_DIR/$EXTERN_DIR/plibc/lib/libplibc.dll.a" ]; then
138
		echo "You have file libplibc.dll.a in default system: $BASE_UL_DIR/$EXTERN_DIR/plibc/lib/libplibc.dll.a"
139
	else
140
		cd "$BASE_UL_DIR/$EXTERN_DIR"
141
		rm -fR plibc
142
		wget http://ovh.dl.sourceforge.net/project/plibc/plibc/0.1.5/plibc-0.1.5.zip
143
		unzip plibc-0.1.5.zip -d plibc;
144
		rm -f plibc/lib/*.la
145
		rm -f plibc-0.1.5.zip
146
	fi
147
	LIBMICROHHTPD_FLAGS="-I$BASE_UL_DIR/$EXTERN_DIR/plibc/include"
148
	LIBMICROHHTPD_LDFLAGS="-L$BASE_UL_DIR/$EXTERN_DIR/plibc/lib"
149

    
150
	# libiconv
151
	LOCAL_LIBICONV="$BASE_UL_DIR/$EXTERN_DIR/libiconv/temp_libiconv_install_mingw"
152
	if [ -f "$LOCAL_LIBICONV/lib/libiconv.a" ]; then
153
		echo "libiconv.a found in $LOCAL_LIBICONV/lib"
154
	else
155
		cd "$BASE_UL_DIR/$EXTERN_DIR"
156
		rm -fR libiconv
157
		
158
		#download binaries
159
		#~ wget http://kent.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-dep.zip; unzip libintl-0.14.4-dep.zip -d libiconv
160
		#~ mkdir -p $LOCAL_LIBICONV/lib/
161
		#~ mv libiconv/*.dll $LOCAL_LIBICONV/lib/
162
		#~ rm -f libintl-0.14.4-dep.zip
163
		
164
		#build from sources
165
		wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz
166
		tar zxvf libiconv-1.13.tar.gz; mv libiconv-1.13 libiconv; rm -f libiconv-1.13.tar.gz; cd libiconv
167
		./configure --enable-static ${HOSTARCH:+--host=$HOSTARCH} --prefix=$LOCAL_LIBICONV
168
		make
169
		make install
170
	fi
171
	LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBICONV/include"
172
	#~ LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBICONV/lib"
173

    
174
	LOCAL_LIBINTL="$BASE_UL_DIR/$EXTERN_DIR/libintl/temp_libintl_install_mingw"
175
	if [ -f "$LOCAL_LIBINTL/lib/libintl.dll.a" ] || [ -f "$LOCAL_LIBINTL/lib/libintl.a" ]; then
176
		echo "libintl libraries found in $LOCAL_LIBINTL/lib"
177
	else
178
		cd "$BASE_UL_DIR/$EXTERN_DIR"
179
		#download binaries
180
		rm -fR libintl
181
		wget http://garr.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-lib.zip; unzip -o libintl-0.14.4-lib.zip -d libintl
182
		wget http://switch.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-bin.zip; unzip -o libintl-0.14.4-bin.zip -d libintl
183
		rm -f libintl-0.14.4-bin.zip; rm -f libintl-0.14.4-lib.zip
184
		cd libintl
185
		mkdir -p $LOCAL_LIBINTL;
186
		mv bin $LOCAL_LIBINTL/; mv lib $LOCAL_LIBINTL/; mv include $LOCAL_LIBINTL/
187
		mv man $LOCAL_LIBINTL/; mv share $LOCAL_LIBINTL/
188
		
189
		# build from gettext sources
190
		#~ rm -fR gettext
191
		#~ rm -fR libintl
192
		#~ wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz
193
		#~ tar zxvf gettext-0.18.1.1.tar.gz; mv gettext-0.18.1.1 gettext; cd gettext
194
		#~ ./configure ${HOSTARCH:+--host=$HOSTARCH} --with-libiconv-prefix=$LOCAL_LIBICONV
195
		#~ cd gettext-runtime/intl
196
		#~ make
197
		#~ mkdir -p $LOCAL_LIBINTL/bin; mkdir -p $LOCAL_LIBINTL/include; mkdir -p $LOCAL_LIBINTL/lib
198
		#~ cp ./.libs/*a $LOCAL_LIBINTL/lib
199
		#~ cp ./.libs/*.dll $LOCAL_LIBINTL/bin
200
		#~ cp *.h $LOCAL_LIBINTL/include
201
		#~ cd ../../../
202
		#~ rm -f gettext-0.18.1.1.tar.gz
203
		#~ rm -fR gettext
204
	fi
205
	LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBINTL"
206
	LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBINTL/lib"
207

    
208
	# check for mingw pthread libs
209
	LOCAL_PTHREAD="$BASE_UL_DIR/$EXTERN_DIR/pthreads"
210
	if [ -f "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthread.a" ]; then
211
		echo "libpthread.a in $LOCAL_PTHREAD/lib/"
212
	else
213
		cd "$BASE_UL_DIR/$EXTERN_DIR"
214
		rm -fR pthreads
215
		wget http://www.mirrorservice.org/sites/sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz
216
		tar zxvf pthreads-w32-2-8-0-release.tar.gz; mv pthreads-w32-2-8-0-release pthreads; rm -f pthreads-w32-2-8-0-release.tar.gz;
217
		cd pthreads
218
		mkdir -p ./{include,lib,bin}
219
		make CROSS=i586-mingw32msvc- GC-inlined
220
		mv libpthreadGC2.a ./lib
221
		mv *.h ./include
222
		mv pthreadGC2.dll ./bin
223
		ln -s "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthreadGC2.a" "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthread.a"
224
	fi
225
	LIBMICROHHTPD_FLAGS="$LIBMICROHHTPD_FLAGS -I$BASE_UL_DIR/$EXTERN_DIR/pthreads/include"
226
	LIBMICROHHTPD_LDFLAGS="$LIBMICROHHTPD_LDFLAGS -L$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib"
227
fi
228

    
229
#libpng
230
if [ -n "$MINGW" ]; then
231
	LOCAL_LIBPNG="$BASE_UL_DIR/$EXTERN_DIR/libpng/temp_libpng_install_mingw"
232
else
233
	LOCAL_LIBPNG="$BASE_UL_DIR/$EXTERN_DIR/libpng/temp_libpng_install_linux"
234
fi
235
if [ -f "$LOCAL_LIBPNG/lib/libpng.a" ]; then
236
	echo "libpng.a found in $LOCAL_LIBPNG/lib"
237
else
238
	cd "$BASE_UL_DIR/$EXTERN_DIR"
239
	rm -fR libpng
240
	wget http://kent.dl.sourceforge.net/project/libpng/01-libpng-master/1.4.4/libpng-1.4.4.tar.gz
241
	tar zxvf libpng-1.4.4.tar.gz; rm -f libpng-1.4.4.tar.gz
242
	mv libpng-1.4.4 libpng; cd libpng;
243
	CFLAGS=-I$LOCAL_Z/include CPPFLAGS=-I$LOCAL_Z/include LDFLAGS=-L$LOCAL_Z/lib sh configure  ${HOSTARCH:+--host=$HOSTARCH} --prefix=$LOCAL_LIBPNG
244
	make
245
	make install
246
fi
247
LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBPNG/include"
248
LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBPNG/lib"
249

    
250
if [ -n "$MINGW" ]; then
251
	TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_mingw"
252
else
253
	TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_linux"
254
fi
255
if [ -n "$BUILD_X264" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_X264" ]; then
256
	cd "$BASE_UL_DIR/$EXTERN_DIR"
257
	
258
	if [ -e "x264" ]; then
259
		cd x264
260
		make clean
261
	else
262
		#get and compile latest x264 library
263
		git clone git://git.videolan.org/x264.git
264
		cd x264
265
	fi	
266
	
267
	#make and install in local folder
268
	./configure --prefix="$TEMP_X264" ${HOSTARCH:+--host=$HOSTARCH}
269
	$MAKE; $MAKE install
270
fi
271

    
272
if [ -n "$MINGW" ]; then
273
	TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_mingw"
274
else
275
	TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_linux"
276
fi
277
if [ -n "$BUILD_MP3LAME" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MP3LAME" ]; then
278
	cd "$BASE_UL_DIR/$EXTERN_DIR"
279
	
280
	if [ -e "mp3lame" ]; then
281
		cd mp3lame
282
		make clean
283
	else
284
		#get and compile latest mp3lame library
285
		rm -f lame-3.98.4.tar.gz
286
		wget http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download -O lame-3.98.4.tar.gz; tar xzf lame-3.98.4.tar.gz; rm -f lame-3.98.4.tar.gz; mv lame-3.98.4 mp3lame;
287
		cd mp3lame
288
	fi	
289

    
290
	#make and install in local folder
291
	./configure --disable-gtktest --disable-frontend --prefix="$TEMP_MP3LAME" ${HOSTARCH:+--host=$HOSTARCH}
292
	$MAKE; $MAKE install
293
fi
294

    
295
if [ -n "$MINGW" ]; then
296
	TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install_mingw"
297
else
298
	TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install_linux"
299
fi
300
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
301
	echo "Compilation of ffmpeg dependancies failed. Check your internet connection and errors. Exiting."
302
fi
303
if [ -n "$BUILD_FFMPEG" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FFMPEG" ]; then
304
	cd "$BASE_UL_DIR/$EXTERN_DIR"
305
	
306
	if [ -e "ffmpeg" ]; then
307
		cd ffmpeg
308
		make clean
309
	else
310
		#get and compile ffmpeg with x264 support
311
		#get latest snapshot
312
		#rm -f ffmpeg-checkout-snapshot.tar.bz2
313
		#wget http://ffmpeg.org/releases/ffmpeg-checkout-snapshot.tar.bz2; tar xjf ffmpeg-checkout-snapshot.tar.bz2; mv ffmpeg-checkout-20* ffmpeg
314
		#do not get latest snapshot
315
		#get a release tarball instead
316
		rm -f ffmpeg-0.6.tar.bz2
317
		wget http://ffmpeg.org/releases/ffmpeg-0.6.tar.bz2; tar xjf ffmpeg-0.6.tar.bz2; rm -f ffmpeg-0.6.tar.bz2; mv ffmpeg-0.6 ffmpeg
318
		#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
319
		#do not get latest snapshot
320
		#get instead a specific one because allows output video rate resampling
321
		#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
322
		cd ffmpeg
323
	fi	
324

    
325
	if [ -n "$MINGW" ]; then
326
		HOSTARCH_OLDSTYLE=${HOSTARCH:+--arch=i586 --enable-cross-compile --cross-prefix=i586-mingw32msvc- --target-os=$HOSTARCH --disable-sse}
327
	
328
		#configure bugfix
329
		sed -i -e 's/^SDL_CONFIG=/[ -z "$SDL_CONFIG" ] \&\& SDL_CONFIG=/g' ./configure;
330
		sed -i -e 's/check_cflags \+-Werror=missing-prototypes/#\0/g' configure;
331
	
332
		./configure $HOSTARCH_OLDSTYLE --enable-gpl --enable-nonfree --enable-version3 --enable-libmp3lame --enable-libx264 --disable-pthreads --extra-cflags="-I$TEMP_X264/include -I$TEMP_MP3LAME/include -I$LOCAL_BZ2/include  -I$LOCAL_Z/include" --extra-ldflags="-L$TEMP_X264/lib -L$TEMP_MP3LAME/lib -L$LOCAL_BZ2/lib -L$LOCAL_Z/lib" --disable-doc --disable-ffplay --disable-ffprobe --disable-ffserver --prefix="$TEMP_FFMPEG"
333
	else
334
		./configure --enable-gpl --enable-nonfree --enable-version3 --enable-libmp3lame --enable-libx264 --enable-pthreads --extra-cflags="-I$TEMP_X264/include -I$TEMP_MP3LAME/include -I$LOCAL_BZ2/include  -I$LOCAL_Z/include" --extra-ldflags="-L$TEMP_X264/lib -L$TEMP_MP3LAME/lib -L$LOCAL_BZ2/lib -L$LOCAL_Z/lib" --disable-doc --disable-ffplay --disable-ffprobe --disable-ffserver --prefix="$TEMP_FFMPEG"
335
	fi
336
	$MAKE; $MAKE install
337
fi
338

    
339
if [ -n "$MINGW" ]; then
340
	TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install_mingw"
341
else
342
	TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install_linux"
343
fi
344
if [ -n "$BUILD_MHD" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MHD" ]; then
345
	cd "$BASE_UL_DIR/$EXTERN_DIR"
346
	
347
	if [ -e "libmicrohttpd" ]; then
348
		cd libmicrohttpd
349
		make clean
350
	else
351
		#get and compile libmicrohttpd lib
352
		svn --non-interactive --trust-server-cert checkout https://ng.gnunet.org/svn/libmicrohttpd
353
		cd libmicrohttpd
354
	fi
355
	
356
	autoreconf -fi
357
	if [ -n "$MINGW" ]; then
358
		CFLAGS="$CFLAGS $LIBMICROHHTPD_FLAGS" CPPFLAGS="$CPPFLAGS $LIBMICROHHTPD_FLAGS" LDFLAGS="$LDFLAGS $LIBMICROHHTPD_LDFLAGS" ./configure ${HOSTARCH:+--host=$HOSTARCH} --disable-curl --disable-https --enable-messages --disable-client-side --prefix="$TEMP_MHD"
359
	else
360
		./configure --disable-curl --disable-https --enable-messages --disable-client-side --prefix="$TEMP_MHD"
361
	fi
362
	$MAKE; $MAKE install
363
fi
364

    
365
if [ -n "$MINGW" ]; then
366
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl_mingw/temp_sdl_install"
367
else
368
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl/temp_sdl_install_linux"
369
fi
370
if [ -n "$BUILD_SDL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL" ]; then
371
	cd "$BASE_UL_DIR/$EXTERN_DIR"
372

    
373
	if [ -n "$MINGW" ]; then
374
		if [ ! -e "sdl_mingw" ]; then
375
			# use binaries
376
			wget http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz; tar zxvf SDL-devel-1.2.14-mingw32.tar.gz; mv SDL-1.2.14 sdl_mingw;
377
			rm -f SDL-devel-1.2.14-mingw32.tar.gz;
378
			cd sdl_mingw
379
			mkdir temp_sdl_install
380
			mv bin $TEMP_SDL/; mv lib $TEMP_SDL/; mv include $TEMP_SDL/; mv share $TEMP_SDL/
381
		fi
382

    
383
		# build from sources
384
		#~ wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz; tar xzf SDL-1.2.14.tar.gz; rm -f SDL-1.2.14.tar.gz; mv SDL-1.2.14 sdl
385
		#make and install in local folder
386
		#~ ./configure ${HOSTARCH:+--host=$HOSTARCH} --disable-video-directfb --prefix="$TEMP_SDL"
387
		#~ $MAKE; $MAKE install
388
	else
389
		if [ -e "sdl" ]; then
390
			cd sdl
391
			make clean
392
		else
393
			#get and compile SDL lib
394
			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; rm -f SDL-1.2.14.tar.gz
395
			cd sdl
396
		fi
397
		#make and install in local folder
398
		./configure --disable-video-directfb --prefix="$TEMP_SDL"
399
		$MAKE; $MAKE install
400
	fi
401
fi
402

    
403
if [ -n "$BUILD_SDLIMAGE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_image.a" ]; then
404
	cd "$BASE_UL_DIR/$EXTERN_DIR"
405
	
406
	if [ -e "sdlimage" ]; then
407
		cd sdlimage
408
		make clean
409
	else
410
		#get and compile SDLIMAGE lib
411
		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
412
		rm -f SDL_image-1.2.10.tar.gz
413
		cd sdlimage
414
	fi
415
	
416
	#make and install in local SDL folder
417
	LIBPNG_CFLAGS="-I$LOCAL_LIBPNG/include" LIBPNG_LIBS="-L$LOCAL_LIBPNG/lib" CFLAGS="$CFLAGS $LIBSDLIMAGE_FLAGS -static" CPPFLAGS="$CPPFLAGS $LIBSDLIMAGE_FLAGS -static" LDFLAGS="$LDFLAGS $LIBSDLIMAGE_LDFLAGS -static" ./configure ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_SDL" --with-sdl-prefix="$TEMP_SDL" --disable-png-shared
418
	$MAKE; $MAKE install
419
fi
420

    
421
# SDL_ttf depends on freetype
422
if [ -n "$MINGW" ]; then
423
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_mingw"
424
else
425
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_linux"
426
fi
427
if [ -n "$BUILD_FREETYPE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FREETYPE" ]; then
428
	cd "$BASE_UL_DIR/$EXTERN_DIR"
429
	if [ -e "freetype" ]; then
430
		cd freetype
431
		make clean
432
	else
433
		#get and compile SDLTTF lib
434
		rm -f freetype-2.1.10.tar.gz
435
		wget http://mirror.lihnidos.org/GNU/savannah/freetype/freetype-2.1.10.tar.gz; tar xzf freetype-2.1.10.tar.gz; rm -f freetype-2.1.10.tar.gz; mv freetype-2.1.10 freetype
436
		cd freetype
437
	fi
438

    
439
	#make and install in local folder
440
	./configure ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_FREETYPE"
441
	$MAKE; $MAKE install
442
fi
443

    
444
if [ -n "$BUILD_SDLTTF" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_ttf.a" ]; then
445
	cd "$BASE_UL_DIR/$EXTERN_DIR"
446
	
447
	if [ -e "sdlttf" ]; then
448
		cd sdlttf
449
		make clean
450
	else
451
		#get and compile SDLTTF lib
452
		rm -f SDL_ttf-2.0.10.tar.gz
453
		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; rm -f SDL_ttf-2.0.10.tar.gz; mv SDL_ttf-2.0.10 sdlttf
454
		cd sdlttf
455
	fi
456

    
457
	#make and install in local SDL folder
458
	./configure ${HOSTARCH:+--host=$HOSTARCH} --with-freetype-prefix="$TEMP_FREETYPE" --with-sdl-prefix="$TEMP_SDL" --prefix="$TEMP_SDL"
459
	$MAKE; $MAKE install
460
fi
461

    
462
if [ -n "$MINGW" ]; then
463
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_mingw"
464
else
465
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_linux"
466
fi
467
if [ -n "$BUILD_CURL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_CURL" ]; then
468
	cd "$BASE_UL_DIR/$EXTERN_DIR"
469
	if [ -e "curl" ]; then
470
		cd curl
471
		make clean
472
	else
473
		#get and compile CURL lib
474
		rm -f curl-7.21.0.tar.bz2
475
		wget http://curl.haxx.se/download/curl-7.21.0.tar.bz2; tar xjf curl-7.21.0.tar.bz2; rm -f curl-7.21.0.tar.bz2; mv curl-7.21.0 curl
476
		cd curl
477
	fi
478

    
479
	#make and install in local folder
480
	./configure ${HOSTARCH:+--host=$HOSTARCH} --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"
481
	$MAKE; $MAKE install
482
fi
483

    
484
#set needed paths to external libraries
485
echo "-----"
486
LOCAL_X264=$TEMP_X264
487
echo "path for X264 dependancy set to $LOCAL_X264"
488
LOCAL_MP3LAME=$TEMP_MP3LAME
489
echo "path for MP3LAME dependancy set to $LOCAL_MP3LAME"
490
LOCAL_FFMPEG=$TEMP_FFMPEG
491
echo "path for FFMPEG dependancy set to $LOCAL_FFMPEG"
492
LOCAL_MHD=$TEMP_MHD
493
echo "path for LIBMICROHTTPD dependancy set to $LOCAL_MHD"
494
LOCAL_ABS_SDL=$TEMP_SDL
495
echo "path for SDL dependancy set to $LOCAL_ABS_SDL"
496
LOCAL_SDLIMAGE=$TEMP_SDL
497
echo "path for SDLIMAGE dependancy set to $LOCAL_SDLIMAGE"
498
LOCAL_SDLTTF=$TEMP_SDL
499
echo "path for SDLTTF dependancy set to $LOCAL_SDLTTF"
500
LOCAL_FREETYPE=$TEMP_FREETYPE
501
echo "path for FREETYPE dependancy set to $LOCAL_FREETYPE"
502
LOCAL_CURL=$TEMP_CURL
503
echo "path for CURL dependancy set to $LOCAL_CURL"
504

    
505
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
506
echo "path for ZLIB dependancy is set to $LOCAL_Z"
507
echo "-----"
508

    
509
#compile the UL external applications
510
#chunker_streamer and chunker_player
511
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse" ]; then
512
	LOCAL_CONFUSE="$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse"
513
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
514
else
515
	LOCAL_CONFUSE_A=`locate -l 1 libconfuse.a`
516
	if [ "$LOCAL_CONFUSE_A" = "" ]; then
517
		if [ -f "/usr/lib/libconfuse.a" ]; then
518
			echo "You have file libconfuse.a in default system"
519
			echo "setting path for it to default /usr/lib/libconfuse.a"
520
			LOCAL_CONFUSE="/usr"
521
		else
522
			echo "you seem not to have file libconfuse.a. EXITING."
523
			exit
524
		fi
525
	else
526
		LOCAL_CONFUSE=`dirname $LOCAL_CONFUSE_A`/..
527
	fi
528
fi
529

    
530
#CHUNKER_STREAMER
531

    
532
# streamer is not supported yet on windows
533
if [ ! -n "$MINGW" ]; then
534
	echo "----------------COMPILING CHUNKER STREAMER"
535
	cd "$BASE_UL_DIR"
536
	cd chunker_streamer
537
	$MAKE clean
538
	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
539
	echo "----------------FINISHED COMPILING CHUNKER STREAMER"
540
fi
541

    
542
#CHUNKER_PLAYER
543
echo "----------------COMPILING CHUNKER PLAYER"
544
cd "$BASE_UL_DIR"
545
cd chunker_player
546
$MAKE clean
547
LOCAL_PTHREAD=$LOCAL_PTHREAD LOCAL_LIBPNG=$LOCAL_LIBPNG LOCAL_LIBICONV=$LOCAL_LIBICONV LOCAL_LIBINTL=$LOCAL_LIBINTL LOCAL_PLIBC=$LOCAL_PLIBC 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
548
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
549

    
550
#compile a version of offerstreamer with UL enabled
551
#static needs fix??
552
cd "$BASE_UL_DIR/../OfferStreamer"
553
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent" ]; then
554
	LOCAL_EVENT="$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent"
555
	echo "found LIBEVENT in $LOCAL_EVENT"
556
else
557
	LOCAL_EVENT_A=`locate -l 1 libevent.a`
558
	if [ "$LOCAL_EVENT_A" = "" ]; then
559
		if [ -f "/usr/lib/libevent.a" ]; then
560
			echo "You have file libevent.a in default system"
561
			echo "setting path for it to default /usr/lib/libevent.a"
562
			LOCAL_EVENT="/usr"
563
		else
564
			echo "you seem not to have file libevent.a. EXITING."
565
			exit
566
		fi
567
	else
568
		LOCAL_EVENT=`dirname $LOCAL_EVENT_A`/..
569
	fi
570
fi
571

    
572
$MAKE IO=$IO clean
573
LOCAL_CURL=$LOCAL_CURL ULPLAYER=$BASE_UL_DIR ULPLAYER_EXTERNAL_LIBS=$EXTERN_DIR LIBEVENT_DIR=$LOCAL_EVENT ML=$ML STATIC=$STATIC MONL=$MONL IO=$IO DEBUG=$DEBUG THREADS=$THREADS $MAKE
574

    
575
#check if all is ok
576
echo "============== RESULTS ==================="
577

    
578
if [ ! -n "$MINGW" ]; then
579
	cd "$BASE_UL_DIR/chunker_streamer"
580
	if [ -f "chunker_streamer" ]; then
581
		echo "chunker_streamer OK"
582
		C_STREAMER_EXE=`ls -la chunker_streamer`
583
		echo "$C_STREAMER_EXE"
584
		#now we want the bare name
585
		C_STREAMER_EXE=`ls chunker_streamer`
586
	else
587
		echo "chunker_streamer FAIL"
588
	fi
589
fi
590

    
591
cd "$BASE_UL_DIR/chunker_player"
592
if [ -n "$MINGW" ]; then
593
	SUFFIX=".exe"
594
fi
595
if [ -f "chunker_player$SUFFIX" ]; then
596
	echo "chunker_player OK"
597
	C_PLAYER_EXE=`ls -la chunker_player$SUFFIX`
598
	echo "$C_PLAYER_EXE"
599
	#now we want the bare name
600
	C_PLAYER_EXE=`ls chunker_player$SUFFIX`
601
else
602
	echo "chunker_player FAIL"
603
fi
604

    
605
cd "$BASE_UL_DIR/../OfferStreamer"
606
echo "Check if the http binary is among these offerstreamers:"
607
ls -la offerstreamer* | grep -v ".o$"
608
echo "Your UL-enabled offerstreamer should be..."
609
O_TARGET_EXE=`ls offerstreamer* | grep -v ".o$" | grep $IO`
610
echo "$O_TARGET_EXE"
611
if [ -f "$O_TARGET_EXE" ]; then
612
	echo "...and i found it."
613
else
614
	echo "...but sadly it appears build FAILED!."
615
fi
616

    
617
#packaging for distribution
618
cd "$BASE_UL_DIR/chunker_player"
619
if [ -f "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" -a -f "$C_PLAYER_EXE" ]; then
620
	echo "============== PACKAGING NAPAPLAYER ==================="
621
	rm -f -r napaplayer
622
	mkdir napaplayer
623
	mkdir napaplayer/icons
624
	cp icons/* napaplayer/icons/
625
	cp channels.conf napaplayer/
626
	cp README napaplayer/
627
	cp napalogo*.bmp napaplayer/
628
	cp *.ttf napaplayer/
629
	cp "$C_PLAYER_EXE" napaplayer/
630
	if [ -n "$MINGW" ]; then
631
		cp "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" napaplayer/offerstreamer.exe
632
	else
633
		cp "$BASE_UL_DIR/../OfferStreamer/$O_TARGET_EXE" napaplayer/offerstreamer
634
	fi
635
	if [ -n "$MINGW" ]; then
636
		cp "$LOCAL_LIBICONV/bin/libiconv-2.dll" napaplayer/libiconv2.dll
637
		if [ -f "$LOCAL_LIBINTL/bin/libintl-8.dll" ]; then
638
			cp "$LOCAL_LIBINTL/bin/libintl-8.dll" napaplayer/
639
		else
640
			cp "$LOCAL_LIBINTL/bin/libintl3.dll" napaplayer/libintl-8.dll
641
		fi
642
		cp "$LOCAL_PLIBC/bin/libplibc-1.dll" napaplayer/
643
		cp "$LOCAL_PTHREAD/bin/pthreadGC2.dll" napaplayer/
644
		cp "$LOCAL_ABS_SDL/bin/SDL.dll" napaplayer/
645
		cp player.bat napaplayer/
646
		rm -f -r napaplayer.zip
647
		zip -r napaplayer napaplayer
648
		if [ -s "napaplayer.zip" ]; then
649
			#it has size>0. OK!
650
			echo "Here it is your napaplayer package. Enjoy!"
651
			ls -la napaplayer.zip
652
		else
653
			echo "Sorry something went wrong during packaging napaplayer."
654
		fi
655
	else
656
		rm -f -r napaplayer.tar.gz
657
		tar cvfz napaplayer.tar.gz napaplayer
658
		if [ -s "napaplayer.tar.gz" ]; then
659
			#it has size>0. OK!
660
			echo "Here it is your napaplayer tarball. Enjoy!"
661
			ls -la napaplayer.tar.gz
662
		else
663
			echo "Sorry something went wrong during packaging napaplayer."
664
		fi
665
	fi
666
else
667
	echo ""
668
	echo "Not packaging napaplayer since build failed."
669
fi
670

    
671
echo "Finished build UL script"
672