summaryrefslogtreecommitdiffstats
path: root/tools/lib32/build32.sh
blob: 758625aac094403671b9740bfd0aee4cb0d0951a (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
#! /bin/sh
# $FreeBSD$
#
# This script is for running on a self-hosted amd64 machine, with an up-to-date
# world and toolchain etc.  ie: the installed world is assumed to match the sources.
# It is rude, crude and brutal.  But its the only option for now.
#
# Its purpose is to build a 32 bit library set and a ld-elf32.so.1.

# XXX beware.. some of the library targets have no way to disable
# XXX installation of includes.  ie: it will re-install some files in
# XXX /usr/include for you.

mkdir -p /lib32
mkdir -p /usr/lib32
mkdir -p /usr/local/lib32
mkdir -p /usr/X11R6/lib32

export MAKEOBJDIRPREFIX=/tmp/i386
mkdir -p $MAKEOBJDIRPREFIX

# Set up an obj tree
chflags -R noschg $MAKEOBJDIRPREFIX
rm -rf $MAKEOBJDIRPREFIX
mkdir -p $MAKEOBJDIRPREFIX

CCARGS="-m32 -march=athlon-xp -msse2 -mfancy-math-387 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32"
CXXARGS="-m32 -march=athlon-xp -msse2 -mfancy-math-387 -I/tmp/i386/root/usr/include/c++/3.4 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32"

# and a place to put the alternate include tree into.
mkdir -p $MAKEOBJDIRPREFIX/root

export MACHINE_ARCH=i386
export DESTDIR=$MAKEOBJDIRPREFIX/root

make -s hierarchy

# Now build includes
make -s obj
make -s includes

unset MACHINE_ARCH
unset DESTDIR

# libncurses needs a build-tools pass first.  I wish build-tools was a recursive target.
(cd lib/libncurses; make -s build-tools)
(cd lib/libmagic; make -s build-tools)

# Now the libraries.  This doesn't work for gnuregex yet. hence -k.
# libbind is just an internal target, ignore it.
export LIBDIR=/usr/lib32
export SHLIBDIR=/usr/lib32
export MACHINE_ARCH=i386
export CC="cc $CCARGS"
export CXX="c++ $CXXARGS"
export LD="ld -m elf_i386_fbsd -Y P,/usr/lib32" 
export AS="as --32"
make -s -DNO_BIND -DNOMAN -DNODOC -DNOINFO libraries

# and now that we have enough libraries, build ld-elf32.so.1
cd libexec/rtld-elf
export PROG=ld-elf32.so.1
unset CC
export CC="cc $CCARGS -DCOMPAT_32BIT"
make -s -DNOMAN -DNODOC -DNOINFO -k obj
make -s -DNOMAN -DNODOC -DNOINFO -k depend
make -s -DNOMAN -DNODOC -DNOINFO -k 
make -s -DNOMAN -DNODOC -DNOINFO -k install

chflags -R noschg $MAKEOBJDIRPREFIX
OpenPOWER on IntegriCloud