Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ 30569e86

History | View | Annotate | Download (30.7 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" -o "$OSTYPE" == "darwin11" ]; 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/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
110
		cd zlib
111
		#make and install in local folder
112
		./configure --prefix="$LOCAL_Z" --libdir="$LOCAL_Z"/lib
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 --libdir=$LOCAL_LIBICONV/lib
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 --libdir=$LOCAL_LIBPNG/lib
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" --libdir="$TEMP_X264"/lib ${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" --libdir="$TEMP_MP3LAME"/lib ${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" --libdir="$TEMP_FFMPEG"/lib
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" --libdir="$TEMP_FFMPEG"/lib
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" --libdir="$TEMP_MHD"/lib
413
	else
414
		./configure --disable-curl --disable-https --enable-messages --disable-client-side --prefix="$TEMP_MHD" --libdir="$TEMP_MHD"/lib
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" --libdir="$TEMP_SDL"/lib
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
			# we use a daily build because of OS X problems in 1.2.14
452
			#$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
453
			$WGET_OR_CURL $WGET_OR_CURLOPT http://peerstreamer.org/files/release/SDL-1.2.tar.gz; tar xzf SDL-1.2.tar.gz; mv SDL-1.2.14 sdl; rm -f SDL-1.2.tar.gz
454
			cd sdl
455
		fi
456
		#make and install in local folder
457
		./autogen.sh
458
		./configure --disable-video-directfb --prefix="$TEMP_SDL" --libdir="$TEMP_SDL"/lib
459
		$MAKE && $MAKE install || exit 1
460
	fi
461
fi
462

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

    
481
	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"
482

    
483
	./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
484

    
485
	$MAKE && $MAKE install || exit 1
486
fi
487

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

    
507
	#make and install in local folder
508
	./configure ${HOSTARCH:+--host=$HOSTARCH} --prefix="$TEMP_FREETYPE" --libdir="$TEMP_FREETYPE"/lib
509
	$MAKE && $MAKE install || exit 1
510
fi
511

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

    
526
	#make and install in local SDL folder
527
	./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
528
	$MAKE && $MAKE install || exit 1
529
fi
530

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

    
549
	#make and install in local folder
550
	./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
551
	$MAKE && $MAKE install || exit 1
552
fi
553

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

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

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

    
636
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
637
echo "path for ZLIB dependancy is set to $LOCAL_Z"
638

    
639
echo "path for LIBEVENT dependancy is set to $LOCAL_EVENT"
640
echo "path for LIBCONFUSE dependancy is set to $LOCAL_CONFUSE"
641
echo "-----"
642

    
643
#compile the UL external applications
644
#chunker_streamer and chunker_player
645

    
646
#CHUNKER_STREAMER
647

    
648
# streamer is not supported yet on windows
649
echo "----------------COMPILING CHUNKER STREAMER"
650
cd "$BASE_UL_DIR"
651
cd chunker_streamer
652
[ -n "$REBUILD" ] && $MAKE clean
653
if [ -z "$MAC_OS" ]; then
654
	USE_AVFILTER=1
655
fi
656
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; }
657
echo "----------------FINISHED COMPILING CHUNKER STREAMER"
658

    
659
#CHUNKER_PLAYER
660
echo "----------------COMPILING CHUNKER PLAYER"
661
cd "$BASE_UL_DIR"
662
cd chunker_player
663
[ -n "$REBUILD" ] && $MAKE clean
664
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; }
665
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
666
exit
667

    
668
#compile a version of winestreamer with UL enabled
669
#static needs fix??
670
cd "$BASE_UL_DIR/../Streamer"
671

    
672
$MAKE IO=$IO clean
673
#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; }
674
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; }
675

    
676
#check if all is ok
677
echo "============== RESULTS ==================="
678

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

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

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

    
748
#creating conf file with executable name inside
749
cd "$BASE_UL_DIR/chunker_player"
750
echo "$O_TARGET_EXE" > peer_exec_name.conf
751

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

    
807
echo "Finished build UL script"
808