summaryrefslogtreecommitdiffstats
path: root/stage2
blob: 09a23149655c65f2fec9b2d64247c1d539bdda56 (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
#!/bin/bash
#
# This script is the second stage in bootstrapping a Fedora build to a
# new platform or architecture.  Running stage1 with no arguments
# builds a cross-development environment, then cross-builds a minimal
# rootfs.  Once you have this minimal rootfs booted (or chroot'd), run
# stage2 (this script) in that rootfs to build the rest of the
# bootstrap packages.
#
# This script assumes that all the needed sources are installed in
# $SRC (below) by stage1.  Each build installs into /usr.
#
# You may pass a single package name on the command line to rebuild
# just that one package.
#
# The master upstream for this script is:
#   git://fedorapeople.org/~djdelorie/bootstrap.git
#
# ------------------------------------------------------------
#
#	      --- NOTES FOR PACKAGE PORTING ---
#
# This script is stage TWO of a bootstrap process.  EVERYTHING that
# this script uses MUST be provided by the stage ONE script -
# filesystem, utilities, sources, etc.  Please keep this in mind when
# editing this script - anything you do manually to "prepare" for your
# build, will NOT be reproducible.
#
# Please make sure your package is not in either stage1 or stage2, and
# that nobody else is already working on your package, before
# starting.  Grep is your friend.  See the wiki page for details.
#
# There are FOUR places you must edit when adding packages to the
# bootstrap build:
#
# 1. Add a clause at the end of this script to actually build your
#    package.
#
# 2. Add your package to the "" case at the beginning of the package
#    list, about a page down from these comments.  Put in the order in
#    which it needs to build based on its dependencies.
#
# 3. Add your SRPM to the list at the end of the stage1 script so that
#    your sources are available in the bootstrap rootfs.
#
# 4. Update the Fedora/ARM bootstrap wiki page.
#
# If you attempt to add a package and discover some unsatisfied build
# dependency, add a clause for it here that documents the dependency
# and exits with a non-zero code.  In that case, do not add your
# package to the "" case.
#
# ------------------------------------------------------------

TOP=/stage2
MYDIR=${0%/*}
STAGE2=$MYDIR/stage2

SRC=$TOP/rpmbuild/BUILD
J=-j2

BUILDDIR=$TOP/builds

# The cross-compiler target
TARGET=armv7hl-redhat-linux-gnueabi

if [ -f $MYDIR/local.conf ]
then
    . $MYDIR/local.conf
fi

if [ ! -c /dev/null -a -w / ]
then
    echo Creating /dev devices...
    mkdir /dev
    mknod /dev/null		c   1 3
    mknod /dev/zero		c   1 5
    mknod /dev/tty		c   5 0
    mknod /dev/console		c   5 1
    mknod /dev/sda		b   8 0
    mknod /dev/sda1		b   8 1
    mknod /dev/sda2		b   8 2
    mknod /dev/sda3		b   8 3
    mknod /dev/sda4		b   8 4
    mknod /dev/mmcblk0		b 179 0
    mknod /dev/mmcblk0p1	b 179 1
    mknod /dev/mmcblk0p2	b 179 2
    mknod /dev/mmcblk0p3	b 179 3
    mknod /dev/mmcblk0p4	b 179 4
    mknod /dev/ttyO0		c 253 0
    mknod /dev/ttyO1		c 253 1
    mknod /dev/ttyO2		c 253 2
    mknod /dev/ttyO3		c 253 3
fi

# ------------------------------------------------------------

mkdirp()
{
    test -d $1 || mkdir -p $1
}

mkdirp $ROOTFS
mkdirp $PREFIX
mkdirp $BUILDDIR

export PATH=$PREFIX/bin:$PATH

go()
{
  "$0" "$@"
}

mcd()
{
    test -d $1 || mkdir -p $1
    cd $1
}

notparallel()
{
    echo .NOTPARALLEL: >> Makefile
}

fix_la()
{
    for la in $ROOTFS/usr/lib/*$1*.la
    do
	rm $la
    done
}

case "$1" in
    "" )
	go clean

	# Keep these in the order in which they must be built.  You
	# will thus normally add new packages to the end of the list.

	go cpio
	go ncurses
	go m4
	go flex
	go bison
	go texinfo
	go gdb

	go curl
	go nspr
	go pcre
	go readline

	go chkconfig
	go sqlite
	go gdbm
	go gawk
	go pth
	go libtool
	go db4
	go perl
	go openssl
	go gettext
	go popt
	go glib2
	go pkgconfig
	go nss

	# Packages known to not build yet - should be a clause later
	# in the file describing why.

	# go gnupg	# not yet
	# go rpm	# not yet
	;;

    "clean" )
	;;

    # Packages built by stage1

    binutils | gcc | glibc | kernel | x-loader | u-boot \
    | gmp | mpfr | libmpc | mpc | ppl | cloog | libselinux | zlib \
    | bash | make | sed | coreutils | util-linux | tar | gzip \
    | bzip2 | diffutils | findutils | gawk | patch | unzip | which | gz | grep )

        echo "$1 is built in stage1"
        exit 1
        ;;

#--------------------------------------------------

    cpio )
	mcd $BUILDDIR/$1
	$SRC/${1}-*/configure $TCONFIGARGS
	notparallel
	make $J
	make $J install
	;;

    ncurses )
	mcd $BUILDDIR/ncurses
	$SRC/ncurses-*/configure $TCONFIGARGS \
	    --with-shared --without-ada --with-ospeed=unsigned \
	    --enable-hard-tabs --enable-xmc-glitch --enable-colorfgbg \
	    --enable-overwrite \
	    --enable-pc-files \
	    --with-termlib=tinfo \
	    --with-chtype=long \
	    --with-ticlib
	notparallel
	make $J
	make $J install
	;;

    m4 )
	mcd $BUILDDIR/m4
	$SRC/m4-*/configure $TCONFIGARGS
	make $J -k
	make $J -k install
	;;

    flex )
	mcd $BUILDDIR/flex
	$SRC/flex-*/configure $TCONFIGARGS --disable-dependency-tracking
	make $J -k
	make $J -k install
	;;

    bison )
	mcd $BUILDDIR/bison
	$SRC/bison-*/configure $TCONFIGARGS
	make $J -k
	make $J -k install
	;;

    texinfo )
	mcd $BUILDDIR/texinfo
	$SRC/texinfo-*/configure $TCONFIGARGS
	make $J -k
	make $J -k install
	;;

    gdb )
	mcd $BUILDDIR/gdb
	$SRC/gdb-*/configure $TCONFIGARGS --without-rpm
	notparallel
	make $J -k
	make $J -k install
	;;

    curl )
	mcd $BUILDDIR/curl
	$SRC/curl-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    nspr )
	mcd $BUILDDIR/nspr
	$SRC/nspr-*/mozilla/nsprpub/configure $TCONFIGARGS --enable-thumb2
	make $J
	make $J install
	;;

    rpm )
	mcd $BUILDDIR/rpm
	$SRC/${1}-*/configure $TCONFIGARGS
	notparallel
	make $J
	make $J install
	;;
    
    pth )
	mcd $BUILDDIR/pth
	$SRC/${1}-*/configure $TCONFIGARGS
	make $J
        make $J install
	;;
    
    chkconfig )
        mcd $BUILDDIR/pth
        #$SRC/${1}-*/configure $TCONFIGARGS
        make $J
        make $J install
        ;;

    sqlite )
	#####################################################
	# sqlite is choking on sqlite_int64 definition
	#####################################################
	mcd $BUILDDIR/sqlite
	export CFLAGS="$RPM_OPT_FLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_DISABLE_DIRSYNC=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -Wall -fno-strict-aliasing"
	$SRC/sqlite-*/configure --disable-tcl --enable-threadsafe --enable-threads-override-locks --enable-load-extension $TCONFIGARGS
	# the compile would fail here, so on a host you need to run
	# tclsh ../../rpmbuild/BUILD/sqlite-src-3070500/tool/mksqlite3h.tcl ../../rpmbuild/BUILD/sqlite-src-3070500 > sqlite3.h
	# Also possibly add -ldl to TLIB in the Makefile
	make $J
	make $J install
	;;

     gdbm )
	mcd $BUILDDIR/gdbm
	$SRC/${1}-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

     nss ) 
	########################################################
	# needs perl
	########################################################
        mcd $BUILDDIR/nss
	BUILD_OPT=1
	export BUILD_OPT
	PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
	PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1

	export PKG_CONFIG_ALLOW_SYSTEM_LIBS
	export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
	NSPR_INCLUDE_DIR=/usr/include/nspr
	NSPR_LIB_DIR=/usr/lib
	export NSPR_INCLUDE_DIR
	export NSPR_LIB_DIR
	NSS_USE_SYSTEM_SQLITE=1
	export NSS_USE_SYSTEM_SQLITE
        make -C $SRC/${1}-3.12.10/mozilla/security/coreconf
	make -C $SRC/${1}-3.12.10/mozilla/security/dbm
	make -C $SRC/${1}-3.12.10/mozilla/security/nss
        cd $SRC/${1}-3.12.10/mozilla/security/coreconf
        make install
        cd $SRC/${1}-3.12.10/mozilla/security/dbm
        make install
        cd $SRC/${1}-3.12.10/mozilla/security/nss
        make install
        ;;
  
     gnupg )
	####################################################### 
	# needs libgpg-error, libgcrypt, libassuan, libksba
	#######################################################
	mcd $BUILDDIR/gnupg2
	$SRC/${1}-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    pcre )
	mcd $BUILDDIR/pcre
	$SRC/pcre-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    readline )
	mcd $BUILDDIR/readline
	$SRC/readline-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    libtool )
	mcd $BUILDDIR/libtool
	$SRC/libtool-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    db4 )
	mcd $BUILDDIR/db4
	$SRC/db-*/dist/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    perl )
	mcd $BUILDDIR/perl
	cd $SRC/perl-*
	sh $SRC/perl-*/Configure -des -Dprefix=/usr -DDEBUGGING=-g  -Dcc=gcc -Dmyhostname=localhost -Dperladmin=root@localhost -Duseshrplib -Dusethreads -Duseithreads -Uusedtrace -Duselargefiles -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto
	make
	make install
;;

    openssl )
        mcd $BUILDDIR/openssl
        cd $SRC/openssl-*
       ./Configure --prefix=/usr --openssldir=/etc/pki/tls zlib enable-camellia enable-seed enable-tlsext enable-rfc3779 enable-cms enable-md2 no-idea no-mdc2 no-rc5 no-ec no-ecdh no-ecdsa shared linux-generic32
        make depend
        make all
        make rehash
        make install
        ;;

    gettext )
	mcd $BUILDDIR/gettext
	$SRC/gettext-*/configure $TCONFIGARGS --disable-static --enable-shared --with-pic-=yes --disable-csharp --disable-rpath
	make $J
	make $J install
	;;

    popt )
	mcd $BUILDDIR/popt
	$SRC/popt-*/configure $TCONFIGARGS
	make $J
	make $J install
	;;

    glib2 )
	mcd $BUILDDIR/glib2
	# glib2 expects --enable-threads=yes to enable threads,
	#  anything else disables threads
	$SRC/glib-*/configure `echo $TCONFIGARGS | sed 's/posix/yes/'` --enable-static
	make $J
	make $J install
	;;

    pkgconfig )
	mcd $BUILDDIR/pkg-config
	$SRC/pkg-config-*/configure $TCONFIGARGS --disable-shared --with-installed-glib --with-installed-popt
	make $J
	make $J install
	
esac

exit 0