Statistics
| Branch: | Revision:

chunker-player / build_ul.sh @ 1afc6d4f

History | View | Annotate | Download (31.2 KB)

1
#!/bin/bash
2
SCRIPT=$0
3
BASE_UL_DIR=`pwd`
4
EXTERN_DIR="external_libs"
5
MAKE="make -j 4"
6
cd "$BASE_UL_DIR"
7

    
8
VERSION_LIBMICROHTTPD=21651
9
VERSION_PTHREADS=2-9-1
10
VERSION_PLIBC=0.1.5
11
VERSION_CURL=7.27.0
12

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

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

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

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

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

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

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

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

    
63
mkdir -p $EXTERN_DIR
64

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

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

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

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

    
155

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

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

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

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

    
251

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

    
273

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

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

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

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

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

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

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

    
426

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

    
436
	if [ -n "$MINGW" ]; then
437
#		if [ ! -e "sdl_mingw" ]; then
438
#			# use binaries
439
#			$WGET_OR_CURL $WGET_OR_CURLOPT http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz; tar zxvf SDL-devel-1.2.14-mingw32.tar.gz; mv SDL-1.2.14 sdl_mingw;
440
#			rm -f SDL-devel-1.2.14-mingw32.tar.gz;
441
#			cd sdl_mingw
442
#			mkdir temp_sdl_install
443
#			mv bin $TEMP_SDL/; mv lib $TEMP_SDL/; mv include $TEMP_SDL/; mv share $TEMP_SDL/
444

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

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

    
488
	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"
489

    
490
	./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
491

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

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

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

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

    
533
	#avoid opengl support configuration
534
	sed -i 's/SDL_opengl.h/SDL_no_opengl.h/g' configure
535

    
536
	#make and install in local SDL folder
537
	./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
538
	$MAKE && $MAKE install || exit 1
539
fi
540

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

    
559
	#make and install in local folder
560
	./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
561
	$MAKE && $MAKE install || exit 1
562
fi
563

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

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

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

    
646
echo "path for BZ2 dependancy is set to $LOCAL_BZ2"
647
echo "path for ZLIB dependancy is set to $LOCAL_Z"
648

    
649
echo "path for LIBEVENT dependancy is set to $LOCAL_EVENT"
650
echo "path for LIBCONFUSE dependancy is set to $LOCAL_CONFUSE"
651
echo "-----"
652

    
653
#compile the UL external applications
654
#chunker_streamer and chunker_player
655

    
656
#CHUNKER_STREAMER
657

    
658
# streamer is not supported yet on windows
659
echo "----------------COMPILING CHUNKER STREAMER"
660
cd "$BASE_UL_DIR"
661
cd chunker_streamer
662
[ -n "$REBUILD" ] && $MAKE clean
663
if [ -z "$MAC_OS" ]; then
664
	USE_AVFILTER=1
665
fi
666
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; }
667
echo "----------------FINISHED COMPILING CHUNKER STREAMER"
668

    
669
#CHUNKER_PLAYER
670
echo "----------------COMPILING CHUNKER PLAYER"
671
cd "$BASE_UL_DIR"
672
cd chunker_player
673
[ -n "$REBUILD" ] && $MAKE clean
674
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; }
675
echo "----------------FINISHED COMPILING CHUNKER PLAYER"
676
exit
677

    
678
#compile a version of winestreamer with UL enabled
679
#static needs fix??
680
cd "$BASE_UL_DIR/../Streamer"
681

    
682
$MAKE IO=$IO clean
683
#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; }
684
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; }
685

    
686
#check if all is ok
687
echo "============== RESULTS ==================="
688

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

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

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

    
758
#creating conf file with executable name inside
759
cd "$BASE_UL_DIR/chunker_player"
760
echo "$O_TARGET_EXE" > peer_exec_name.conf
761

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

    
817
echo "Finished build UL script"
818