App inst fixed on invalid image file; App zinstall for ZDE works - we've got GUI...
[ZeXOS.git] / build.sh
blob2918a2db43dd51308470bcf1c8096e89d7d23218
1 #!/bin/bash
3 VERSION="0.6.7"
4 ARCHITECTURE="i386"
6 APPPREFIX="/usr/bin"
8 if [ -z $ARCH ] ; then
9 ARCH=$ARCHITECTURE
12 export ARCH
14 if [ "$ARCH" = "i386" ] ; then
15 CC="gcc -m32"
16 LD="ld -m elf_i386"
17 AR="ar"
18 elif [ "$ARCH" = "x86_64" ] ; then
19 CC="gcc -m64"
20 LD="ld -m elf_x86_64"
21 AR="ar"
22 elif [ "$ARCH" = "arm" ] ; then
23 CC=$(ls /usr/bin/arm*-gcc)
24 LD=$(ls /usr/bin/arm*-ld)
25 AR=$(ls /usr/bin/arm*-ar)
28 export CC
29 export LD
30 export AR
32 cd `dirname $0`
34 if ! [ -e $APPPREFIX/make ] ; then
35 echo "Please install package: make"
36 exit -1
39 if [ "$1" = "clean" ] ; then
40 echo "Cleaning source from object files .."
41 make clean -C libc &&
42 make clean -C libx &&
43 make clean -C libm &&
44 make clean -C libipc &&
45 make clean -C libpthread &&
46 make clean -C libsnd && \
47 rm -f tools/ips2ip/ips2ip ; \
48 rm -f iso/boot/kernel.bin ; \
49 rm -f iso/README ; \
50 rm -f zexos-$VERSION-*.iso ; \
51 rm -f zexos-$VERSION-$ARCH.img ; \
52 make clean -C kernel ; \
53 echo "OK"
54 exit 0
57 if ! [ -e $APPPREFIX/gcc ] ; then
58 echo "Please install package: gcc"
59 exit -1;
61 if ! [ -e $APPPREFIX/nasm ] ; then
62 echo "Please install package: nasm"
63 exit -1;
66 if [ "$1" = "qemu" ] ; then
67 if ! [ -e $APPPREFIX/qemu ] ; then
68 echo "Please install package: qemu"
69 exit -1
72 make -C kernel
74 if [ "$ARCH" = "arm" ] ; then
75 qemu-system-arm -kernel kernel/kernel.bin -serial stdio
76 exit 1
79 if [ "$ARCH" = "ppc" ] ; then
80 qemu-system-powerpc -kernel kernel/kernel.bin
81 exit 1
82 else
83 qemu -cdrom zexos-$VERSION-$ARCH.iso
84 exit 1
87 exit 0
90 if [ -e kernel/.config ]
91 then
92 echo "Checking for .config: OK"
93 else
94 echo "Using default kernel config - defconfig .."
95 cp kernel/defconfig kernel/.config
97 if [ -e kernel/.config ] ; then
98 echo " :)"
99 else
100 echo "Please check your .config file in kernel directory and try it again !"
101 exit 0
105 make -C kernel
106 if [ "$ARCH" = "i386" ] ; then
107 make -C libc
108 make -C libx
109 make -C libm
110 make -C libipc
111 make -C libpthread
112 make -C libsnd
115 if [ -e kernel/kernel.bin ] ; then
116 echo "Source was compiled succefully"
119 if [ "$1" = "iso" ] ; then
120 if ! [ -e $APPPREFIX/mkisofs ] ; then
121 echo "Please install package: cdrtools (mkisofs)"
122 exit -1
125 if [ -n "$2" ] ; then
126 make -C apps/$2 iso
129 cp kernel/kernel.bin iso/boot/kernel.bin &&
130 cp README iso/README &&
131 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 60 -boot-info-table -o zexos-$VERSION-$ARCH.iso iso &&
132 echo iso created OK && exit 0
135 if [ "$1" = "img" ] || [ "$1" = "floppy" ] ; then
136 wget -c http://zexos.sf.net/zexos.img && \
137 mkdir zexos ; \
138 mount -oloop zexos.img zexos && \
140 if [ -e zexos-$VERSION-$ARCH.iso ] ; then
141 echo " :)"
142 else
143 echo "I have to make .iso image first"
144 cp kernel/kernel.bin iso/boot/kernel.bin &&
145 cp libc/libc.a iso/libc.a &&
146 cp README iso/README &&
147 mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o zexos-$VERSION-$ARCH.iso iso
150 mkdir zexosiso ; \
151 mount -oloop zexos-$VERSION-$ARCH.iso zexosiso && \
152 cp zexosiso/boot/kernel.bin zexos/boot/ && \
153 umount zexosiso && \
154 umount zexos && \
155 rmdir zexosiso && \
156 rmdir zexos && \
157 mv zexos.img zexos-$VERSION-$ARCH.img && \
158 rm zexos-$VERSION-$ARCH.iso && \
159 echo "OK - Image 'zexos-$VERSION-$ARCH.img' was created succefully."
160 echo "Please wait until installer copy image to floppy ..."
161 if [ "$1" = "floppy" ] ; then
162 dd if=zexos-$VERSION-$ARCH.img of=/dev/fd0 bs=1440k && \
163 echo "Installation on floppy is done, enjoy !"