5 # $2 grub_arch (if x86 or x86_64):
11 grub_version
="0.97" # "0.97" or "svn" or "1.96"
13 bochs_version
="2.4.1" # "svn" or 2.4.1
15 binutils_version
="2.19.1"
16 gcc_version
="4.4.0" # or "snapshot-version"
17 gcc_version_clean
="4.4.0"
18 gcc_is_snapshot
="false" # or "true"
24 echo "Error: No architecture selected"
33 echo "Error: No grub architecture selected. Use \"x86_64-unknown\" or \"i386-pc\""
41 echo "Enter the path where the cross compiled tools are stored: "
43 if [ ! -d $tool_path ]
45 echo "Error: Not a directory"
55 if [ ! -e $curdir/bin
/grub-
$grub_version ]
57 if [ $grub_version = "svn" ]
59 echo "Downloading grub from svn"
60 svn co svn
://svn.savannah.gnu.org
/grub
/trunk
/grub2
62 if [ ! -e grub-
$grub_version.
tar.gz
]
64 echo "Downloading grub-$grub_version"
65 wget
ftp://alpha.gnu.org
/gnu
/grub
/grub-
$grub_version.
tar.gz
67 echo "Unpacking grub-$grub_version"
68 tar -xf grub-
$grub_version.
tar.gz
69 if [ $grub_version = "0.97" ]
71 echo "Patching (x86-64 elf) grub-$grub_version"
72 cp grub_x86_64.
patch grub-
$grub_version && cd grub-
$grub_version && patch -p1 <grub_x86_64.
patch && cd ..
76 echo "Compiling/Installing grub-$grub_version"
77 if [ $grub_version = "svn" ]
79 cd grub2
&& .
/configure
--prefix=$curdir/bin
&& make && make install && make clean
81 cd grub-
$grub_version && .
/configure
--prefix=$curdir/bin
&& make && make install && make clean
87 if [ $grub_version = "svn" ]
91 rm -rf grub-
$grub_version
96 echo "Error: Grub build failed"
100 touch $curdir/bin
/grub-
$grub_version
104 rm -f ..
/build
/x86
/boot
/grub
/stage1 ..
/build
/x86
/boot
/grub
/stage2_eltorito ..
/build
/x86
/boot
/grub
/stage2 ..
/build
/x86_64
/boot
/grub
/stage1 ..
/build
/x86_64
/boot
/grub
/stage2_eltorito ..
/build
/x86_64
/boot
/grub
/stage2
105 ln -s $curdir/bin
/lib
/grub
/$2/stage1 ..
/build
/x86
/boot
/grub
/stage1
106 ln -s $curdir/bin
/lib
/grub
/$2/stage2_eltorito ..
/build
/x86
/boot
/grub
/stage2_eltorito
107 ln -s $curdir/bin
/lib
/grub
/$2/stage2 ..
/build
/x86
/boot
/grub
/stage2
108 ln -s $curdir/bin
/lib
/grub
/$2/stage1 ..
/build
/x86_64
/boot
/grub
/stage1
109 ln -s $curdir/bin
/lib
/grub
/$2/stage2_eltorito ..
/build
/x86_64
/boot
/grub
/stage2_eltorito
110 ln -s $curdir/bin
/lib
/grub
/$2/stage2 ..
/build
/x86_64
/boot
/grub
/stage2
117 if [ ! -e $curdir/bin
/nasm-
$nasm_version ]
119 if [ ! -e nasm-
$nasm_version.
tar.bz2
]
121 echo "Downloading nasm-$nasm_version"
122 wget http
://www.nasm.us
/pub
/nasm
/releasebuilds
/$nasm_version/nasm-
$nasm_version.
tar.bz2
125 echo "Unpacking nasm-$nasm_version"
126 tar -xf nasm-
$nasm_version.
tar.bz2
128 echo "Compiling/Installing nasm-$nasm_version"
129 cd nasm-
$nasm_version && .
/configure
--prefix=$curdir/bin
&& make && make install && make clean
133 rm -rf nasm-
$nasm_version
137 echo "Error: Nasm build failed"
141 touch $curdir/bin
/nasm-
$nasm_version
146 ln -s $curdir/bin
/bin
/nasm nasm
151 ! [ $3 = "--no-bochs" ]
156 if [ ! -e bin
/bochs-
$bochs_version ]
158 if [ $bochs_version = "svn" ]
160 echo "Downloading bochs from svn"
161 cvs
-z3 -d:pserver
:anonymous@bochs.cvs.sourceforge.net
:/cvsroot
/bochs co
-P bochs
162 else if [ ! -e bochs-
$bochs_version.
tar.gz
]
164 echo "Downloading bochs-$bochs_version"
165 wget http
://garr.dl.sourceforge.net
/sourceforge
/bochs
/bochs-
$bochs_version.
tar.gz
167 echo "Unpacking bochs-$bochs_version"
168 tar -xf bochs-
$bochs_version.
tar.gz
171 echo "Compile/Installing bochs-$bochs_version"
172 flags
="--enable-x86-64 --enable-apic --enable-ne2000 --enable-acpi --enable-pci --enable-usb --enable-mtrr --enable-debugger --enable-disasm --enable-all-optimizations --enable-vbe --enable-clgd54xx --enable-vme --enable-sse=4 --enable-sse-extension --enable-x86-debugger --enable-smp --enable-sb16=linux"
174 if [ $bochs_version = "svn" ]
176 cd bochs
&& .
/configure
--prefix=$curdir/bin
$flags && make && make install && make clean
178 cd bochs-
$bochs_version && .
/configure
--prefix=$curdir/bin
$flags && make && make install && make clean
184 if [ $bochs_version = "svn" ]
188 rm -rf bochs-
$bochs_version
193 echo "Error: Bochs build failed"
196 touch $curdir/bin
/bochs-
$bochs_version
201 rm -f x86-bochs x86_64-bochs
202 ln -s $curdir/bin
/bin
/bochs x86-bochs
203 ln -s $curdir/bin
/bin
/bochs x86_64-bochs
206 if [ ! -e $curdir/bin
/qemu-
$qemu_version ]
208 if [ ! -e qemu-
$qemu_version.
tar.gz
]
210 echo "Downloading qemu-$qemu_version"
211 wget http
://savannah.nongnu.org
/download
/qemu
/qemu-
$qemu_version.
tar.gz
213 echo "Unpacking qemu-$qemu_version"
214 tar -xf qemu-
$qemu_version.
tar.gz
215 echo "Compiling/Installing qemu-$qemu_version"
216 cd qemu-
$qemu_version && .
/configure
--target-list=x86_64-softmmu
--prefix=$curdir/bin
&& make && make install && make clean
219 rm -rf qemu-
$qemu_version
223 echo "Error: Qemu build failed"
226 touch $curdir/bin
/qemu-
$qemu_version
229 rm -f x86-qemu x86_64-qemu
230 ln -s $curdir/bin
/bin
/qemu-system-x86_64 x86-qemu
231 ln -s $curdir/bin
/bin
/qemu-system-x86_64 x86_64-qemu
233 # Architecture (for binutils and gcc)
236 target
="i686-pc-lightos"
238 elif [ $1 = "x86_64" ]
240 target
="x86_64-pc-lightos"
241 binutils_flags
="--enable-64-bit-bfd"
243 echo "Error: Invalid architecture selected: " $1
248 if [ ! -e $curdir/bin
/binutils-
$1-$binutils_version ]
250 if [ ! -e binutils-
$binutils_version.
tar.bz2
]
252 echo "Downloading binutils-$binutils_version"
253 wget http
://ftp.gnu.org
/gnu
/binutils
/binutils-
$binutils_version.
tar.bz2
256 echo "Unpacking binutils-$binutils_version"
257 tar -xf binutils-
$binutils_version.
tar.bz2
258 echo "Patching binutils-$binutils_version"
259 cd binutils-
$binutils_version && patch -p0 < ..
/binutils.
patch && cd ..
260 echo "Compiling/Installing binutils-$binutils_version"
261 cd binutils-
$binutils_version && .
/configure
--prefix=$curdir/bin
--with-sysroot=$curdir/bin
--target=$target $binutils_flags --disable-nls && make -j3 all
&& make install && make clean
264 rm -rf binutils-
$binutils_version
267 echo "Error: Binutils $1 build failed"
271 touch $curdir/bin
/binutils-
$1-$binutils_version
274 rm -f $1-ar $1-as $1-c++filt
$1-ld $1-nm $1-objdump $1-readelf $1-strip
275 ln -s $curdir/bin
/bin
/$target-ar $1-ar
276 ln -s $curdir/bin
/bin
/$target-as $1-as
277 ln -s $curdir/bin
/bin
/$target-c++filt
$1-c++filt
278 ln -s $curdir/bin
/bin
/$target-ld $1-ld
279 ln -s $curdir/bin
/bin
/$target-nm $1-nm
280 ln -s $curdir/bin
/bin
/$target-objdump $1-objdump
281 ln -s $curdir/bin
/bin
/$target-readelf $1-readelf
282 ln -s $curdir/bin
/bin
/$target-strip $1-strip
284 # Directories for gcc
285 if ! [ -e $curdir/bin
/usr
]
287 mkdir
$curdir/bin
/usr
290 if ! [ -e $curdir/bin
/usr
/include
]
292 mkdir
$curdir/bin
/usr
/include
295 # Install the libraries (for libgcc)
298 cd ..
&& .
/configure
--arch x86
&& make install-headers
&& cd $curdir
299 elif [ $1 = "x86_64" ]
301 cd ..
&& .
/configure
--arch x86_64
&& make install-headers
&& cd $curdir
305 if [ ! -e $curdir/bin
/gcc-
$1-$gcc_version ]
307 if [ ! -e gcc-core-
$gcc_version.
tar.bz2
]
309 echo "Downloading gcc-core-$gcc_version"
310 if [ $gcc_is_snapshot = "true" ]
312 wget
ftp://gcc.gnu.org
/pub
/gcc
/snapshots
/$gcc_version/gcc-core-
$gcc_version.
tar.bz2
314 wget
ftp://ftp.fu-berlin.de
/unix
/languages
/gcc
/releases
/gcc-
$gcc_version/gcc-core-
$gcc_version.
tar.bz2
317 if [ ! -e gcc-g
++-$gcc_version.
tar.bz2
]
319 echo "Downloading gcc-g++-$gcc_version"
320 if [ $gcc_is_snapshot = "true" ]
322 wget
ftp://gcc.gnu.org
/pub
/gcc
/snapshots
/$gcc_version/gcc-g
++-$gcc_version.
tar.bz2
324 wget
ftp://ftp.fu-berlin.de
/unix
/languages
/gcc
/releases
/gcc-
$gcc_version/gcc-g
++-$gcc_version.
tar.bz2
327 echo "Unpacking gcc-core-$gcc_version"
328 tar -xf gcc-core-
$gcc_version.
tar.bz2
329 echo "Unpacking gcc-g++-$gcc_version"
330 tar -xf gcc-g
++-$gcc_version.
tar.bz2
331 echo "Patching gcc-$gcc_version"
332 cd gcc-
$gcc_version && patch -p0 < ..
/gcc.
patch && cd ..
333 echo "Compiling/Installing gcc-$gcc_version"
336 ..
/gcc-
$gcc_version/configure
--prefix=$curdir/bin
--with-sysroot=$curdir/bin
--target=$target --disable-nls --enable-languages=c
,c
++ && make -j3 all-gcc all-target-libgcc
&& make install-gcc install-target-libgcc
&& make clean
339 rm -rf build gcc-
$gcc_version
342 echo "Error: Gcc $1 build failed"
345 touch $curdir/bin
/gcc-
$1-$gcc_version
348 rm -f $1-libgcc.a
$1-gcc $1-g++ $1-gcc-include $1-gcc-include-fixed
349 ln -s $curdir/bin
/lib
/gcc
/$target/$gcc_version_clean/libgcc.a
$1-libgcc.a
350 ln -s $curdir/bin
/bin
/$target-gcc $1-gcc
351 ln -s $curdir/bin
/bin
/$target-g++ $1-g++