As for me I use code::blocks IDE.
At the beginning I used DJGPP and batch based build (and yes from tutorial). However I quickly ran into trouble with batch build (dos command line args can't be too long, it still continues to compile if an error occured and no IDE can pick up easily the output/support batch building) So I wrote a makefile (kinda adventure on it's own for me). and configured code::blocks to compile directly using djgpp (required some hacking) BTW if anyone tries to do the same then
Code: Select all
@echo %* > c:\djgpp\bin\gcc_params.txt
@c:\djgpp\bin\gcc.exe @c:\djgpp\bin\gcc_params.txt 2>&1
@del /Q c:\djgpp\bin\gcc_params.txt
Well this setup worked for a little while but was very awkward to use - since I use vistax64 it means no DOS. So I got a VM running windows 2000. I compiled my kernel in it then copied the file to vista, made a disk image and then started VM. Very tedious.
So I tried to compile things with mingw - what a waste of time that was! After a lot of banging my head against the table and looking for help I finally settled for cygwin and compiled my own gcc (I still can't understand why cross tools can't be precompiled?). So this worked out much better.
The way I made my disk images was also rather stupid - I got a working binary with grub installed and used WinImage GUI to copy and paste a file into it Lot of pointing, clicking and dragging. And annoying popups! ...
Well I used this setup for a little while. Until I ran into trouble with placing my kernel to a high memory area. After lot of guess work and head scratching I found out that old grub I had did not support differing linear and virtual addresses in the binary.
Now of course I had to go and figure out how to create a GRUB disk. And I swear my next project will be a SIMPLE COPY PASTE GUI tool for creating a simple grub bootdisk containing a simple kernel binary. I had to boot into linux, spend hours trying to figure and work things out (I am thick headed sometimes) reading the tutorials. Finally I managed. I am rather proud of that! Here is a small script I used
Code: Select all
umount /dev/loop0
losetup -d /dev/loop0
mkdir /mnt/myfloppy
dd if=/dev/zero of=floppy.img bs=512 count=2880
losetup /dev/loop0 floppy.img
mkdosfs /dev/loop0
mount -t msdos /dev/loop0 /mnt/myfloppy
cd /mnt/myfloppy
mkdir grub
cp /usr/lib/grub/stage[12] /mnt/myfloppy/grub
echo "(fd0) /dev/loop0" > /mnt/myfloppy/grub/device.map
grub --device-map=/mnt/myfloppy/grub/device.map /dev/loop0
echo "title ZineOs Kernel 0.0.1" > /mnt/myfloppy/grub/menu.lst
echo "root (fd0)" >> /mnt/myfloppy/grub/menu.lst
echo "kernel /kernel.bin" >> /mnt/myfloppy/grub/menu.lst
cp /home/albert/ZineOs/kernel/bin/kernel.bin /mnt/myfloppy/
So now I am back in windows. And dicided to tweak my build flow a bit. Here's a small batch script I use to copy compiled kernel binary to a disk image and execute the VirtualPC
Code: Select all
winimage bin\floppy.img /H /Q /I bin\kernel.bin
"virtual pc" -quiet -pc zineos -launch
But now finally I almost got it perfect. I optimized both GRUP (boot directly -don't show the menu) and Virtual PC to minimize startup time. Installed colorgcc (I highly reccoment to anyone who hasn't got one yet!) I think I am almost content with the current setup. Although I will want better debugging options. I guess bochs is the way to go?
So what's your story? You got any cool/small/nifty scripts to ease your life?
I post here my makefile as well just in case someone finds it useful or is trying to solve similar problems I had. I think it's also suitable to compile the tutorial kernels.
Code: Select all
#
# Simple makefile to build ZineOS kernel
# @todo Add platform checking (allow compiling under linux)
# issue an error if compiled under windows (mingw)
# djgpp *could* also compile. IF elf support exists
#
# Is it Cygwin crosscompiling?
# else it's linux
ifeq ($(TERM),cygwin)
GCC_PREFIX = i586-elf-
else
GCC_PREFIX =
endif
# The output file
BIN = bin/kernel.bin
#Linker
LD = $(GCC_PREFIX)ld
LDFLAGS = -s -T link.ld --oformat elf32-i386 -melf_i386
# NASM assembler and files
ASM = nasm
ASMFLAGS = -f elf32
ASMMAIN = start.asm
ASMSRCS = src/$(ASMMAIN) $(filter-out src/$(ASMMAIN), $(wildcard src/*.asm))
# FreeBASIC compiler and files
FB = fbc
FBFLAGS = -nodeflibs -w pedantic
FBSRCS = $(wildcard src/*.bas)
# C/C++ compiler and files
GCC = $(GCC_PREFIX)gcc
GPP = $(GCC_PREFIX)g++
CINCS = -I./include/libc -I./include
CFLAGS = $(CINCS) -pipe -Os -g -m32 -Wall -nostdinc -nostdlib -fno-builtin -fleading-underscore -nostartfiles
GPPFLAGS = $(CFLAGS) -fno-rtti -nostdinc++ -fno-nonansi-builtins -fno-exceptions
CSRCS = $(wildcard src/*.c)
GPPSRCS = $(wildcard src/*.cpp)
# ASM Files *MUST* be first (ASMMAIN)
OBJECTS = $(patsubst src/%.asm,obj/%.asm.o,$(ASMSRCS))\
$(patsubst src/%.bas,obj/%.bas.o,$(FBSRCS)) \
$(patsubst src/%.c,obj/%.c.o,$(CSRCS)) \
$(patsubst src/%.cpp,obj/%.cpp.o,$(GPPSRCS))
# Build targets
.PHONY : all clean link
# Rule for ALL
all : $(BIN)
# Rule for CLEAN
clean :
rm -f $(OBJECTS) $(BIN)
link:
$(LD) $(LDFLAGS) -o $(BIN) $(OBJECTS)
# Compile C sources
obj/%.c.o : src/%.c
$(GCC) $(CFLAGS) -c $< -o $@
# Compile C++ sources
obj/%.cpp.o : src/%.cpp
$(GPP) $(GPPFLAGS) -c $< -o $@
# Compile FB sources
obj/%.bas.o : src/%.bas
$(FB) $(FBFLAGS) -c $< -o $@
# Compile ASM sources
obj/%.asm.o : src/%.asm
$(ASM) $(ASMFLAGS) $< -o $@
# link together and create the binary
$(BIN) : $(OBJECTS)
$(LD) $(LDFLAGS) -o $(BIN) $(OBJECTS)