* mikeOS 16 bit and amd64 baremetal
[mascara-docs.git] / i86 / mikeos-4.1.2 / build-osx.sh
blobb9d63631a2119cec45d3bce3cb4f0aa11d95cea9
1 #!/bin/sh
3 # This script assembles the MikeOS bootloader, kernel and programs
4 # with NASM, and then creates floppy and CD images (on Mac OS X)
6 # Only the root user can mount the floppy disk image as a virtual
7 # drive (loopback mounting), in order to copy across the files
10 echo ">>> MikeOS OS X build script - requires nasm and mkisofs"
13 if test "`whoami`" != "root" ; then
14 echo "You must be logged in as root to build (for loopback mounting)"
15 echo "Enter 'su' or 'sudo bash' to switch to root"
16 exit
20 echo ">>> Assembling bootloader..."
22 nasm -O0 -f bin -o source/bootload/bootload.bin source/bootload/bootload.asm || exit
25 echo ">>> Assembling MikeOS kernel..."
27 cd source
28 nasm -O0 -f bin -o kernel.bin kernel.asm || exit
29 cd ..
32 echo ">>> Assembling programs..."
34 cd programs
36 for i in *.asm
38 nasm -O0 -f bin $i -o `basename $i .asm`.bin || exit
39 done
41 cd ..
43 echo ">>> Creating floppy..."
44 cp disk_images/mikeos.flp disk_images/mikeos.dmg
47 echo ">>> Adding bootloader to floppy image..."
49 dd conv=notrunc if=source/bootload/bootload.bin of=disk_images/mikeos.dmg || exit
52 echo ">>> Copying MikeOS kernel and programs..."
54 rm -rf tmp-loop
56 dev=`hdid -nobrowse -nomount disk_images/mikeos.dmg`
57 mkdir tmp-loop && mount -t msdos ${dev} tmp-loop && cp source/kernel.bin tmp-loop/
59 cp programs/*.bin programs/*.bas programs/test.pcx tmp-loop
61 echo ">>> Unmounting loopback floppy..."
63 umount tmp-loop || exit
64 hdiutil detach ${dev}
66 rm -rf tmp-loop
68 echo ">>> MikeOS floppy image is disk_images/mikeos.dmg"
71 echo ">>> Creating CD-ROM ISO image..."
73 rm -f disk_images/mikeos.iso
74 mkisofs -quiet -V 'MIKEOS' -input-charset iso8859-1 -o disk_images/mikeos.iso -b mikeos.dmg disk_images/ || exit
76 echo '>>> Done!'