summaryrefslogtreecommitdiff
path: root/atari/scripts/makelibs.sh
blob: c479b1ea81fdfd8474c1173c880ffecd43a2ca23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
#!/bin/sh

#todo: cflib, libcurl -> ensure ssl support, force ssl support

#example usage: 
#./makelibs.sh -prefix /usr -dest /media/EXT3_DATA/nslibs/m68000 -cross -nsonly -clean -src ./
#./makelibs.sh -prefix /usr -dest /media/EXT3_DATA/nslibs/m68020 -cross -arch 68020 -nsonly -clean -src ./
#./makelibs.sh -prefix /usr -dest /media/EXT3_DATA/nslibs/m68020-60 -cross -arch 68020-60 -nsonly -clean -src ./
#./makelibs.sh -prefix /usr -dest /media/EXT3_DATA/nslibs/m5475 -cross -arch 5475 -clean

# option description:
#
#-buildroot - this option tells the script where it is located, only needen when the script isn|t located in cwd.
#-arch - specifiy architecture type (format: 68000, 68020, 5475 etc...) 
#-src - tell the tool where the sources for the ns libs are located
#-prefix - what prefix to use ( -prefix local )
#-dest - where to install result files, this should NOT point to /usr or something like that!!! Its a temporary folder. 
#-optflags 
#-with-nsfb - compile with libnsfb
#-cross - set up some cross-compiler vars
#-clean - clean source dirs before building 
#-nsonly - only build netsurf libs
#-dry - only set environment variables, echo them and then exit the script
#-release - compile from release svn tree 

buildroot=`pwd`"/"
libopensslpkg="openssl-0.9.8r"
libpngpkg="libpng-1.5.10"
libzlibpkg="zlib-1.2.5"
libldgpkg="ldg-dev-2.33"
libiconvpkg="libiconv-1.13.1"
libcurlpkg="curl-7.25.0"
libfreetypepkg="freetype-2.4.9"
libhermespkg="Hermes-1.3.3"
libjpegpkg="jpeg-8b"
libxmlpkg="libxml2-2.7.8"
libparserutils_version=0.1.1
libwapcaplet_version=0.1.1
hubbub_version=0.1.2
libnsgif_version=0.0.3
libnsbmp_version=0.0.3
libnsfb_version=0.0.2
libcss_version=0.1.2
arch="68000"
archdir=""
debugmode="1"
profileflags=""
optflags="-O2"
withnsfb="1"
prefix="/usr"
userfs=$buildroot"userfs"
patchdir=$buildroot"patches/"
builddir=$buildroot"build/"
rpmdir=$buildroot"packages/"
nssrctree=$buildroot
compiler="gcc"
cross="0"
cleanup="echo no cleaning"
ssltarget="m68k-mint"
dry="0"
nsonly="0"
release="0"

if [ "$CC" != "" ]
then
	compiler=$CC
fi

while [ "$1" != "" ]			# When there are arguments...
do					# Process the next one
  case $1				# Look at $1
  in
   -dummy)
		dummy="1"
		shift
	;;

   -p)
		profileflags="-pg"
		shift
	;;

   -buildroot)
		shift
		buildroot=$1
		userfs=$buildroot"userfs"
		patchdir=$buildroot"patches/"
		builddir=$buildroot"build/"
		rpmdir=$buildroot"packages/"
		nssrctree=$buildroot"src/"
		shift
	;;

   -arch)
		shift
		arch=$1
		shift
	;;

   -src)
		shift
		nssrctree=$1
		shift
	;;

   -prefix)
		shift
		prefix=$1
		shift
	;;
   
   -release)
                release="1"
		shift
        ;;
	
   -dest)
		shift
		userfs=$1
		shift
	;;

   -optflags)
		shift
		optflags=$1
		shift
	;;

   -with-nsfb)
		withnsfb="1"
		shift
	;;

   -cross )
		cross="1"
		shift
	;;

   -nsonly )
	nsonly="1"
	shift
	;;

   -clean )
		cleanup="make clean && make distclean"
		shift
	;;

   -dry ) 
                dry="1"
		shift
        ;;

	*)	echo "Option [$1] not one of  [-buildroot,-arch,-src,-prefix,-dest,-optflags,-with-nsfb]";
	exit;;
  esac
done


if [ -d "$buildroot" ] 
then
	echo "Buildroot: $buildroot"
else
	echo "Invalid buildroot directory ("$buildroot") !" 
	echo "This script must know where it is located!"
	echo "Either use buildroot option or start from directory where the script is located."
	exit 0
fi

if [ "$release" = "0" ]
then
libparserutils_version=""
libwapcaplet_version=""
hubbub_version=""
libnsgif_version=""
libnsbmp_version=""
libnsfb_version=""
libcss_version=""
fi

if [ "$nssrctree" = "./" ]
then
	nssrctree=`pwd`
fi



#testarch:
archok=0
if [ "$arch" = "68000" ]
then
	archok=1
fi
if [ "$arch" = "68020" ]
then
	archok=1
fi
if [ "$arch" = "68020-60" ]
then
	archok=1
	openssltarget="m680x0-mint"
fi
if [ "$arch" = "5475" ]
then
	archok=1
	openssltarget="cf-mint"
fi

if [ "$archok" = "0" ]
then
	echo "Invalid arch:"$arch" valid: 68000,68020,68020-69,5475"
	exit 0
fi

if [ "$cross" = "1" ]
then
	echo "enabling cross compiler mode"
	export CC="m68k-atari-mint-gcc"
	export LD="m68k-atari-mint-ld"
	export AR="m68k-atari-mint-ar"
	export RANLIB="m68k-atari-mint-ranlib"
	export CPP="m68k-atari-mint-cpp"
	compiler="m68k-atari-mint-gcc"
fi


# handle arch specific settings here.

if [ "$arch" = "68000" ]
then
	archlibdir=$userfs$prefix"/lib"
	archdir=""
else
	archlibdir=$userfs$prefix"/lib/m"$arch
	archdir="m"$arch
fi

if [ "$arch" = "5475" ]
then
	machineflag="cpu="$arch
else
	machineflag=$arch
fi


echo "machine: " $machineflag
incdir="-I$userfs$prefix/include"
CFLAGS_ORG="-m$machineflag $optflags $profileflags $incdir"
LDLAGS_ORG="-m$machineflag $profileflags"
CFLAGS="$CFLAGS_ORG"
LDFLAGS="$LDFLAGS_ORG"
export CFLAGS_ORG
export LDLAGS_ORG
export CFLAGS
export LDFLAGS

echo "Build root: "$buildroot
echo "Netsurf sources: "$nssrctree
echo "Build directory: "$builddir
echo "Patches: "$patchdir
echo "Libdir: "$archlibdir
echo "Dest: "$userfs
echo "Prefix: "$prefix
echo "Compiler: "$compiler
echo "CFLAGS: "$CFLAGS
echo "PKG_CONFIG_PATH=$archlibdir/pkgconfig"
echo "PKG_CONFIG_LIBDIR=$archlibdir/pkgconfig"
echo "PKG_CONFIG_SYSROOT_DIR=$userfs"
echo "Dry: " $dry


#echo "Installing RPMs:"
#rpm -i $rpmdir""$opensslpkg

#cd $buildroot
#exit 0


# configure flags for curl, this actually saves 30kb in the lib and about 100k in the final executable 
#./configure --disable-debug --enable-optimize --disable-ldap --disable-ldaps --disable-rtsp --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-manual -- disable-sspi --target="m"$arch 

# freetype configured for winfnt, truetype, raster (not smooth)
# saves around 160kb in the lib.

if [ "$dry" = "1" ]
then
echo "export CFLAGS=$CFLAGS"
echo "export PKG_CONFIG_PATH=$archlibdir/pkgconfig"
echo "export PKG_CONFIG_LIBDIR=$archlibdir/pkgconfig"
echo "export PKG_CONFIG_SYSROOT_DIR=$userfs"
exit 0
fi

echo "creating staging directory"
mkdir "$userfs"
mkdir "$userfs$prefix"
mkdir "$userfs$prefix/include"
mkdir "$archlibdir"
mkdir "$archlibdir/pkgconfig"


export PKG_CONFIG_PATH="$archlibdir/pkgconfig"
export PKG_CONFIG_LIBDIR="$archlibdir/pkgconfig"
export PKG_CONFIG_SYSROOT_DIR="$userfs"

echo "Building Libraries..."
cd $nssrctree

#start test
if [ "$nsonly" = "0" ]
then

echo "compiling Hermes..."
cd $libhermespkg
$cleanup
./configure --disable-x86asm --disable-debug --host="m68k-atari-mint" --prefix="$userfs$prefix"
make install
cd ..

echo "compiling iconv..."
cd $libiconvpkg
$cleanup
./configure --enable-static \
       --host="m68k-atari-mint"\
        --prefix="$prefix"\
	--exec-prefix="$prefix"\
       --enable-extra-encodings\
        lt_cv_sys_max_cmd_len=65536
make install DESTDIR=$destdir PREFIX=$prefix
cd ..


cd $libzlibpkg
$cleanup
if [ "$cross" = "1" ]
then
	./configure --prefix=$prefix --static
else
	./configure --prefix=$prefix --static
fi
make
# there is an error within make instal, copy headers manually. 
install -m644 zlib.h "$userfs$prefix/include/zlib.h"
install -m644 zconf.h "$userfs$prefix/include/zconf.h"
install -m644 zutil.h "$userfs$prefix/include/zutil.h"
make install DESTDIR=$userfs PREFIX="$prefix"
cd ..

pwd
cd $libfreetypepkg
$cleanup
if [ "$cross" = "1" ]
then
./configure --prefix="$prefix" \
	--host="m68k-atari-mint" \
	CFLAGS="$CFLAGS_ORG"
make
make install DESTDIR=$userfs
else
./configure --prefix="$userfs$prefix" --host="m68k-atari-mint" --target="m$arch" CFLAGS="$CFLAGS_ORG"
make
make install DESTDIR=$userfs
fi

cd ..

cd $libxmlpkg
$cleanup
if [ "$cross" = "1" ]
then
./configure --prefix="$prefix" \
	--host="m68k-atari-mint" \
	--without-python \
	--without-threads \
	--enable-ipv6=no \
	--without-debug \
	--without-http \
	--without-ftp \
	--without-legacy \
	--without-docbook \
	--without-catalog \
	--without-regexps \
	--without-schemas \
	--without-schematron \
	--without-sax1 \
	--without-xpath \
	--without-modules \
	--without-c14n \
	--without-pattern \
	--without-push \
	--with-iconv="$archlibdir" \
	--with-zlib="$archlibdir"
make
make install DESTDIR="$userfs"
else
echo "no cross"
fi
cd ..

cd $libopensslpkg
$cleanup
if [ "$cross" = "1" ]
then
./Configure $openssltarget --prefix="$prefix" --install-prefix="$userfs"
else
./Configure $openssltarget --prefix="$prefix" --install-prefix="$userfs" 
fi
make
make rehash
make install
cd ..

# FIXME: build c-ares here, if you want to

cd $libcurlpkg
$cleanup
/configure\
 --prefix="$prefix" \
 --libdir=$prefix"/lib/$archdir"\
 --host="m68k-atari-mint"\
 --program-suffix=".ttp"\
 --with-random="/dev/urandom"\
 --enable-static\
 --enable-optimize\
 --enable-warnings\
 --enable-http\
 --enable-gopher\
 --enable-nonblocking\
 --enable-cookies\
 --disable-libtool-lock\
 --disable-verbose\
 --disable-shared\
 --disable-dependency-tracking\
 --disable-manual\
 --disable-curldebug\
 --disable-debug\
 --disable-ipv6\
 --disable-largefile\
 --disable-thread\
 --disable-threaded-resolver\
 --disable-telnet\
 --disable-tftp\
 --disable-dict\
 --disable-pop3\
 --disable-imap\
 --disable-smtp\
 --disable-ldaps\
 --disable-ldap\
 --disable-rtsp\
 --disable-sspi\
 --disable-rtsp\
 --without-polarssl\
 --without-cyassl\
 --without-nss\
 --without-libssh2\
 --without-librtmp\
 --without-libidn\
 --without-gnutls
# --with-ares="/usr/m68k-atari-mint/lib/"$archdir\
# --enable-ares

make CFLAGS="$CFLAGS_ORG"
make install DESTDIR="$userfs"
cd ..

cd $libjpegpkg
./configure --enable-static --prefix="$userfs$prefix" --host="m68k-atari-mint"
make install
cd ..

cd $libpngpkg
$cleanup
if [ "$cross" = "1" ]
then
	./configure --prefix=$prefix --host=m68k-atari-mint
else
	./configure --prefix=$prefix
fi

make
make install DESTDIR="$userfs"
cd ..

# we only need header files of ldg... 
#cd $libldgpkg
#cp ./include/ldg.h "$userfs$prefix/include"
#cd ..

cd windom
cd src
rm ../lib/gcc/libwindom.a
$cleanup
export M68K_ATARI_MINT_CFLAGS="$CFLAGS"
echo $M68K_ATARI_MINT_CFLAGS
echo "dest:"  $userfs$prefix
if [ "$cross" = "1" ]
then
make cross
cp ../lib/gcc/libwindom.a "$userfs$prefix/lib"
cp ../include/* "$userfs$prefix/include/" -R
else
make -f gcc.mak
cp ./lib/gcc/libwindom.a "$userfs$prefix/lib"
cp ./include/* "$userfs$prefix/include/" -R
fi
cd ../..

fi # END OF TEST 

# set TARGET, so that make clean and build use the same directory.
export TARGET="freemint"

echo "compiling libparserutils..."
cd libparserutils/$libparserutils_version
export CFLAGS="$CFLAGS_ORG -DWITH_ICONV_FILTER"
$cleanup
if [ "$cross" = "1" ]
then
	make TARGET="freemint"
	make install DESTDIR="$userfs" PREFIX="$prefix" TARGET="freemint"
else
#	make install DESTDIR="$userfs" PREFIX="$prefix"
	make install DESTDIR="$archlibdir" PREFIX="$prefix"
fi
cd $nssrctree
export CFLAGS="$CFLAGS_ORG"


echo "compiling libwapcaplet..."
cd libwapcaplet/$libwapcaplet_version || exit 1
$cleanup
if [ "$cross" = "1" ]
then
	make install DESTDIR=$userfs PREFIX=$prefix TARGET="freemint"
	#make install DESTDIR="$userfs/$archdir" TARGET="freemint" 
	#PREFIX=$prefix TARGET="freemint"
else
	make install DESTDIR=$userfs PREFIX=$prefix
	#make install DESTDIR="$archlibdir" PREFIX=$prefix
fi
cd $nssrctree

cd libcss/$libcss_version
$cleanup
if [ "$cross" = "1" ]
then
	make install DESTDIR=$userfs PREFIX=$prefix TARGET="freemint"
#	make install DESTDIR="$archlibdir" TARGET="freemint" 
#PREFIX=$prefix TARGET="freemint"
else
	make install DESTDIR=$userfs PREFIX=$prefix
#	make install DESTDIR="$archlibdir" PREFIX=$prefix
fi
cd $nssrctree

echo "compiling hubbub..." 
pwd
cd hubbub/$hubbub_version || exit 1
$cleanup
if [ "$cross" = "1" ]
then
	make install DESTDIR=$userfs PREFIX=$prefix TARGET="freemint"
else
	make install DESTDIR=$userfs PREFIX=$prefix
fi
cd $nssrctree


echo "compiling libnsgif..." 
cd libnsgif/$libnsgif_version || exit 1
$cleanup
if [ "$cross" = "1" ]
then
	make install DESTDIR=$userfs PREFIX=$prefix TARGET="freemint"
else
	make install DESTDIR=$userfs PREFIX=$prefix
fi
cd $nssrctree

echo "compiling libnsbmp..." 
cd libnsbmp/$libnsbmp_version || exit 1
$cleanup
if [ "$cross" = "1" ]
then
	make install DESTDIR=$userfs PREFIX=$prefix TARGET="freemint"
else
	make install DESTDIR=$userfs PREFIX=$prefix
fi
cd $nssrctree


if [ "$withnsfb" = "1" ]
then
	echo "compiling libnsfb..."
	cd libnsfb/$libnsfb_version || exit 1
	$cleanup
	if [ "$cross" = "1" ]
	then
		make install DESTDIR=$userfs PREFIX=$prefix TARGET="freemint"
	else
		make install DESTDIR=$userfs PREFIX=$prefix
	fi
	cd $nssrctree
else
	echo "libnsfb skipped"
fi


if [ "$arch" = "68000" ]
then
	echo "No library relocation needed!"
else
	echo "Relocation Libraries to :"
	echo $archlibdir
	srclibdir=$userfs$prefix"/lib/"
	srcpkgdir=$userfs$prefix"/lib/pkgconfig"
	mkdir $archlibdir
	rm $archlib/*.a 
	mv $srclibdir*.a  $archlibdir/ -v
	mv $srcpkgdir $archlibdir -v
fi

echo "please add symlink to libxml2/libxml within /usr/m68k-atari-mint/include"
echo "please add symlink to freetype2/freetype within /usr/m68k-atari-mint/include"
exit 0