Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ d0ab3a7d

History | View | Annotate | Download (30.9 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
VERSION_LIBMICROHTTPD=21651
9
VERSION_PTHREADS=2-9-1
10
VERSION_PLIBC=0.1.5
11
VERSION_CURL=7.27.0
12

    
13
REBUILD=
14
[ "$1" == "-r" ] && REBUILD=1
15

    
16
#check the architecture
17
if [ "$OSTYPE" == "linux-gnu" ]; then
18
   # do something Linux-y
19
   echo "Building on Linux"
20
elif [ "$OSTYPE" == "darwin10.0" -o "$OSTYPE" == "darwin11" ]; then
21
   # do something OSX-y
22
   echo "Building on OSX"
23
   MAC_OS=1
24
fi
25

    
26
which svn >/dev/null || { echo "CANNOT build UL Applications: svn missing. Please install subversion, then retry!"; exit 1; }
27
#which libtoolize >/dev/null || { echo "CANNOT build UL Applications: libtool missing. Please install libtool, then retry!"; exit 1; }
28
which yasm >/dev/null || { echo "CANNOT build UL Applications: yasm missing. Please install yasm, then retry!"; exit 1; }
29
if [ ! -n "MAC_OS" ]; then
30
  #we don't have git on osx - so we avoid using it
31
  which git >/dev/null || { echo "CANNOT build UL Applications: git missing. Please install git, then retry!"; exit 1; }
32
fi
33
WGET_OR_CURL=`which wget`
34
[ -n "$WGET_OR_CURL" ] || { WGET_OR_CURL=`which curl` ; WGET_OR_CURLOPT="-L -O"; }
35
[ -n "$WGET_OR_CURL" ] || { echo "please install wget or curl!"; exit 1; }
36

    
37
#set some defaults
38
IO=${IO:-"tcp"}
39
MONL=${MONL:-1}
40
ML=${ML:-1}
41

    
42
case $HOSTARCH in
43
  *mingw*)
44
	MINGW=1
45
	;;
46
esac
47

    
48
#by default build an check
49
BUILD_ALL=1
50

    
51
LIBTOOLIZE_PATH=`whereis libtoolize`
52
if [ "$LIBTOOLIZE_PATH" = "libtoolize:" ]; then
53
	echo "Can't find libtoolize. Try sudo apt-get install libtool"
54
	exit
55
fi
56

    
57
YASM_PATH=`whereis yasm`
58
if [ "$YASM_PATH" = "yasm:" ]; then
59
	echo "Can't find yasm assembler. Try sudo apt-get install yasm"
60
	exit
61
fi
62

    
63
mkdir -p $EXTERN_DIR
64

    
65
if [ -n "$MINGW" ]; then
66
	TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2_mingw"
67
	if [ ! -e "$TEMP_BZ2/lib/libbz2.a" ]; then
68
		#we erase and rebuild since the installation is not there
69
		cd "$BASE_UL_DIR/$EXTERN_DIR"
70
		rm -r -f bzip2_mingw
71
		#get the latest bzip2 library
72
		$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.sourceforge.net/project/gnuwin32/bzip2/1.0.5/bzip2-1.0.5-bin.zip; unzip bzip2-1.0.5-bin.zip -d bzip2_mingw
73
		$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.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
74
		rm -f bzip2-1.0.5-lib.zip; rm -f bzip2-1.0.5-bin.zip;
75
	fi
76
	LOCAL_BZ2=$TEMP_BZ2
77
else
78
	#try to find libbz2 in your system
79
	LOCAL_BZ2_A=/usr/lib/libbz2.a
80
	if [ ! -e $LOCAL_BZ2_A ]; then
81
		[ X$LOCAL_BZ2_A != X ] && LOCAL_BZ2=`dirname $LOCAL_BZ2_A`/..
82
		if [ ! -e "$LOCAL_BZ2/lib/libbz2.a" ]; then
83
			#wrong location and/or folders structure
84
			echo "you seem not to have file libbz2.a or the location is non-standard.Will be built locally."
85
			LOCAL_BZ2=""
86
			BUILD_BZ2=1
87
		fi
88
	else
89
		echo "You have file libbz2.a in default system"
90
		echo "setting path for it to default /usr/lib/libbz2.a"
91
		LOCAL_BZ2="/usr"
92
	fi
93
fi
94

    
95
if [ -n "$MINGW" ]; then
96
	TEMP_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib_mingw"
97
	if [ ! -e "$TEMP_Z/lib/libz.a" ]; then
98
		cd "$BASE_UL_DIR/$EXTERN_DIR"
99
		rm -r -f zlib_mingw;
100
		#get the latest zlib libraries
101
		$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.sourceforge.net/project/gnuwin32/zlib/1.2.3/zlib-1.2.3-bin.zip; unzip zlib-1.2.3-bin.zip -d zlib_mingw
102
		$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.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
103
		rm -f zlib-1.2.3-bin.zip; rm -f zlib-1.2.3-lib.zip;
104
	fi
105
	LOCAL_Z=$TEMP_Z
106
else
107
	LOCAL_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib/temp_zlib_install_linux"
108
	if [ -f "$LOCAL_Z/lib/libz.a" ]; then
109
		echo "libz.a found in $LOCAL_Z/lib"
110
	else
111
		#force building locally
112
		#does not exist systemwide
113
		cd "$BASE_UL_DIR/$EXTERN_DIR"
114
		rm -r -f zlib
115
		#get and compile latest zlib library
116
		$WGET_OR_CURL $WGET_OR_CURLOPT http://zlib.net/fossils/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
117
		cd zlib
118
		#make and install in local folder
119
		./configure --prefix="$LOCAL_Z" --libdir="$LOCAL_Z"/lib
120
		$MAKE && $MAKE install || exit 1
121
	fi
122

    
123
	#clean all external libraries if CLEAN_EXTERNAL_BUILD=1
124
	if [ -n "$CLEAN_EXTERNAL_BUILD" ]; then
125
		#remove previuos versions of external libs builds
126
		rm -r -f $EXTERN_DIR
127
	fi
128
fi
129
LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_Z/include"
130
LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_Z/lib"
131

    
132
if [ ! -n "$MINGW" ]; then
133
	TEMP_BZ2="$BASE_UL_DIR/$EXTERN_DIR/bzip2/temp_bzip2_install_linux"
134
	if [ -n "$BUILD_BZ2" ]; then
135
		#we have to build it either because of user will or because does not exist system wide
136
		if [ -z "$LOCAL_BZ2" ]; then
137
			#does not exist systemwide
138
			if [ -n "$BUILD_ALL" -a ! -e "$TEMP_BZ2" ]; then
139
				#we erase and rebuild since the installation is not there
140
				cd "$BASE_UL_DIR/$EXTERN_DIR"
141
				rm -r -f bzip2
142
				#get and compile latest bzip2 library
143
				$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
144
				cd bzip2
145
				#make and install in local folder
146
				$MAKE && $MAKE install PREFIX="$TEMP_BZ2" || exit 1 
147
			fi
148
			#previous local install is existing, just set pointer to it
149
			#or override location if it was set as systemwide
150
			LOCAL_BZ2=$TEMP_BZ2
151
		fi
152
	fi
153
fi
154

    
155

    
156
if [ -n "$MINGW" ]; then
157
	# plibc
158
	LOCAL_PLIBC="$BASE_UL_DIR/$EXTERN_DIR/plibc"
159
	if [ -f "$BASE_UL_DIR/$EXTERN_DIR/plibc/lib/libplibc.dll.a" ]; then
160
		echo "You have file libplibc.dll.a in default system: $BASE_UL_DIR/$EXTERN_DIR/plibc/lib/libplibc.dll.a"
161
	else
162
		cd "$BASE_UL_DIR/$EXTERN_DIR"
163
		rm -fR plibc
164
		$WGET_OR_CURL $WGET_OR_CURLOPT http://sourceforge.net/projects/plibc/files/plibc/${VERSION_PLIBC}/plibc-${VERSION_PLIBC}.zip
165
		unzip plibc-${VERSION_PLIBC}.zip -d plibc;
166
		rm -f plibc/lib/*.la
167
		rm -f plibc-${VERSION_PLIBC}.zip
168
	fi
169
	LIBMICROHHTPD_FLAGS="-I$BASE_UL_DIR/$EXTERN_DIR/plibc/include"
170
	LIBMICROHHTPD_LDFLAGS="-L$BASE_UL_DIR/$EXTERN_DIR/plibc/lib"
171

    
172
	# libiconv
173
	LOCAL_LIBICONV="$BASE_UL_DIR/$EXTERN_DIR/libiconv/temp_libiconv_install_mingw"
174
	if [ -f "$LOCAL_LIBICONV/lib/libiconv.a" ]; then
175
		echo "libiconv.a found in $LOCAL_LIBICONV/lib"
176
	else
177
		cd "$BASE_UL_DIR/$EXTERN_DIR"
178
		rm -fR libiconv
179
		
180
		#download binaries
181
		#~ 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
182
		#~ mkdir -p $LOCAL_LIBICONV/lib/
183
		#~ mv libiconv/*.dll $LOCAL_LIBICONV/lib/
184
		#~ rm -f libintl-0.14.4-dep.zip
185
		
186
		#build from sources
187
		$WGET_OR_CURL $WGET_OR_CURLOPT http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz
188
		tar zxvf libiconv-1.13.tar.gz; mv libiconv-1.13 libiconv; rm -f libiconv-1.13.tar.gz; cd libiconv
189
		./configure --enable-static ${HOSTARCH:+--host=$HOSTARCH} --prefix=$LOCAL_LIBICONV --libdir=$LOCAL_LIBICONV/lib
190
		make
191
		make install
192
	fi
193
	LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBICONV/include"
194
	#~ LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBICONV/lib"
195

    
196
	LOCAL_LIBINTL="$BASE_UL_DIR/$EXTERN_DIR/libintl/temp_libintl_install_mingw"
197
	if [ -f "$LOCAL_LIBINTL/lib/libintl.dll.a" ] || [ -f "$LOCAL_LIBINTL/lib/libintl.a" ]; then
198
		echo "libintl libraries found in $LOCAL_LIBINTL/lib"
199
	else
200
		cd "$BASE_UL_DIR/$EXTERN_DIR"
201
		#download binaries
202
		rm -fR libintl
203
		$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-lib.zip; unzip -o libintl-0.14.4-lib.zip -d libintl
204
		$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4-bin.zip; unzip -o libintl-0.14.4-bin.zip -d libintl
205
		rm -f libintl-0.14.4-bin.zip; rm -f libintl-0.14.4-lib.zip
206
		cd libintl
207
		mkdir -p $LOCAL_LIBINTL;
208
		mv bin $LOCAL_LIBINTL/; mv lib $LOCAL_LIBINTL/; mv include $LOCAL_LIBINTL/
209
		mv man $LOCAL_LIBINTL/; mv share $LOCAL_LIBINTL/
210
		
211
		# build from gettext sources
212
		#~ rm -fR gettext
213
		#~ rm -fR libintl
214
		#~ wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz
215
		#~ tar zxvf gettext-0.18.1.1.tar.gz; mv gettext-0.18.1.1 gettext; cd gettext
216
		#~ ./configure ${HOSTARCH:+--host=$HOSTARCH} --with-libiconv-prefix=$LOCAL_LIBICONV
217
		#~ cd gettext-runtime/intl
218
		#~ make
219
		#~ mkdir -p $LOCAL_LIBINTL/bin; mkdir -p $LOCAL_LIBINTL/include; mkdir -p $LOCAL_LIBINTL/lib
220
		#~ cp ./.libs/*a $LOCAL_LIBINTL/lib
221
		#~ cp ./.libs/*.dll $LOCAL_LIBINTL/bin
222
		#~ cp *.h $LOCAL_LIBINTL/include
223
		#~ cd ../../../
224
		#~ rm -f gettext-0.18.1.1.tar.gz
225
		#~ rm -fR gettext
226
	fi
227
	LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBINTL"
228
	LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBINTL/lib"
229

    
230
	# check for mingw pthread libs
231
	LOCAL_PTHREAD="$BASE_UL_DIR/$EXTERN_DIR/pthreads"
232
	if [ -f "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthread.a" ]; then
233
		echo "libpthread.a in $LOCAL_PTHREAD/lib/"
234
	else
235
		cd "$BASE_UL_DIR/$EXTERN_DIR"
236
		rm -fR pthreads
237
		$WGET_OR_CURL $WGET_OR_CURLOPT http://www.mirrorservice.org/sites/sourceware.org/pub/pthreads-win32/pthreads-w32-${VERSION_PTHREADS}-release.tar.gz
238
		tar zxvf pthreads-w32-${VERSION_PTHREADS}-release.tar.gz; mv pthreads-w32-${VERSION_PTHREADS}-release pthreads; rm -f pthreads-w32-${VERSION_PTHREADS}-release.tar.gz;
239
		cd pthreads
240
		mkdir -p ./{include,lib,bin}
241
		make CROSS=${CROSSPREFIX} GC-inlined
242
		mv libpthreadGC2.a ./lib
243
		mv *.h ./include
244
		mv pthreadGC2.dll ./bin
245
		ln -s "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthreadGC2.a" "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthread.a"
246
	fi
247
	LIBMICROHHTPD_FLAGS="$LIBMICROHHTPD_FLAGS -I$BASE_UL_DIR/$EXTERN_DIR/pthreads/include"
248
	LIBMICROHHTPD_LDFLAGS="$LIBMICROHHTPD_LDFLAGS -L$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib"
249
fi
250

    
251

    
252
echo "building libpng"
253
if [ -n "$MINGW" ]; then
254
	LOCAL_LIBPNG="$BASE_UL_DIR/$EXTERN_DIR/libpng/temp_libpng_install_mingw"
255
else
256
	LOCAL_LIBPNG="$BASE_UL_DIR/$EXTERN_DIR/libpng/temp_libpng_install_linux"
257
fi
258
if [ -f "$LOCAL_LIBPNG/lib/libpng.a" ]; then
259
	echo "libpng.a found in $LOCAL_LIBPNG/lib"
260
else
261
	cd "$BASE_UL_DIR/$EXTERN_DIR"
262
	rm -fR libpng
263
	$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.sourceforge.net/project/libpng/libpng14/older-releases/1.4.4/libpng-1.4.4.tar.gz
264
	tar zxvf libpng-1.4.4.tar.gz; rm -f libpng-1.4.4.tar.gz
265
	mv libpng-1.4.4 libpng; cd libpng;
266
	CFLAGS=-I$LOCAL_Z/include CPPFLAGS=-I$LOCAL_Z/include LDFLAGS=-L$LOCAL_Z/lib sh configure  ${HOSTARCH:+--host=$HOSTARCH} --prefix=$LOCAL_LIBPNG --libdir=$LOCAL_LIBPNG/lib
267
	make
268
	make install
269
fi
270
LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBPNG/include"
271
LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBPNG/lib"
272

    
273

    
274
echo "building x264"
275
if [ -n "$LOCAL_X264" ]; then
276
	TEMP_X264=$LOCAL_X264
277
else
278
if [ -n "$MINGW" ]; then
279
	#TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_mingw"	#would be needed only for the encoding by the chunker, so we disable it
280
	echo "mingw: libx264 not required for player"
281
else
282
	TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_linux"
283
if [ -n "$BUILD_X264" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_X264" ]; then
284
	cd "$BASE_UL_DIR/$EXTERN_DIR"
285
	if [ -e "x264" ]; then
286
		cd x264
287
		make clean
288
	else
289
		#get and compile latest x264 library
290
		if [ -n "$MAC_OS" ]; then
291
		   $WGET_OR_CURL $WGET_OR_CURLOPT ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20110115-2245.tar.bz2
292
		   tar yvfx x264-snapshot-20110115-2245.tar.bz2
293
		   rm -f x264-snapshot-20110115-2245.tar.bz2
294
		   mv x264-snapshot-20110115-2245/ x264
295
		else
296
		   git clone git://git.videolan.org/x264.git
297
		fi
298
		cd x264
299
	fi	
300

    
301
	#make and install in local folder
302
	./configure --prefix="$TEMP_X264" --libdir="$TEMP_X264"/lib ${HOSTARCH:+--host=$HOSTARCH}
303
	$MAKE && $MAKE install || exit 1
304
fi
305
fi
306
fi
307

    
308
echo "building mp3lame"
309
if [ -n "$LOCAL_MP3LAME" ]; then
310
	TEMP_MP3LAME=$LOCAL_MP3LAME
311
else
312
if [ -n "$MINGW" ]; then
313
	#TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_mingw"	#would be needed only for the encoding by the chunker, so we disable it
314
	echo "mingw: libmp3lame not required for player"
315
else
316
	TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_linux"
317
if [ -n "$BUILD_MP3LAME" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MP3LAME" ]; then
318
	cd "$BASE_UL_DIR/$EXTERN_DIR"
319
	
320
	if [ -e "mp3lame" ]; then
321
		cd mp3lame
322
		make clean
323
	else
324
		#get and compile latest mp3lame library
325
		rm -f lame-3.98.4.tar.gz
326
		$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;
327
		cd mp3lame
328
	fi	
329

    
330
	#make and install in local folder
331
	./configure --disable-gtktest --disable-frontend --prefix="$TEMP_MP3LAME" --libdir="$TEMP_MP3LAME"/lib ${HOSTARCH:+--host=$HOSTARCH}
332
	$MAKE && $MAKE install || exit 1
333
fi
334
fi
335
fi
336

    
337
echo "building ffmpeg"
338
if [ -n "$LOCAL_FFMPEG" ]; then
339
	TEMP_FFMPEG=$LOCAL_FFMPEG
340
else
341
if [ -n "$MINGW" ]; then
342
	TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install_mingw"
343
else
344
	TEMP_FFMPEG="$BASE_UL_DIR/$EXTERN_DIR/ffmpeg/temp_ffmpeg_install_linux"
345
fi
346
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
347
	echo "Compilation of some ffmpeg dependancies failed. Check your internet connection and errors."
348
fi
349
if [ -e "$TEMP_X264/lib/libx264.a" ]; then
350
	FFMPEG_CONFIG+=" --enable-libx264"
351
	FFMPEG_EXTRA_CFLAGS+=" -I$TEMP_X264/include"
352
fi
353
if [ -e "$TEMP_MP3LAME/lib/libmp3lame.a" ]; then
354
	FFMPEG_CONFIG+=" --enable-libmp3lame"
355
	FFMPEG_EXTRA_CFLAGS+=" -I$TEMP_MP3LAME/include"
356
fi
357
if [ -n "$BUILD_FFMPEG" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FFMPEG" ]; then
358
	cd "$BASE_UL_DIR/$EXTERN_DIR"
359
	
360
	if [ -e "ffmpeg" ]; then
361
		cd ffmpeg
362
		make clean
363
	else
364
		#get and compile ffmpeg with x264 support
365
		#get latest snapshot
366
		#rm -f ffmpeg-checkout-snapshot.tar.bz2
367
		#wget http://ffmpeg.org/releases/ffmpeg-checkout-snapshot.tar.bz2; tar xjf ffmpeg-checkout-snapshot.tar.bz2; mv ffmpeg-checkout-20* ffmpeg
368
		#do not get latest snapshot
369
		#get a release tarball instead
370
		rm -f ffmpeg-0.6.tar.bz2
371
		$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
372
		#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
373
		#do not get latest snapshot
374
		#get instead a specific one because allows output video rate resampling
375
		#svn -r 21010 checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
376
		cd ffmpeg
377
	fi	
378

    
379
	if [ -n "$MINGW" ]; then
380
		HOSTARCH_OLDSTYLE=${HOSTARCH:+--arch=i586 --enable-cross-compile --cross-prefix=i586-mingw32msvc- --target-os=$HOSTARCH --disable-sse}
381
	
382
		#configure bugfix
383
		sed -i -e 's/^SDL_CONFIG=/[ -z "$SDL_CONFIG" ] \&\& SDL_CONFIG=/g' ./configure;
384
		sed -i -e 's/check_cflags \+-Werror=missing-prototypes/#\0/g' configure;
385
	
386
		./configure $HOSTARCH_OLDSTYLE --enable-gpl --enable-nonfree --enable-version3 --disable-pthreads $FFMPEG_CONFIG --extra-cflags="$FFMPEG_EXTRA_CFLAGS -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" --libdir="$TEMP_FFMPEG"/lib
387
	else
388
		./configure --enable-gpl --enable-nonfree --enable-version3 --enable-pthreads  $FFMPEG_CONFIG --extra-cflags="$FFMPEG_EXTRA_CFLAGS -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" --libdir="$TEMP_FFMPEG"/lib
389
	fi
390
	$MAKE && $MAKE install || exit 1
391
fi
392
fi
393

    
394
echo "building libmicrohttpd"
395
if [ -n "$MINGW" ]; then
396
	TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install_mingw"
397
else
398
	TEMP_MHD="$BASE_UL_DIR/$EXTERN_DIR/libmicrohttpd/temp_mhd_install_linux"
399
fi
400
if [ -n "$BUILD_MHD" ]; then
401
	cd "$BASE_UL_DIR/$EXTERN_DIR"
402
	
403
	if [ -e "libmicrohttpd" ]; then
404
		cd libmicrohttpd
405
		make clean
406
	else
407
		#get and compile libmicrohttpd lib
408
		if [ X`svn --version|head -1|cut -c14-16` = X1.6 ]; then
409
			svn --non-interactive --trust-server-cert checkout https://gnunet.org/svn/libmicrohttpd -r$VERSION_LIBMICROHTTPD
410
		else
411
			svn --non-interactive checkout https://gnunet.org/svn/libmicrohttpd -r$VERSION_LIBMICROHTTPD
412
		fi
413
		cd libmicrohttpd || { echo "CANNOT download libmicrohttpd"; exit 1; }
414
 
415
	fi
416
	
417
	autoreconf -fi
418
	if [ -n "$MINGW" ]; then
419
		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" --libdir="$TEMP_MHD"/lib
420
	else
421
		./configure --disable-curl --disable-https --enable-messages --disable-client-side --prefix="$TEMP_MHD" --libdir="$TEMP_MHD"/lib
422
	fi
423
	$MAKE && $MAKE install || exit 1
424
fi
425

    
426

    
427
echo "building SDL"
428
if [ -n "$MINGW" ]; then
429
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl_mingw/temp_sdl_install"
430
else
431
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl/temp_sdl_install_linux"
432
fi
433
if [ -n "$BUILD_SDL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL" ]; then
434
	cd "$BASE_UL_DIR/$EXTERN_DIR"
435

    
436
	if [ -n "$MINGW" ]; then
437
#		if [ ! -e "sdl_mingw" ]; then
438
#			# use binaries
439
#			$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;
440
#			rm -f SDL-devel-1.2.14-mingw32.tar.gz;
441
#			cd sdl_mingw
442
#			mkdir temp_sdl_install
443
#			mv bin $TEMP_SDL/; mv lib $TEMP_SDL/; mv include $TEMP_SDL/; mv share $TEMP_SDL/
444

    
445
			# build from sources
446
			$WGET_OR_CURL $WGET_OR_CURLOPT http://www.libsdl.org/release/SDL-1.2.15.tar.gz; tar xzf SDL-1.2.15.tar.gz; rm -f SDL-1.2.15.tar.gz; mv SDL-1.2.15 sdl_mingw
447
			cd sdl_mingw
448
			#make and install in local folder
449
			./configure ${HOSTARCH:+--host=$HOSTARCH} --disable-video-directfb --disable-shared --prefix="$TEMP_SDL" --libdir="$TEMP_SDL"/lib
450
			$MAKE && $MAKE install || exit 1
451
#		fi
452
	else
453
		if [ -e "sdl" ]; then
454
			cd sdl
455
			make clean
456
		else
457
			#get and compile SDL lib
458
			#$WGET_OR_CURL $WGET_OR_CURLOPT http://www.libsdl.org/release/SDL-1.2.15.tar.gz; tar xzf SDL-1.2.15.tar.gz; mv SDL-1.2.15 sdl; rm -f SDL-1.2.15.tar.gz
459
			$WGET_OR_CURL $WGET_OR_CURLOPT http://peerstreamer.org/files/release/SDL-1.2.15.tar.gz; tar xzf SDL-1.2.15.tar.gz; mv SDL-1.2.15 sdl; rm -f SDL-1.2.15.tar.gz
460
			cd sdl
461
		fi
462
		#make and install in local folder
463
		./autogen.sh
464
		./configure --disable-video-directfb --prefix="$TEMP_SDL" --libdir="$TEMP_SDL"/lib
465
		$MAKE && $MAKE install || exit 1
466
	fi
467
fi
468

    
469
echo "building SDLimage"
470
if [ -n "$BUILD_SDLIMAGE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_image.a" ]; then
471
	cd "$BASE_UL_DIR/$EXTERN_DIR"
472
	
473
	if [ -e "sdlimage" ]; then
474
		cd sdlimage
475
		make clean
476
	else
477
		#get and compile SDLIMAGE lib
478
		$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
479
		rm -f SDL_image-1.2.10.tar.gz
480
		cd sdlimage
481
	fi
482
	
483
	#make and install in local SDL folder
484
        ./autogen.sh
485
	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\" --libdir=\"$TEMP_SDL\"/lib --with-sdl-prefix=\"$TEMP_SDL\" --disable-png-shared"
486

    
487
	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\" --libdir=\"$TEMP_SDL\"/lib --with-sdl-prefix=\"$TEMP_SDL\" --disable-png-shared"
488

    
489
	./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" --libdir="$TEMP_SDL"/lib --with-sdl-prefix="$TEMP_SDL" --disable-png-shared  --disable-shared --disable-sdltest
490

    
491
	$MAKE && $MAKE install || exit 1
492
fi
493

    
494
echo "building freetype"
495
# SDL_ttf depends on freetype
496
if [ -n "$MINGW" ]; then
497
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_mingw"
498
else
499
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_linux"
500
fi
501
if [ -n "$BUILD_FREETYPE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FREETYPE" ]; then
502
	cd "$BASE_UL_DIR/$EXTERN_DIR"
503
	if [ -e "freetype" ]; then
504
		cd freetype
505
		make clean
506
	else
507
		#get and compile SDLTTF lib
508
		rm -f freetype-2.1.10.tar.gz
509
		$WGET_OR_CURL $WGET_OR_CURLOPT http://download.savannah.gnu.org/releases/freetype/freetype-old/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
510
		cd freetype
511
	fi
512

    
513
	#make and install in local folder
514
	./configure ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_FREETYPE" --libdir="$TEMP_FREETYPE"/lib
515
	$MAKE && $MAKE install || exit 1
516
fi
517

    
518
echo "building libSDL-ttf"
519
if [ -n "$BUILD_SDLTTF" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_ttf.a" ]; then
520
	cd "$BASE_UL_DIR/$EXTERN_DIR"
521
	
522
	if [ -e "sdlttf" ]; then
523
		cd sdlttf
524
		make clean
525
	else
526
		#get and compile SDLTTF lib
527
		rm -f SDL_ttf-2.0.10.tar.gz
528
		$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
529
		cd sdlttf
530
	fi
531

    
532
	#make and install in local SDL folder
533
	./configure ${HOSTARCH:+--host=$HOSTARCH} --with-freetype-prefix="$TEMP_FREETYPE" --with-sdl-prefix="$TEMP_SDL" --prefix="$TEMP_SDL" --libdir="$TEMP_SDL"/lib --disable-shared --disable-sdltest
534
	$MAKE && $MAKE install || exit 1
535
fi
536

    
537
echo "building curl"
538
if [ -n "$MINGW" ]; then
539
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_mingw"
540
else
541
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_linux"
542
fi
543
if [ -n "$BUILD_CURL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_CURL" ]; then
544
	cd "$BASE_UL_DIR/$EXTERN_DIR"
545
	if [ -e "curl" ]; then
546
		cd curl
547
		make clean
548
	else
549
		#get and compile CURL lib
550
		rm -f curl-7.21.0.tar.bz2
551
		$WGET_OR_CURL $WGET_OR_CURLOPT http://curl.haxx.se/download/curl-${VERSION_CURL}.tar.bz2; tar xjf curl-${VERSION_CURL}.tar.bz2; rm -f curl-${VERSION_CURL}.tar.bz2; mv curl-${VERSION_CURL} curl
552
		cd curl
553
	fi
554

    
555
	#make and install in local folder
556
	./configure ${HOSTARCH:+--host=$HOSTARCH} --without-librtmp --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" --libdir="$TEMP_CURL"/lib
557
	$MAKE && $MAKE install || exit 1
558
fi
559

    
560
echo "looking for libevent"
561
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent" ]; then
562
	LOCAL_EVENT="$BASE_UL_DIR/../../3RDPARTY-LIBS/libevent"
563
	echo "found LIBEVENT in $LOCAL_EVENT"
564
else 
565
  if [ -d "$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS/3RDPARTY-LIBS/libevent" ]; then
566
	LOCAL_EVENT="$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS/3RDPARTY-LIBS/libevent"
567
	echo "found LIBEVENT in $LOCAL_EVENT"
568
  else 
569
    if [ -d "$BASE_UL_DIR/external_libs/libevent" ]; then
570
	LOCAL_EVENT="$BASE_UL_DIR/external_libs/libevent"
571
	echo "found LIBEVENT in $LOCAL_EVENT"
572
    else
573
	if [ "$LOCAL_EVENT_A" = "" ]; then
574
		if [ -f "/usr/lib/libevent.a" ]; then
575
			echo "You have file libevent.a in default system"
576
			echo "setting path for it to default /usr/lib/libevent.a"
577
			LOCAL_EVENT="/usr"
578
		else
579
			echo "you seem not to have file libevent.a."
580
			echo "you will not be able to build the libevent based version"
581
			echo "(don't worry, the default version will still compile)."
582
		fi
583
	else
584
		LOCAL_EVENT=`dirname $LOCAL_EVENT_A`/..
585
	fi
586
    fi
587
  fi
588
fi
589

    
590
echo "looking for libconfuse"
591
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse" ]; then
592
	LOCAL_CONFUSE="$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse"
593
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
594
else 
595
  if [ -d "$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS/3RDPARTY-LIBS/libconfuse" ]; then
596
	LOCAL_CONFUSE="$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS/3RDPARTY-LIBS/libconfuse"
597
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
598
  else 
599
    if [ -d "$BASE_UL_DIR/external_libs/libconfuse" ]; then
600
	LOCAL_CONFUSE="$BASE_UL_DIR/external_libs/libconfuse"
601
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
602
    else
603
	if [ "$LOCAL_CONFUSE_A" = "" ]; then
604
		if [ -f "/usr/lib/libconfuse.a" ]; then
605
			echo "You have file libconfuse.a in default system"
606
			echo "setting path for it to default /usr/lib/libconfuse.a"
607
			LOCAL_CONFUSE="/usr"
608
		else
609
			echo "you seem not to have file libconfuse.a. EXITING."
610
			exit
611
		fi
612
	else
613
		LOCAL_CONFUSE=`dirname $LOCAL_CONFUSE_A`/..
614
	fi
615
    fi
616
  fi
617
fi
618

    
619
#set needed paths to external libraries
620
echo "-----"
621
NAPA="$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS"
622
echo "path for NAPA base folder set to $NAPA"
623
LOCAL_X264=$TEMP_X264
624
echo "path for X264 dependancy set to $LOCAL_X264"
625
LOCAL_MP3LAME=$TEMP_MP3LAME
626
echo "path for MP3LAME dependancy set to $LOCAL_MP3LAME"
627
LOCAL_FFMPEG=$TEMP_FFMPEG
628
echo "path for FFMPEG dependancy set to $LOCAL_FFMPEG"
629
LOCAL_MHD=$TEMP_MHD
630
echo "path for LIBMICROHTTPD dependancy set to $LOCAL_MHD"
631
LOCAL_ABS_SDL=$TEMP_SDL
632
echo "path for SDL dependancy set to $LOCAL_ABS_SDL"
633
LOCAL_SDLIMAGE=$TEMP_SDL
634
echo "path for SDLIMAGE dependancy set to $LOCAL_SDLIMAGE"
635
LOCAL_SDLTTF=$TEMP_SDL
636
echo "path for SDLTTF dependancy set to $LOCAL_SDLTTF"
637
LOCAL_FREETYPE=$TEMP_FREETYPE
638
echo "path for FREETYPE dependancy set to $LOCAL_FREETYPE"
639
LOCAL_CURL=$TEMP_CURL
640
echo "path for CURL dependancy set to $LOCAL_CURL"
641

    
642
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
643
echo "path for ZLIB dependancy is set to $LOCAL_Z"
644

    
645
echo "path for LIBEVENT dependancy is set to $LOCAL_EVENT"
646
echo "path for LIBCONFUSE dependancy is set to $LOCAL_CONFUSE"
647
echo "-----"
648

    
649
#compile the UL external applications
650
#chunker_streamer and chunker_player
651

    
652
#CHUNKER_STREAMER
653

    
654
# streamer is not supported yet on windows
655
echo "----------------COMPILING CHUNKER STREAMER"
656
cd "$BASE_UL_DIR"
657
cd chunker_streamer
658
[ -n "$REBUILD" ] && $MAKE clean
659
if [ -z "$MAC_OS" ]; then
660
	USE_AVFILTER=1
661
fi
662
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 USE_AVFILTER=$USE_AVFILTER $MAKE || { echo "Failed to build CHUNKER STREAMER"; exit 1; }
663
echo "----------------FINISHED COMPILING CHUNKER STREAMER"
664

    
665
#CHUNKER_PLAYER
666
echo "----------------COMPILING CHUNKER PLAYER"
667
cd "$BASE_UL_DIR"
668
cd chunker_player
669
[ -n "$REBUILD" ] && $MAKE clean
670
NAPA=$NAPA LIBEVENT_DIR=$LOCAL_EVENT LOCAL_CURL=$LOCAL_CURL 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; }
671
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
672
exit
673

    
674
#compile a version of winestreamer with UL enabled
675
#static needs fix??
676
cd "$BASE_UL_DIR/../Streamer"
677

    
678
$MAKE IO=$IO clean
679
#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; }
680
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; }
681

    
682
#check if all is ok
683
echo "============== RESULTS ==================="
684

    
685
if [ ! -n "$MINGW" ]; then
686
	cd "$BASE_UL_DIR/chunker_streamer"
687
	if [ -f "chunker_streamer" ]; then
688
		echo "chunker_streamer OK"
689
		C_STREAMER_EXE=`ls -la chunker_streamer`
690
		echo "$C_STREAMER_EXE"
691
		#now we want the bare name
692
		C_STREAMER_EXE=`ls chunker_streamer`
693
	else
694
		echo "chunker_streamer FAIL"
695
	fi
696
fi
697

    
698
cd "$BASE_UL_DIR/chunker_player"
699
if [ -n "$MINGW" ]; then
700
	SUFFIX=".exe"
701
	SCRIPT_SUFFIX=".bat"
702
else
703
	SUFFIX=""
704
	SCRIPT_SUFFIX=".sh"
705
fi
706
if [ -f "chunker_player$SUFFIX" ]; then
707
	echo "chunker_player OK"
708
	C_PLAYER_EXE=`ls -la chunker_player$SUFFIX`
709
	echo "$C_PLAYER_EXE"
710
	#now we want the bare name
711
	C_PLAYER_EXE=`ls chunker_player$SUFFIX`
712
else
713
	echo "chunker_player FAIL"
714
fi
715

    
716
cd "$BASE_UL_DIR/../Streamer"
717
echo "Check if the http binary is among these winestreamers:"
718
ls -la winestreamer* | grep -v ".o$"
719
echo "Your UL-enabled winestreamer has these flags:"
720
if [ -n "$ALTO" ]; then
721
	GREP_ALTO_EXPR="-alto"
722
	GREP_ALTO_FLAGS=""
723
	echo "ALTO: enabled"
724
else
725
	GREP_ALTO_EXPR="-alto"
726
	GREP_ALTO_FLAGS="-v"
727
	echo "ALTO: disabled"
728
fi
729
if [ "$STATIC" = "1" ]; then
730
	GREP_STATIC_EXPR="-halfstatic"
731
	GREP_STATIC_FLAGS=""
732
	echo "STATIC: halfstatic"
733
elif [ "$STATIC" = "2" ]; then
734
	GREP_STATIC_EXPR="-static"
735
	GREP_STATIC_FLAGS=""
736
	echo "STATIC: static"
737
else
738
	GREP_STATIC_EXPR="static"
739
	GREP_STATIC_FLAGS="-v"
740
	echo "STATIC: dynamic"
741
fi
742
echo "IO: $IO"
743
IO="-"$IO
744
echo "Hence your UL-enabled winestreamer should be..."
745
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"`
746
#O_TARGET_EXE=`ls winestreamer* | grep -v ".o$" | grep -e "$IO"`
747
echo "$O_TARGET_EXE"
748
if [ -f "$O_TARGET_EXE" ]; then
749
	echo "...and i found it."
750
else
751
	echo "...but sadly it appears build FAILED!."
752
fi
753

    
754
#creating conf file with executable name inside
755
cd "$BASE_UL_DIR/chunker_player"
756
echo "$O_TARGET_EXE" > peer_exec_name.conf
757

    
758
#packaging for distribution
759
cd "$BASE_UL_DIR/chunker_player"
760
if [ -f "$BASE_UL_DIR/../Streamer/$O_TARGET_EXE" -a -f "$C_PLAYER_EXE" ]; then
761
	echo "============== PACKAGING NAPAPLAYER ==================="
762
	rm -f -r napaplayer
763
	mkdir napaplayer
764
	mkdir napaplayer/icons
765
	cp icons/* napaplayer/icons/
766
	cp channels.conf napaplayer/
767
	cp peer_exec_name.conf napaplayer/
768
	cp runme$SCRIPT_SUFFIX napaplayer/
769
	cp README napaplayer/
770
	cp napalogo*.bmp napaplayer/
771
	cp *.ttf napaplayer/
772
	cp "$C_PLAYER_EXE" napaplayer/
773
	if [ -n "$MINGW" ]; then
774
		cp "$BASE_UL_DIR/../Streamer/$O_TARGET_EXE" napaplayer/
775
	else
776
		cp "$BASE_UL_DIR/../Streamer/$O_TARGET_EXE" napaplayer/
777
	fi
778
	if [ -n "$MINGW" ]; then
779
		cp "$LOCAL_LIBICONV/bin/libiconv-2.dll" napaplayer/libiconv2.dll
780
		if [ -f "$LOCAL_LIBINTL/bin/libintl-8.dll" ]; then
781
			cp "$LOCAL_LIBINTL/bin/libintl-8.dll" napaplayer/
782
		else
783
			cp "$LOCAL_LIBINTL/bin/libintl3.dll" napaplayer/libintl-8.dll
784
		fi
785
		cp "$LOCAL_PLIBC/bin/libplibc-1.dll" napaplayer/
786
		cp "$LOCAL_PTHREAD/bin/pthreadGC2.dll" napaplayer/
787
		cp "$LOCAL_ABS_SDL/bin/SDL.dll" napaplayer/
788
		rm -f -r napaplayer.zip
789
		zip -r napaplayer napaplayer
790
		if [ -s "napaplayer.zip" ]; then
791
			#it has size>0. OK!
792
			echo "Here it is your napaplayer package. Enjoy!"
793
			ls -la napaplayer.zip
794
		else
795
			echo "Sorry something went wrong during packaging napaplayer."
796
		fi
797
	else
798
		rm -f -r napaplayer.tar.gz
799
		tar cvfz napaplayer.tar.gz napaplayer
800
		if [ -s "napaplayer.tar.gz" ]; then
801
			#it has size>0. OK!
802
			echo "Here it is your napaplayer tarball. Enjoy!"
803
			ls -la napaplayer.tar.gz
804
		else
805
			echo "Sorry something went wrong during packaging napaplayer."
806
		fi
807
	fi
808
else
809
	echo ""
810
	echo "Not packaging napaplayer since build failed."
811
fi
812

    
813
echo "Finished build UL script"
814