Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ 7f736ef7

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
VERSION_LIBMICROHTTPD=21651
9

    
10
REBUILD=
11
[ "$1" == "-r" ] && REBUILD=1
12

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

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

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

    
39
if [ "$HOSTARCH" = "mingw32" ]; then
40
	MINGW=1
41
fi
42

    
43
#by default build an check
44
BUILD_ALL=1
45

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

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

    
58
mkdir -p $EXTERN_DIR
59

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

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

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

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

    
150

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

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

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

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

    
246

    
247
echo "building libpng"
248
if [ -n "$MINGW" ]; then
249
	LOCAL_LIBPNG="$BASE_UL_DIR/$EXTERN_DIR/libpng/temp_libpng_install_mingw"
250
else
251
	LOCAL_LIBPNG="$BASE_UL_DIR/$EXTERN_DIR/libpng/temp_libpng_install_linux"
252
fi
253
if [ -f "$LOCAL_LIBPNG/lib/libpng.a" ]; then
254
	echo "libpng.a found in $LOCAL_LIBPNG/lib"
255
else
256
	cd "$BASE_UL_DIR/$EXTERN_DIR"
257
	rm -fR libpng
258
	$WGET_OR_CURL $WGET_OR_CURLOPT http://downloads.sourceforge.net/project/libpng/libpng14/older-releases/1.4.4/libpng-1.4.4.tar.gz
259
	tar zxvf libpng-1.4.4.tar.gz; rm -f libpng-1.4.4.tar.gz
260
	mv libpng-1.4.4 libpng; cd libpng;
261
	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
262
	make
263
	make install
264
fi
265
LIBSDLIMAGE_FLAGS="$LIBSDLIMAGE_FLAGS -I$LOCAL_LIBPNG/include"
266
LIBSDLIMAGE_LDFLAGS="$LIBSDLIMAGE_LDFLAGS -L$LOCAL_LIBPNG/lib"
267

    
268

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

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

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

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

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

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

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

    
421

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
647
#CHUNKER_STREAMER
648

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

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

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

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

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

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

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

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

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

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

    
808
echo "Finished build UL script"
809