Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ f6b56b50

History | View | Annotate | Download (30 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
REBUILD=
9
[ "$1" == "-r" ] && REBUILD=1
10

    
11
#check the architecture
12
if [ "$OSTYPE" == "linux-gnu" ]; then
13
   # do something Linux-y
14
   echo "Building on Linux"
15
elif [ "$OSTYPE" == "darwin10.0" ]; then
16
   # do something OSX-y
17
   echo "Building on OSX"
18
   MAC_OS=1
19
fi
20

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

    
32
#set some defaults
33
IO=${IO:-"tcp"}
34
MONL=${MONL:-1}
35
ML=${ML:-1}
36

    
37
if [ "$HOSTARCH" = "mingw32" ]; then
38
	MINGW=1
39
fi
40

    
41
#by default build an check
42
BUILD_ALL=1
43

    
44
LIBTOOLIZE_PATH=`whereis libtoolize`
45
if [ "$LIBTOOLIZE_PATH" = "libtoolize:" ]; then
46
	echo "Can't find libtoolize. Try sudo apt-get install libtool"
47
	exit
48
fi
49

    
50
YASM_PATH=`whereis yasm`
51
if [ "$YASM_PATH" = "yasm:" ]; then
52
	echo "Can't find yasm assembler. Try sudo apt-get install yasm"
53
	exit
54
fi
55

    
56
mkdir -p $EXTERN_DIR
57

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

    
88
if [ -n "$MINGW" ]; then
89
	TEMP_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib_mingw"
90
	if [ ! -e "$TEMP_Z/lib/libz.a" ]; then
91
		cd "$BASE_UL_DIR/$EXTERN_DIR"
92
		rm -r -f zlib_mingw;
93
		#get the latest zlib libraries
94
		$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
95
		$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
96
		rm -f zlib-1.2.3-bin.zip; rm -f zlib-1.2.3-lib.zip;
97
	fi
98
	LOCAL_Z=$TEMP_Z
99
else
100
	LOCAL_Z="$BASE_UL_DIR/$EXTERN_DIR/zlib/temp_zlib_install_linux"
101
	if [ -f "$LOCAL_Z/lib/libz.a" ]; then
102
		echo "libz.a found in $LOCAL_Z/lib"
103
	else
104
		#force building locally
105
		#does not exist systemwide
106
		cd "$BASE_UL_DIR/$EXTERN_DIR"
107
		rm -r -f zlib
108
		#get and compile latest zlib library
109
		$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
110
		cd zlib
111
		#make and install in local folder
112
		./configure --prefix="$LOCAL_Z"
113
		$MAKE && $MAKE install || exit 1
114
	fi
115

    
116
	#clean all external libraries if CLEAN_EXTERNAL_BUILD=1
117
	if [ -n "$CLEAN_EXTERNAL_BUILD" ]; then
118
		#remove previuos versions of external libs builds
119
		rm -r -f $EXTERN_DIR
120
	fi
121
fi
122
LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_Z/include"
123
LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_Z/lib"
124

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

    
148

    
149
if [ -n "$MINGW" ]; then
150
	# plibc
151
	LOCAL_PLIBC="$BASE_UL_DIR/$EXTERN_DIR/plibc"
152
	if [ -f "$BASE_UL_DIR/$EXTERN_DIR/plibc/lib/libplibc.dll.a" ]; then
153
		echo "You have file libplibc.dll.a in default system: $BASE_UL_DIR/$EXTERN_DIR/plibc/lib/libplibc.dll.a"
154
	else
155
		cd "$BASE_UL_DIR/$EXTERN_DIR"
156
		rm -fR plibc
157
		$WGET_OR_CURL $WGET_OR_CURLOPT http://ovh.dl.sourceforge.net/project/plibc/plibc/0.1.5/plibc-0.1.5.zip
158
		unzip plibc-0.1.5.zip -d plibc;
159
		rm -f plibc/lib/*.la
160
		rm -f plibc-0.1.5.zip
161
	fi
162
	LIBMICROHHTPD_FLAGS="-I$BASE_UL_DIR/$EXTERN_DIR/plibc/include"
163
	LIBMICROHHTPD_LDFLAGS="-L$BASE_UL_DIR/$EXTERN_DIR/plibc/lib"
164

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

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

    
223
	# check for mingw pthread libs
224
	LOCAL_PTHREAD="$BASE_UL_DIR/$EXTERN_DIR/pthreads"
225
	if [ -f "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthread.a" ]; then
226
		echo "libpthread.a in $LOCAL_PTHREAD/lib/"
227
	else
228
		cd "$BASE_UL_DIR/$EXTERN_DIR"
229
		rm -fR pthreads
230
		$WGET_OR_CURL $WGET_OR_CURLOPT http://www.mirrorservice.org/sites/sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz
231
		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;
232
		cd pthreads
233
		mkdir -p ./{include,lib,bin}
234
		make CROSS=i586-mingw32msvc- GC-inlined
235
		mv libpthreadGC2.a ./lib
236
		mv *.h ./include
237
		mv pthreadGC2.dll ./bin
238
		ln -s "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthreadGC2.a" "$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib/libpthread.a"
239
	fi
240
	LIBMICROHHTPD_FLAGS="$LIBMICROHHTPD_FLAGS -I$BASE_UL_DIR/$EXTERN_DIR/pthreads/include"
241
	LIBMICROHHTPD_LDFLAGS="$LIBMICROHHTPD_LDFLAGS -L$BASE_UL_DIR/$EXTERN_DIR/pthreads/lib"
242
fi
243

    
244

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

    
266

    
267
echo "building x264"
268
if [ -n "$LOCAL_X264" ]; then
269
	TEMP_X264=$LOCAL_X264
270
else
271
if [ -n "$MINGW" ]; then
272
	#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
273
	echo "mingw: libx264 not required for player"
274
else
275
	TEMP_X264="$BASE_UL_DIR/$EXTERN_DIR/x264/temp_x264_install_linux"
276
if [ -n "$BUILD_X264" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_X264" ]; then
277
	cd "$BASE_UL_DIR/$EXTERN_DIR"
278
	if [ -e "x264" ]; then
279
		cd x264
280
		make clean
281
	else
282
		#get and compile latest x264 library
283
		if [ -n "$MAC_OS" ]; then
284
		   $WGET_OR_CURL $WGET_OR_CURLOPT ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20110115-2245.tar.bz2
285
		   tar yvfx x264-snapshot-20110115-2245.tar.bz2
286
		   rm -f x264-snapshot-20110115-2245.tar.bz2
287
		   mv x264-snapshot-20110115-2245/ x264
288
		else
289
		   git clone git://git.videolan.org/x264.git
290
		fi
291
		cd x264
292
	fi	
293

    
294
	#make and install in local folder
295
	./configure --prefix="$TEMP_X264" ${HOSTARCH:+--host=$HOSTARCH}
296
	$MAKE && $MAKE install || exit 1
297
fi
298
fi
299
fi
300

    
301
echo "building mp3lame"
302
if [ -n "$LOCAL_MP3LAME" ]; then
303
	TEMP_MP3LAME=$LOCAL_MP3LAME
304
else
305
if [ -n "$MINGW" ]; then
306
	#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
307
	echo "mingw: libmp3lame not required for player"
308
else
309
	TEMP_MP3LAME="$BASE_UL_DIR/$EXTERN_DIR/mp3lame/temp_mp3lame_install_linux"
310
if [ -n "$BUILD_MP3LAME" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_MP3LAME" ]; then
311
	cd "$BASE_UL_DIR/$EXTERN_DIR"
312
	
313
	if [ -e "mp3lame" ]; then
314
		cd mp3lame
315
		make clean
316
	else
317
		#get and compile latest mp3lame library
318
		rm -f lame-3.98.4.tar.gz
319
		$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;
320
		cd mp3lame
321
	fi	
322

    
323
	#make and install in local folder
324
	./configure --disable-gtktest --disable-frontend --prefix="$TEMP_MP3LAME" ${HOSTARCH:+--host=$HOSTARCH}
325
	$MAKE && $MAKE install || exit 1
326
fi
327
fi
328
fi
329

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

    
372
	if [ -n "$MINGW" ]; then
373
		HOSTARCH_OLDSTYLE=${HOSTARCH:+--arch=i586 --enable-cross-compile --cross-prefix=i586-mingw32msvc- --target-os=$HOSTARCH --disable-sse}
374
	
375
		#configure bugfix
376
		sed -i -e 's/^SDL_CONFIG=/[ -z "$SDL_CONFIG" ] \&\& SDL_CONFIG=/g' ./configure;
377
		sed -i -e 's/check_cflags \+-Werror=missing-prototypes/#\0/g' configure;
378
	
379
		./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"
380
	else
381
		./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"
382
	fi
383
	$MAKE && $MAKE install || exit 1
384
fi
385
fi
386

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

    
419

    
420
echo "building SDL"
421
if [ -n "$MINGW" ]; then
422
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl_mingw/temp_sdl_install"
423
else
424
	TEMP_SDL="$BASE_UL_DIR/$EXTERN_DIR/sdl/temp_sdl_install_linux"
425
fi
426
if [ -n "$BUILD_SDL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL" ]; then
427
	cd "$BASE_UL_DIR/$EXTERN_DIR"
428

    
429
	if [ -n "$MINGW" ]; then
430
#		if [ ! -e "sdl_mingw" ]; then
431
#			# use binaries
432
#			$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;
433
#			rm -f SDL-devel-1.2.14-mingw32.tar.gz;
434
#			cd sdl_mingw
435
#			mkdir temp_sdl_install
436
#			mv bin $TEMP_SDL/; mv lib $TEMP_SDL/; mv include $TEMP_SDL/; mv share $TEMP_SDL/
437

    
438
			# build from sources
439
			$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; rm -f SDL-1.2.14.tar.gz; mv SDL-1.2.14 sdl_mingw
440
			cd sdl_mingw
441
			#make and install in local folder
442
			./configure ${HOSTARCH:+--host=$HOSTARCH} --disable-video-directfb --disable-shared --prefix="$TEMP_SDL"
443
			$MAKE && $MAKE install || exit 1
444
#		fi
445
	else
446
		if [ -e "sdl" ]; then
447
			cd sdl
448
			make clean
449
		else
450
			#get and compile SDL lib
451
			$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
452
			cd sdl
453
		fi
454
		#make and install in local folder
455
		./configure --disable-video-directfb --prefix="$TEMP_SDL"
456
		$MAKE && $MAKE install || exit 1
457
	fi
458
fi
459

    
460
echo "building SDLimage"
461
if [ -n "$BUILD_SDLIMAGE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_image.a" ]; then
462
	cd "$BASE_UL_DIR/$EXTERN_DIR"
463
	
464
	if [ -e "sdlimage" ]; then
465
		cd sdlimage
466
		make clean
467
	else
468
		#get and compile SDLIMAGE lib
469
		$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
470
		rm -f SDL_image-1.2.10.tar.gz
471
		cd sdlimage
472
	fi
473
	
474
	#make and install in local SDL folder
475
        ./autogen.sh
476
	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"
477

    
478
	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"
479

    
480
	./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  --disable-shared --disable-sdltest
481

    
482
	$MAKE && $MAKE install || exit 1
483
fi
484

    
485
echo "building freetype"
486
# SDL_ttf depends on freetype
487
if [ -n "$MINGW" ]; then
488
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_mingw"
489
else
490
	TEMP_FREETYPE="$BASE_UL_DIR/$EXTERN_DIR/freetype/temp_freetype_install_linux"
491
fi
492
if [ -n "$BUILD_FREETYPE" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_FREETYPE" ]; then
493
	cd "$BASE_UL_DIR/$EXTERN_DIR"
494
	if [ -e "freetype" ]; then
495
		cd freetype
496
		make clean
497
	else
498
		#get and compile SDLTTF lib
499
		rm -f freetype-2.1.10.tar.gz
500
		$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
501
		cd freetype
502
	fi
503

    
504
	#make and install in local folder
505
	./configure ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_FREETYPE"
506
	$MAKE && $MAKE install || exit 1
507
fi
508

    
509
echo "building libSDL-ttf"
510
if [ -n "$BUILD_SDLTTF" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_SDL/lib/libSDL_ttf.a" ]; then
511
	cd "$BASE_UL_DIR/$EXTERN_DIR"
512
	
513
	if [ -e "sdlttf" ]; then
514
		cd sdlttf
515
		make clean
516
	else
517
		#get and compile SDLTTF lib
518
		rm -f SDL_ttf-2.0.10.tar.gz
519
		$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
520
		cd sdlttf
521
	fi
522

    
523
	#make and install in local SDL folder
524
	./configure ${HOSTARCH:+--host=$HOSTARCH} --with-freetype-prefix="$TEMP_FREETYPE" --with-sdl-prefix="$TEMP_SDL" --prefix="$TEMP_SDL" --disable-shared --disable-sdltest
525
	$MAKE && $MAKE install || exit 1
526
fi
527

    
528
echo "building curl"
529
if [ -n "$MINGW" ]; then
530
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_mingw"
531
else
532
	TEMP_CURL="$BASE_UL_DIR/$EXTERN_DIR/curl/temp_curl_install_linux"
533
fi
534
if [ -n "$BUILD_CURL" ] || [ -n "$BUILD_ALL" -a ! -e "$TEMP_CURL" ]; then
535
	cd "$BASE_UL_DIR/$EXTERN_DIR"
536
	if [ -e "curl" ]; then
537
		cd curl
538
		make clean
539
	else
540
		#get and compile CURL lib
541
		rm -f curl-7.21.0.tar.bz2
542
		$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
543
		cd curl
544
	fi
545

    
546
	#make and install in local folder
547
	./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"
548
	$MAKE && $MAKE install || exit 1
549
fi
550

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

    
581
echo "looking for libconfuse"
582
if [ -d "$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse" ]; then
583
	LOCAL_CONFUSE="$BASE_UL_DIR/../../3RDPARTY-LIBS/libconfuse"
584
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
585
else 
586
  if [ -d "$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS/3RDPARTY-LIBS/libconfuse" ]; then
587
	LOCAL_CONFUSE="$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS/3RDPARTY-LIBS/libconfuse"
588
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
589
  else 
590
    if [ -d "$BASE_UL_DIR/external_libs/libconfuse" ]; then
591
	LOCAL_CONFUSE="$BASE_UL_DIR/external_libs/libconfuse"
592
	echo "found LIBCONFUSE in $LOCAL_CONFUSE"
593
    else
594
	if [ "$LOCAL_CONFUSE_A" = "" ]; then
595
		if [ -f "/usr/lib/libconfuse.a" ]; then
596
			echo "You have file libconfuse.a in default system"
597
			echo "setting path for it to default /usr/lib/libconfuse.a"
598
			LOCAL_CONFUSE="/usr"
599
		else
600
			echo "you seem not to have file libconfuse.a. EXITING."
601
			exit
602
		fi
603
	else
604
		LOCAL_CONFUSE=`dirname $LOCAL_CONFUSE_A`/..
605
	fi
606
    fi
607
  fi
608
fi
609

    
610
#set needed paths to external libraries
611
echo "-----"
612
NAPA="$BASE_UL_DIR/../THIRDPARTY-LIBS/NAPA-BASELIBS"
613
echo "path for NAPA base folder set to $NAPA"
614
LOCAL_X264=$TEMP_X264
615
echo "path for X264 dependancy set to $LOCAL_X264"
616
LOCAL_MP3LAME=$TEMP_MP3LAME
617
echo "path for MP3LAME dependancy set to $LOCAL_MP3LAME"
618
LOCAL_FFMPEG=$TEMP_FFMPEG
619
echo "path for FFMPEG dependancy set to $LOCAL_FFMPEG"
620
LOCAL_MHD=$TEMP_MHD
621
echo "path for LIBMICROHTTPD dependancy set to $LOCAL_MHD"
622
LOCAL_ABS_SDL=$TEMP_SDL
623
echo "path for SDL dependancy set to $LOCAL_ABS_SDL"
624
LOCAL_SDLIMAGE=$TEMP_SDL
625
echo "path for SDLIMAGE dependancy set to $LOCAL_SDLIMAGE"
626
LOCAL_SDLTTF=$TEMP_SDL
627
echo "path for SDLTTF dependancy set to $LOCAL_SDLTTF"
628
LOCAL_FREETYPE=$TEMP_FREETYPE
629
echo "path for FREETYPE dependancy set to $LOCAL_FREETYPE"
630
LOCAL_CURL=$TEMP_CURL
631
echo "path for CURL dependancy set to $LOCAL_CURL"
632

    
633
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
634
echo "path for ZLIB dependancy is set to $LOCAL_Z"
635

    
636
echo "path for LIBEVENT dependancy is set to $LOCAL_EVENT"
637
echo "path for LIBCONFUSE dependancy is set to $LOCAL_CONFUSE"
638
echo "-----"
639

    
640
#compile the UL external applications
641
#chunker_streamer and chunker_player
642

    
643
#CHUNKER_STREAMER
644

    
645
# streamer is not supported yet on windows
646
if [ ! -n "$MINGW" ]; then
647
	echo "----------------COMPILING CHUNKER STREAMER"
648
	cd "$BASE_UL_DIR"
649
	cd chunker_streamer
650
	[ -n "$REBUILD" ] && $MAKE clean
651
	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; }
652
	echo "----------------FINISHED COMPILING CHUNKER STREAMER"
653
fi
654

    
655
#CHUNKER_PLAYER
656
echo "----------------COMPILING CHUNKER PLAYER"
657
cd "$BASE_UL_DIR"
658
cd chunker_player
659
[ -n "$REBUILD" ] && $MAKE clean
660
NAPA=$NAPA LIBEVENT_DIR=$LOCAL_EVENT 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; }
661
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
662
exit
663

    
664
#compile a version of winestreamer with UL enabled
665
#static needs fix??
666
cd "$BASE_UL_DIR/../Streamer"
667

    
668
$MAKE IO=$IO clean
669
#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; }
670
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; }
671

    
672
#check if all is ok
673
echo "============== RESULTS ==================="
674

    
675
if [ ! -n "$MINGW" ]; then
676
	cd "$BASE_UL_DIR/chunker_streamer"
677
	if [ -f "chunker_streamer" ]; then
678
		echo "chunker_streamer OK"
679
		C_STREAMER_EXE=`ls -la chunker_streamer`
680
		echo "$C_STREAMER_EXE"
681
		#now we want the bare name
682
		C_STREAMER_EXE=`ls chunker_streamer`
683
	else
684
		echo "chunker_streamer FAIL"
685
	fi
686
fi
687

    
688
cd "$BASE_UL_DIR/chunker_player"
689
if [ -n "$MINGW" ]; then
690
	SUFFIX=".exe"
691
	SCRIPT_SUFFIX=".bat"
692
else
693
	SUFFIX=""
694
	SCRIPT_SUFFIX=".sh"
695
fi
696
if [ -f "chunker_player$SUFFIX" ]; then
697
	echo "chunker_player OK"
698
	C_PLAYER_EXE=`ls -la chunker_player$SUFFIX`
699
	echo "$C_PLAYER_EXE"
700
	#now we want the bare name
701
	C_PLAYER_EXE=`ls chunker_player$SUFFIX`
702
else
703
	echo "chunker_player FAIL"
704
fi
705

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

    
744
#creating conf file with executable name inside
745
cd "$BASE_UL_DIR/chunker_player"
746
echo "$O_TARGET_EXE" > peer_exec_name.conf
747

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

    
803
echo "Finished build UL script"
804