1 | #!/bin/sh
|
---|
2 |
|
---|
3 | # This script creates a 'develop' directory that can be used from Haiku
|
---|
4 |
|
---|
5 | set -x
|
---|
6 |
|
---|
7 | #
|
---|
8 | # 1. Check command line arguments
|
---|
9 | #
|
---|
10 |
|
---|
11 | if [ $# \< 2 ]; then
|
---|
12 | echo Usage: $0 '<haiku trunkdir> <buildtools dir> [ <haiku output dir> ]' >&2
|
---|
13 | exit 1
|
---|
14 | fi
|
---|
15 |
|
---|
16 | #
|
---|
17 | # 2. Set up environment
|
---|
18 | #
|
---|
19 |
|
---|
20 | haikuSourceDir=$1
|
---|
21 | buildToolsDir=$2/legacy
|
---|
22 |
|
---|
23 | if [ $# \< 3 ]; then
|
---|
24 | haikuOutputDir=$haikuSourceDir/generated
|
---|
25 | else
|
---|
26 | haikuOutputDir=$3
|
---|
27 | fi
|
---|
28 |
|
---|
29 | if [ ! -d $haikuSourceDir ]; then
|
---|
30 | echo "No such directory: \"$haikuSourceDir\"" >&2
|
---|
31 | exit 1
|
---|
32 | fi
|
---|
33 |
|
---|
34 | if [ ! -d $buildToolsDir ]; then
|
---|
35 | echo "No such directory: \"$buildToolsDir\"" >&2
|
---|
36 | exit 1
|
---|
37 | fi
|
---|
38 |
|
---|
39 | # create the output dir
|
---|
40 | mkdir -p $haikuOutputDir || exit 1
|
---|
41 |
|
---|
42 | # get absolute paths
|
---|
43 | currentDir=$(pwd)
|
---|
44 |
|
---|
45 | cd $haikuSourceDir
|
---|
46 | haikuSourceDir=$(pwd)
|
---|
47 | cd $currentDir
|
---|
48 |
|
---|
49 | cd $buildToolsDir
|
---|
50 | buildToolsDir=$(pwd)
|
---|
51 | cd $currentDir
|
---|
52 |
|
---|
53 | cd $haikuOutputDir
|
---|
54 | haikuOutputDir=$(pwd)
|
---|
55 |
|
---|
56 | # create the object and installation directories for the cross compilation tools
|
---|
57 | installDir=$haikuOutputDir/developer-tools
|
---|
58 | objDir=$haikuOutputDir/developer-tools-build
|
---|
59 | binutilsObjDir=$objDir/binutils
|
---|
60 | gccObjDir=$objDir/gcc
|
---|
61 |
|
---|
62 | rm -rf $installDir $objDir
|
---|
63 | mkdir -p $installDir $objDir $binutilsObjDir $gccObjDir $tmpIncludeDir \
|
---|
64 | $tmpLibDir || exit 1
|
---|
65 |
|
---|
66 | #
|
---|
67 | # 3. Copy necessities
|
---|
68 | #
|
---|
69 |
|
---|
70 | cd $haikuOutputDir/objects/haiku/x86/release/system/glue/arch/x86
|
---|
71 | cp crti.o crtn.o ../../../../../../../../cross-tools/i586-pc-beos/lib
|
---|
72 | cd $currentDir
|
---|
73 |
|
---|
74 | # Copy init_term_dyn.o and start_dyn.o
|
---|
75 | cd $haikuOutputDir/objects/haiku/x86/release/system/glue
|
---|
76 | cp init_term_dyn.o start_dyn.o ../../../../../../cross-tools/i586-pc-beos/lib
|
---|
77 | cd $currentDir
|
---|
78 |
|
---|
79 | # Copy system libs
|
---|
80 | cd $haikuOutputDir/objects/haiku/x86/release
|
---|
81 | cp system/libroot/libroot.so ../../../../cross-tools/lib/gcc-lib/i586-pc-beos/2.95.3-beos-060710
|
---|
82 | cd $currentDir
|
---|
83 |
|
---|
84 | # Copy Haiku POSIX headers and their dependencies
|
---|
85 | copy_headers()
|
---|
86 | {
|
---|
87 | sourceDir=$1
|
---|
88 | targetDir=$2
|
---|
89 |
|
---|
90 | headers="$(find $sourceDir -name \*\.h | grep -v /.svn)"
|
---|
91 | headers="$(echo $headers | sed -e s@$sourceDir/@@g)"
|
---|
92 | for f in $headers; do
|
---|
93 | headerTargetDir=$targetDir/$(dirname $f)
|
---|
94 | mkdir -p $headerTargetDir
|
---|
95 | cp $sourceDir/$f $headerTargetDir
|
---|
96 | done
|
---|
97 | }
|
---|
98 |
|
---|
99 | copy_headers $haikuSourceDir/headers/os $haikuOutputDir/cross-tools/i586-pc-beos/sys-include/be
|
---|
100 | copy_headers $haikuSourceDir/headers/posix $haikuOutputDir/cross-tools/i586-pc-beos/sys-include/posix
|
---|
101 |
|
---|
102 | #
|
---|
103 | # 4. Build binutils
|
---|
104 | #
|
---|
105 | cd $binutilsObjDir
|
---|
106 |
|
---|
107 | PATH=$haikuOutputDir/cross-tools/bin:$PATH
|
---|
108 |
|
---|
109 | $buildToolsDir/binutils/configure --prefix=$installDir --host=i586-pc-beos --build=i486-linux-gnu --target=i586-pc-beos --disable-nls --enable-shared=yes --disable-werror || exit 1
|
---|
110 |
|
---|
111 | make || exit 1
|
---|
112 |
|
---|
113 | make install || exit 1
|
---|
114 |
|
---|
115 | #
|
---|
116 | # 5. Build gcc
|
---|
117 | #
|
---|
118 |
|
---|
119 | # configure gcc
|
---|
120 | cd $gccObjDir
|
---|
121 | CFLAGS="-O2" CXXFLAGS="-O2" $buildToolsDir/gcc/configure --prefix=$installDir \
|
---|
122 | --host=i586-pc-beos --build=i486-linux-gnu --target=i586-pc-beos --disable-nls \
|
---|
123 | --enable-shared=yes --enable-languages=c,c++ || exit 1
|
---|
124 |
|
---|
125 | # hack the Makefile to avoid trouble with stuff we don't need anyway
|
---|
126 | sedExpr=
|
---|
127 | for toRemove in libiberty libio libjava libobjc libstdc++; do
|
---|
128 | sedExpr="$sedExpr -e 's@^\(TARGET_CONFIGDIRS =.*\)$toRemove\(.*\)@\1\2@'"
|
---|
129 | done
|
---|
130 | echo sedExpr: $sedExpr
|
---|
131 | mv Makefile Makefile.bak || exit 1
|
---|
132 | eval "sed $sedExpr Makefile.bak > Makefile" || exit 1
|
---|
133 | rm Makefile.bak
|
---|
134 |
|
---|
135 | # make gcc
|
---|
136 | make || {
|
---|
137 | echo "ERROR: Building gcc failed." >&2
|
---|
138 | exit 1
|
---|
139 | }
|
---|
140 |
|
---|
141 | # install gcc
|
---|
142 | make install-gcc-cross || {
|
---|
143 | echo "ERROR: Installing the cross compiler failed." >&2
|
---|
144 | exit 1
|
---|
145 | }
|
---|
146 |
|
---|
147 | #
|
---|
148 | # 6. Copy headers into the developer-tools
|
---|
149 | #
|
---|
150 |
|
---|
151 | copy_headers $haikuSourceDir/headers/os $installDir/i586-pc-beos/sys-include/be
|
---|
152 | copy_headers $haikuSourceDir/headers/posix $installDir/i586-pc-beos/sys-include/posix
|
---|