Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ e11386c0

History | View | Annotate | Download (27.4 KB)

1
#!/bin/bash
2
SCRIPT=$0
3
BASE_UL_DIR=`pwd`
4
EXTERN_DIR="external_libs"
5
MAKE="make -j 4"
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
if [ ! -n "MAC_OS" ]; then
12
  #we don't have git on osx - so we avoid using it
13
  which git >/dev/null || { echo "CANNOT build UL Applications: git missing. Please install git, then retry!"; exit 1; }
14
fi
15
WGET_OR_CURL=`which wget`
16
[ -n "$WGET_OR_CURL" ] || { WGET_OR_CURL=`which curl` ; WGET_OR_CURLOPT="-L -O"; }
17
[ -n "$WGET_OR_CURL" ] || { echo "please install wget or curl!"; exit 1; }
18

    
19
#set some defaults
20
IO=${IO:-"httpevent"}
21
MONL=${MONL:-1}
22
ML=${ML:-1}
23

    
24
if [ "$HOSTARCH" = "mingw32" ]; then
25
	MINGW=1
26
fi
27

    
28
#by default build an check
29
BUILD_ALL=1
30

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

    
37
YASM_PATH=`whereis yasm`
38
if [ "$YASM_PATH" = "yasm:" ]; then
39
	echo "Can't find yasm assembler. Try sudo apt-get install yasm"
40
	exit
41
fi
42

    
43
mkdir $EXTERN_DIR
44

    
45
if [ -n "$MINGW" ]; then
46
	TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2_mingw"
47
	if [ ! -e "$TEMP_BZ2/lib/libbz2.a" ]; then
48
		#we erase and rebuild since the installation is not there
49
		cd "$BASE_UL_DIR/$EXTERN_DIR"
50
		rm -r -f bzip2_mingw
51
		#get the latest bzip2 library
52
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
53
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
54
		rm -f bzip2-1.0.5-lib.zip; rm -f bzip2-1.0.5-bin.zip;
55
	fi
56
	LOCAL_BZ2=$TEMP_BZ2
57
else
58
	#try to find libbz2 in your system
59
	LOCAL_BZ2_A=/usr/lib/libbz2.a
60
	if [ ! -e $LOCAL_BZ2_A ]; then
61
		LOCAL_BZ2_A=`locate -l 1 libbz2.a`
62
		[ X$LOCAL_BZ2_A != X ] && LOCAL_BZ2=`dirname $LOCAL_BZ2_A`/..
63
		if [ ! -e "$LOCAL_BZ2/lib/libbz2.a" ]; then
64
			#wrong location and/or folders structure
65
			echo "you seem not to have file libbz2.a or the location is non-standard.Will be built locally."
66
			LOCAL_BZ2=""
67
			BUILD_BZ2=1
68
		fi
69
	else
70
		echo "You have file libbz2.a in default system"
71
		echo "setting path for it to default /usr/lib/libbz2.a"
72
		LOCAL_BZ2="/usr"
73
	fi
74
fi
75

    
76
if [ -n "$MINGW" ]; then
77
	TEMP_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib_mingw"
78
	if [ ! -e "$TEMP_Z/lib/libz.a" ]; then
79
		cd "$BASE_UL_DIR/$EXTERN_DIR"
80
		rm -r -f zlib_mingw;
81
		#get the latest zlib libraries
82
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
83
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
84
		rm -f zlib-1.2.3-bin.zip; rm -f zlib-1.2.3-lib.zip;
85
	fi
86
	LOCAL_Z=$TEMP_Z
87
else
88
	LOCAL_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib/temp_zlib_install_linux"
89
	if [ -f "$LOCAL_Z/lib/libz.a" ]; then
90
		echo "libz.a found in $LOCAL_Z/lib"
91
	else
92
		#force building locally
93
		#does not exist systemwide
94
		cd "$BASE_UL_DIR/$EXTERN_DIR"
95
		rm -r -f zlib
96
		#get and compile latest zlib library
97
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
98
		cd zlib
99
		#make and install in local folder
100
		./configure --prefix="$LOCAL_Z"
101
		$MAKE; $MAKE install
102
	fi
103

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

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

    
136

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

    
153
	# libiconv
154
	LOCAL_LIBICONV="$BASE_UL_DIR/$EXTERN_DIR/libiconv/temp_libiconv_install_mingw"
155
	if [ -f "$LOCAL_LIBICONV/lib/libiconv.a" ]; then
156
		echo "libiconv.a found in $LOCAL_LIBICONV/lib"
157
	else
158
		cd "$BASE_UL_DIR/$EXTERN_DIR"
159
		rm -fR libiconv
160
		
161
		#download binaries
162
		#~ 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
163
		#~ mkdir -p $LOCAL_LIBICONV/lib/
164
		#~ mv libiconv/*.dll $LOCAL_LIBICONV/lib/
165
		#~ rm -f libintl-0.14.4-dep.zip
166
		
167
		#build from sources
168
		$WGET_OR_CURL $WGET_OR_CURLOPT http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz
169
		tar zxvf libiconv-1.13.tar.gz; mv libiconv-1.13 libiconv; rm -f libiconv-1.13.tar.gz; cd libiconv
170
		./configure --enable-static ${HOSTARCH:+--host=$HOSTARCH} --prefix=$LOCAL_LIBICONV
171
		make
172
		make install
173
	fi
174
	LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBICONV/include"
175
	#~ LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBICONV/lib"
176

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

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

    
232

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

    
254

    
255
if [ -n "$MINGW" ]; then
256
	TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_mingw"
257
else
258
	TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_linux"
259
fi
260
if [ -n "$BUILD_X264" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_X264" ]; then
261
	cd "$BASE_UL_DIR/$EXTERN_DIR"
262
	if [ -e "x264" ]; then
263
		cd x264
264
		make clean
265
	else
266
		#get and compile latest x264 library
267
		if [ -n "$MAC_OS" ]; then
268
		   $WGET_OR_CURL $WGET_OR_CURLOPT ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20110115-2245.tar.bz2
269
		   tar yvfx x264-snapshot-20110115-2245.tar.bz2
270
		   rm -f x264-snapshot-20110115-2245.tar.bz2
271
		   mv x264-snapshot-20110115-2245/ x264
272
		else
273
		   git clone git://git.videolan.org/x264.git
274
		fi
275
		cd x264
276
	fi	
277

    
278
	#make and install in local folder
279
	./configure --prefix="$TEMP_X264" ${HOSTARCH:+--host=$HOSTARCH}
280
	$MAKE; $MAKE install
281
fi
282

    
283

    
284
if [ -n "$MINGW" ]; then
285
	TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_mingw"
286
else
287
	TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_linux"
288
fi
289
if [ -n "$BUILD_MP3LAME" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MP3LAME" ]; then
290
	cd "$BASE_UL_DIR/$EXTERN_DIR"
291
	
292
	if [ -e "mp3lame" ]; then
293
		cd mp3lame
294
		make clean
295
	else
296
		#get and compile latest mp3lame library
297
		rm -f lame-3.98.4.tar.gz
298
		$WGET_OR_CURL $WGET_OR_CURLOPT http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download; tar xzf download; rm -f download; mv lame-3.98.4 mp3lame;
299
		cd mp3lame
300
	fi	
301

    
302
	#make and install in local folder
303
	./configure --disable-gtktest --disable-frontend --prefix="$TEMP_MP3LAME" ${HOSTARCH:+--host=$HOSTARCH}
304
	$MAKE; $MAKE install
305
fi
306

    
307

    
308
if [ -n "$MINGW" ]; then
309
	TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install_mingw"
310
else
311
	TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install_linux"
312
fi
313
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
314
	echo "Compilation of ffmpeg dependancies failed. Check your internet connection and errors. Exiting."
315
fi
316
if [ -n "$BUILD_FFMPEG" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FFMPEG" ]; then
317
	cd "$BASE_UL_DIR/$EXTERN_DIR"
318
	
319
	if [ -e "ffmpeg" ]; then
320
		cd ffmpeg
321
		make clean
322
	else
323
		#get and compile ffmpeg with x264 support
324
		#get latest snapshot
325
		#rm -f ffmpeg-checkout-snapshot.tar.bz2
326
		#wget http://ffmpeg.org/releases/ffmpeg-checkout-snapshot.tar.bz2; tar xjf ffmpeg-checkout-snapshot.tar.bz2; mv ffmpeg-checkout-20* ffmpeg
327
		#do not get latest snapshot
328
		#get a release tarball instead
329
		rm -f ffmpeg-0.6.tar.bz2
330
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
331
		#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
332
		#do not get latest snapshot
333
		#get instead a specific one because allows output video rate resampling
334
		#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
335
		cd ffmpeg
336
	fi	
337

    
338
	if [ -n "$MINGW" ]; then
339
		HOSTARCH_OLDSTYLE=${HOSTARCH:+--arch=i586 --enable-cross-compile --cross-prefix=i586-mingw32msvc- --target-os=$HOSTARCH --disable-sse}
340
	
341
		#configure bugfix
342
		sed -i -e 's/^SDL_CONFIG=/[ -z "$SDL_CONFIG" ] \&\& SDL_CONFIG=/g' ./configure;
343
		sed -i -e 's/check_cflags \+-Werror=missing-prototypes/#\0/g' configure;
344
	
345
		./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"
346
	else
347
		./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"
348
	fi
349
	$MAKE; $MAKE install
350
fi
351

    
352

    
353
if [ -n "$MINGW" ]; then
354
	TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install_mingw"
355
else
356
	TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install_linux"
357
fi
358
if [ -n "$BUILD_MHD" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MHD" ]; then
359
	cd "$BASE_UL_DIR/$EXTERN_DIR"
360
	
361
	if [ -e "libmicrohttpd" ]; then
362
		cd libmicrohttpd
363
		make clean
364
	else
365
		#get and compile libmicrohttpd lib
366
		svn --non-interactive --trust-server-cert checkout https://ng.gnunet.org/svn/libmicrohttpd
367
		cd libmicrohttpd
368
	fi
369
	
370
	autoreconf -fi
371
	if [ -n "$MINGW" ]; then
372
		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"
373
	else
374
		./configure --disable-curl --disable-https --enable-messages --disable-client-side --prefix="$TEMP_MHD"
375
	fi
376
	$MAKE; $MAKE install
377
fi
378

    
379

    
380
if [ -n "$MINGW" ]; then
381
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl_mingw/temp_sdl_install"
382
else
383
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl/temp_sdl_install_linux"
384
fi
385
if [ -n "$BUILD_SDL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL" ]; then
386
	cd "$BASE_UL_DIR/$EXTERN_DIR"
387

    
388
	if [ -n "$MINGW" ]; then
389
		if [ ! -e "sdl_mingw" ]; then
390
			# use binaries
391
			$WGET_OR_CURL $WGET_OR_CURLOPT 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;
392
			rm -f SDL-devel-1.2.14-mingw32.tar.gz;
393
			cd sdl_mingw
394
			mkdir temp_sdl_install
395
			mv bin $TEMP_SDL/; mv lib $TEMP_SDL/; mv include $TEMP_SDL/; mv share $TEMP_SDL/
396
		fi
397

    
398
		# build from sources
399
		#~ 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
400
		#make and install in local folder
401
		#~ ./configure ${HOSTARCH:+--host=$HOSTARCH} --disable-video-directfb --prefix="$TEMP_SDL"
402
		#~ $MAKE; $MAKE install
403
	else
404
		if [ -e "sdl" ]; then
405
			cd sdl
406
			make clean
407
		else
408
			#get and compile SDL lib
409
			$WGET_OR_CURL $WGET_OR_CURLOPT 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
410
			cd sdl
411
		fi
412
		#make and install in local folder
413
		./configure --disable-video-directfb --prefix="$TEMP_SDL"
414
		$MAKE; $MAKE install
415
	fi
416
fi
417

    
418
if [ -n "$BUILD_SDLIMAGE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_image.a" ]; then
419
	cd "$BASE_UL_DIR/$EXTERN_DIR"
420
	
421
	if [ -e "sdlimage" ]; then
422
		cd sdlimage
423
		make clean
424
	else
425
		#get and compile SDLIMAGE lib
426
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
427
		rm -f SDL_image-1.2.10.tar.gz
428
		cd sdlimage
429
	fi
430
	
431
	#make and install in local SDL folder
432
        ./autogen.sh
433
	echo "./configure 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\" ${HOSTARCH:+--host=$HOSTARCH} --prefix=\"$TEMP_SDL\" --with-sdl-prefix=\"$TEMP_SDL\" --disable-png-shared"
434

    
435
	echo "./configure CFLAGS=\"$CFLAGS -I$LOCAL_LIBPNG/include\" CPPFLAGS=\"$CPPFLAGS -I$LOCAL_LIBPNG/include\" LDFLAGS=\"$LDFLAGS -L$LOCAL_LIBPNG/lib\" ${HOSTARCH:+--host=$HOSTARCH} --prefix=\"$TEMP_SDL\" --with-sdl-prefix=\"$TEMP_SDL\" --disable-png-shared"
436

    
437
	./configure CFLAGS="$CFLAGS $LIBSDLIMAGE_FLAGS -I$LOCAL_LIBPNG/include" CPPFLAGS="$CPPFLAGS -I$LOCAL_LIBPNG/include" LDFLAGS="$LDFLAGS $LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBPNG/lib" ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_SDL" --with-sdl-prefix="$TEMP_SDL" --disable-png-shared
438

    
439
	$MAKE; $MAKE install
440
fi
441

    
442
# SDL_ttf depends on freetype
443
if [ -n "$MINGW" ]; then
444
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_mingw"
445
else
446
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_linux"
447
fi
448
if [ -n "$BUILD_FREETYPE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FREETYPE" ]; then
449
	cd "$BASE_UL_DIR/$EXTERN_DIR"
450
	if [ -e "freetype" ]; then
451
		cd freetype
452
		make clean
453
	else
454
		#get and compile SDLTTF lib
455
		rm -f freetype-2.1.10.tar.gz
456
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
457
		cd freetype
458
	fi
459

    
460
	#make and install in local folder
461
	./configure ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_FREETYPE"
462
	$MAKE; $MAKE install
463
fi
464

    
465
if [ -n "$BUILD_SDLTTF" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_ttf.a" ]; then
466
	cd "$BASE_UL_DIR/$EXTERN_DIR"
467
	
468
	if [ -e "sdlttf" ]; then
469
		cd sdlttf
470
		make clean
471
	else
472
		#get and compile SDLTTF lib
473
		rm -f SDL_ttf-2.0.10.tar.gz
474
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
475
		cd sdlttf
476
	fi
477

    
478
	#make and install in local SDL folder
479
	./configure ${HOSTARCH:+--host=$HOSTARCH} --with-freetype-prefix="$TEMP_FREETYPE" --with-sdl-prefix="$TEMP_SDL" --prefix="$TEMP_SDL"
480
	$MAKE; $MAKE install
481
fi
482

    
483
if [ -n "$MINGW" ]; then
484
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_mingw"
485
else
486
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_linux"
487
fi
488
if [ -n "$BUILD_CURL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_CURL" ]; then
489
	cd "$BASE_UL_DIR/$EXTERN_DIR"
490
	if [ -e "curl" ]; then
491
		cd curl
492
		make clean
493
	else
494
		#get and compile CURL lib
495
		rm -f curl-7.21.0.tar.bz2
496
		$WGET_OR_CURL $WGET_OR_CURLOPT 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
497
		cd curl
498
	fi
499

    
500
	#make and install in local folder
501
	./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"
502
	$MAKE; $MAKE install
503
fi
504

    
505
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent" ]; then
506
	LOCAL_EVENT="$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent"
507
	echo "found LIBEVENT in $LOCAL_EVENT"
508
else
509
	LOCAL_EVENT_A=`locate -l 1 libevent.a`
510
	if [ "$LOCAL_EVENT_A" = "" ]; then
511
		if [ -f "/usr/lib/libevent.a" ]; then
512
			echo "You have file libevent.a in default system"
513
			echo "setting path for it to default /usr/lib/libevent.a"
514
			LOCAL_EVENT="/usr"
515
		else
516
			echo "you seem not to have file libevent.a. EXITING."
517
			exit
518
		fi
519
	else
520
		LOCAL_EVENT=`dirname $LOCAL_EVENT_A`/..
521
	fi
522
fi
523

    
524
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse" ]; then
525
	LOCAL_CONFUSE="$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse"
526
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
527
else
528
	LOCAL_CONFUSE_A=`locate -l 1 libconfuse.a`
529
	if [ "$LOCAL_CONFUSE_A" = "" ]; then
530
		if [ -f "/usr/lib/libconfuse.a" ]; then
531
			echo "You have file libconfuse.a in default system"
532
			echo "setting path for it to default /usr/lib/libconfuse.a"
533
			LOCAL_CONFUSE="/usr"
534
		else
535
			echo "you seem not to have file libconfuse.a. EXITING."
536
			exit
537
		fi
538
	else
539
		LOCAL_CONFUSE=`dirname $LOCAL_CONFUSE_A`/..
540
	fi
541
fi
542

    
543
#set needed paths to external libraries
544
echo "-----"
545
LOCAL_X264=$TEMP_X264
546
echo "path for X264 dependancy set to $LOCAL_X264"
547
LOCAL_MP3LAME=$TEMP_MP3LAME
548
echo "path for MP3LAME dependancy set to $LOCAL_MP3LAME"
549
LOCAL_FFMPEG=$TEMP_FFMPEG
550
echo "path for FFMPEG dependancy set to $LOCAL_FFMPEG"
551
LOCAL_MHD=$TEMP_MHD
552
echo "path for LIBMICROHTTPD dependancy set to $LOCAL_MHD"
553
LOCAL_ABS_SDL=$TEMP_SDL
554
echo "path for SDL dependancy set to $LOCAL_ABS_SDL"
555
LOCAL_SDLIMAGE=$TEMP_SDL
556
echo "path for SDLIMAGE dependancy set to $LOCAL_SDLIMAGE"
557
LOCAL_SDLTTF=$TEMP_SDL
558
echo "path for SDLTTF dependancy set to $LOCAL_SDLTTF"
559
LOCAL_FREETYPE=$TEMP_FREETYPE
560
echo "path for FREETYPE dependancy set to $LOCAL_FREETYPE"
561
LOCAL_CURL=$TEMP_CURL
562
echo "path for CURL dependancy set to $LOCAL_CURL"
563

    
564
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
565
echo "path for ZLIB dependancy is set to $LOCAL_Z"
566

    
567
echo "path for LIBEVENT dependancy is set to $LOCAL_EVENT"
568
echo "path for LIBCONFUSE dependancy is set to $LOCAL_CONFUSE"
569
echo "-----"
570

    
571
#compile the UL external applications
572
#chunker_streamer and chunker_player
573

    
574
#CHUNKER_STREAMER
575

    
576
# streamer is not supported yet on windows
577
if [ ! -n "$MINGW" ]; then
578
	echo "----------------COMPILING CHUNKER STREAMER"
579
	cd "$BASE_UL_DIR"
580
	cd chunker_streamer
581
	$MAKE clean
582
	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 IO=$IO MAC_OS=$MAC_OS $MAKE || { echo "Failed to build CHUNKER STREAMER"; exit 1; }
583
	echo "----------------FINISHED COMPILING CHUNKER STREAMER"
584
fi
585

    
586
#CHUNKER_PLAYER
587
echo "----------------COMPILING CHUNKER PLAYER"
588
cd "$BASE_UL_DIR"
589
cd chunker_player
590
$MAKE clean
591
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 IO=$IO MAC_OS=$MAC_OS  $MAKE || { echo "Failed to build CHUNKER PLAYER" ; exit 1; }
592
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
593

    
594
#compile a version of winestreamer with UL enabled
595
#static needs fix??
596
cd "$BASE_UL_DIR/../Streamer"
597

    
598
$MAKE IO=$IO clean
599
#LOCAL_MHD=$LOCAL_MHD 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 MAC_OS=$MAC_OS SVNVERSION=$SVNVERSION $MAKE || { echo "Failed to build WineStreamer" ; exit 1; }
600
LOCAL_CURL=$LOCAL_CURL LIBEVENT_DIR=$LOCAL_EVENT ML=$ML STATIC=$STATIC MONL=$MONL ALTO=$ALTO IO=$IO DEBUG=$DEBUG THREADS=$THREADS MAC_OS=$MAC_OS SVNVERSION=$SVNVERSION $MAKE || { echo "Failed to build WineStreamer" ; exit 1; }
601

    
602
#check if all is ok
603
echo "============== RESULTS ==================="
604

    
605
if [ ! -n "$MINGW" ]; then
606
	cd "$BASE_UL_DIR/chunker_streamer"
607
	if [ -f "chunker_streamer" ]; then
608
		echo "chunker_streamer OK"
609
		C_STREAMER_EXE=`ls -la chunker_streamer`
610
		echo "$C_STREAMER_EXE"
611
		#now we want the bare name
612
		C_STREAMER_EXE=`ls chunker_streamer`
613
	else
614
		echo "chunker_streamer FAIL"
615
	fi
616
fi
617

    
618
cd "$BASE_UL_DIR/chunker_player"
619
if [ -n "$MINGW" ]; then
620
	SUFFIX=".exe"
621
	SCRIPT_SUFFIX=".bat"
622
else
623
	SUFFIX=""
624
	SCRIPT_SUFFIX=".sh"
625
fi
626
if [ -f "chunker_player$SUFFIX" ]; then
627
	echo "chunker_player OK"
628
	C_PLAYER_EXE=`ls -la chunker_player$SUFFIX`
629
	echo "$C_PLAYER_EXE"
630
	#now we want the bare name
631
	C_PLAYER_EXE=`ls chunker_player$SUFFIX`
632
else
633
	echo "chunker_player FAIL"
634
fi
635

    
636
cd "$BASE_UL_DIR/../Streamer"
637
echo "Check if the http binary is among these winestreamers:"
638
ls -la winestreamer* | grep -v ".o$"
639
echo "Your UL-enabled winestreamer has these flags:"
640
if [ -n "$ALTO" ]; then
641
	GREP_ALTO_EXPR="-alto"
642
	GREP_ALTO_FLAGS=""
643
	echo "ALTO: enabled"
644
else
645
	GREP_ALTO_EXPR="-alto"
646
	GREP_ALTO_FLAGS="-v"
647
	echo "ALTO: disabled"
648
fi
649
if [ "$STATIC" = "1" ]; then
650
	GREP_STATIC_EXPR="-halfstatic"
651
	GREP_STATIC_FLAGS=""
652
	echo "STATIC: halfstatic"
653
elif [ "$STATIC" = "2" ]; then
654
	GREP_STATIC_EXPR="-static"
655
	GREP_STATIC_FLAGS=""
656
	echo "STATIC: static"
657
else
658
	GREP_STATIC_EXPR="static"
659
	GREP_STATIC_FLAGS="-v"
660
	echo "STATIC: dynamic"
661
fi
662
echo "IO: $IO"
663
IO="-"$IO
664
echo "Hence your UL-enabled winestreamer should be..."
665
O_TARGET_EXE=`ls winestreamer* | grep -v ".o$" | grep $GREP_STATIC_FLAGS -e "$GREP_STATIC_EXPR" | grep $GREP_ALTO_FLAGS -e "$GREP_ALTO_EXPR" | grep -e "$IO"`
666
#O_TARGET_EXE=`ls winestreamer* | grep -v ".o$" | grep -e "$IO"`
667
echo "$O_TARGET_EXE"
668
if [ -f "$O_TARGET_EXE" ]; then
669
	echo "...and i found it."
670
else
671
	echo "...but sadly it appears build FAILED!."
672
fi
673

    
674
#creating conf file with executable name inside
675
cd "$BASE_UL_DIR/chunker_player"
676
echo "$O_TARGET_EXE" > peer_exec_name.conf
677

    
678
#packaging for distribution
679
cd "$BASE_UL_DIR/chunker_player"
680
if [ -f "$BASE_UL_DIR/../Streamer/$O_TARGET_EXE" -a -f "$C_PLAYER_EXE" ]; then
681
	echo "============== PACKAGING NAPAPLAYER ==================="
682
	rm -f -r napaplayer
683
	mkdir napaplayer
684
	mkdir napaplayer/icons
685
	cp icons/* napaplayer/icons/
686
	cp channels.conf napaplayer/
687
	cp peer_exec_name.conf napaplayer/
688
	cp runme$SCRIPT_SUFFIX napaplayer/
689
	cp README napaplayer/
690
	cp napalogo*.bmp napaplayer/
691
	cp *.ttf napaplayer/
692
	cp "$C_PLAYER_EXE" napaplayer/
693
	if [ -n "$MINGW" ]; then
694
		cp "$BASE_UL_DIR/../Streamer/$O_TARGET_EXE" napaplayer/
695
	else
696
		cp "$BASE_UL_DIR/../Streamer/$O_TARGET_EXE" napaplayer/
697
	fi
698
	if [ -n "$MINGW" ]; then
699
		cp "$LOCAL_LIBICONV/bin/libiconv-2.dll" napaplayer/libiconv2.dll
700
		if [ -f "$LOCAL_LIBINTL/bin/libintl-8.dll" ]; then
701
			cp "$LOCAL_LIBINTL/bin/libintl-8.dll" napaplayer/
702
		else
703
			cp "$LOCAL_LIBINTL/bin/libintl3.dll" napaplayer/libintl-8.dll
704
		fi
705
		cp "$LOCAL_PLIBC/bin/libplibc-1.dll" napaplayer/
706
		cp "$LOCAL_PTHREAD/bin/pthreadGC2.dll" napaplayer/
707
		cp "$LOCAL_ABS_SDL/bin/SDL.dll" napaplayer/
708
		rm -f -r napaplayer.zip
709
		zip -r napaplayer napaplayer
710
		if [ -s "napaplayer.zip" ]; then
711
			#it has size>0. OK!
712
			echo "Here it is your napaplayer package. Enjoy!"
713
			ls -la napaplayer.zip
714
		else
715
			echo "Sorry something went wrong during packaging napaplayer."
716
		fi
717
	else
718
		rm -f -r napaplayer.tar.gz
719
		tar cvfz napaplayer.tar.gz napaplayer
720
		if [ -s "napaplayer.tar.gz" ]; then
721
			#it has size>0. OK!
722
			echo "Here it is your napaplayer tarball. Enjoy!"
723
			ls -la napaplayer.tar.gz
724
		else
725
			echo "Sorry something went wrong during packaging napaplayer."
726
		fi
727
	fi
728
else
729
	echo ""
730
	echo "Not packaging napaplayer since build failed."
731
fi
732

    
733
echo "Finished build UL script"
734