2011-02-11 08:55:03 +03:00
|
|
|
#CC = gcc
|
|
|
|
CC = clang
|
2011-02-09 23:32:49 +03:00
|
|
|
CFLAGS = -Wall -Wextra -pedantic -m32 -O0 -std=c99 -finline-functions -fno-stack-protector -nostdinc -ffreestanding -Wno-unused-function -Wno-unused-parameter
|
2011-02-11 08:55:03 +03:00
|
|
|
LD = ld -m elf_i386
|
2011-02-19 07:22:25 +03:00
|
|
|
NASM = nasm
|
2011-02-09 23:32:49 +03:00
|
|
|
ECHO = `which echo` -e
|
2011-02-13 01:47:20 +03:00
|
|
|
MODULES = $(patsubst %.c,%.o,$(wildcard kernel/core/*.c))
|
|
|
|
FILESYSTEMS = $(patsubst %.c,%.o,$(wildcard kernel/core/fs/*.c))
|
2011-02-10 09:59:06 +03:00
|
|
|
EMU = qemu
|
2011-02-10 00:33:03 +03:00
|
|
|
GENEXT = genext2fs
|
2011-02-19 07:22:25 +03:00
|
|
|
DD = dd conv=notrunc
|
2011-01-17 22:58:31 +03:00
|
|
|
|
2011-02-10 00:33:03 +03:00
|
|
|
.PHONY: all clean install run
|
2011-01-17 22:58:31 +03:00
|
|
|
|
2011-02-13 01:47:20 +03:00
|
|
|
all: toaruos-kernel toaruos-initrd
|
2011-01-16 04:01:19 +03:00
|
|
|
|
2011-02-13 01:47:20 +03:00
|
|
|
install: toaruos-kernel toaruos-initrd
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} -n "\033[34m -- Installing to /boot...\033[0m"
|
2011-02-13 01:47:20 +03:00
|
|
|
@cp toaruos-kernel /boot/toaruos-kernel
|
|
|
|
@cp toaruos-initrd /boot/toaruos-initrd
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} "\r\033[34;1m -- Kernel and ramdisk installed.\033[0m"
|
2011-01-16 04:01:19 +03:00
|
|
|
|
2011-02-13 01:47:20 +03:00
|
|
|
run: toaruos-kernel toaruos-initrd
|
|
|
|
${EMU} -kernel toaruos-kernel -initrd toaruos-initrd -serial stdio
|
2011-01-29 23:52:44 +03:00
|
|
|
|
2011-02-19 07:22:25 +03:00
|
|
|
################
|
|
|
|
# Kernel #
|
|
|
|
################
|
2011-02-13 01:47:20 +03:00
|
|
|
toaruos-kernel: kernel/start.o kernel/link.ld kernel/main.o ${MODULES} ${FILESYSTEMS}
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} -n "\033[32m LD $<\033[0m"
|
2011-02-13 01:47:20 +03:00
|
|
|
@${LD} -T kernel/link.ld -o toaruos-kernel kernel/*.o kernel/core/*.o kernel/core/fs/*.o
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} "\r\033[32;1m LD $<\033[0m"
|
2011-01-16 04:01:19 +03:00
|
|
|
|
2011-02-13 01:47:20 +03:00
|
|
|
kernel/start.o: kernel/start.asm
|
|
|
|
@${ECHO} -n "\033[32m nasm kernel/start.asm\033[0m"
|
2011-02-19 07:22:25 +03:00
|
|
|
@${NASM} -f elf -o kernel/start.o kernel/start.asm
|
2011-02-13 01:47:20 +03:00
|
|
|
@${ECHO} "\r\033[32;1m nasm kernel/start.asm\033[0m"
|
2011-02-05 22:27:04 +03:00
|
|
|
|
2011-01-16 04:01:19 +03:00
|
|
|
%.o: %.c
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} -n "\033[32m CC $<\033[0m"
|
2011-02-13 01:47:20 +03:00
|
|
|
@${CC} ${CFLAGS} -I./kernel/include -c -o $@ $<
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} "\r\033[32;1m CC $<\033[0m"
|
2011-01-17 22:58:31 +03:00
|
|
|
|
2011-02-19 07:22:25 +03:00
|
|
|
################
|
|
|
|
# Ram disk #
|
|
|
|
################
|
|
|
|
toaruos-initrd: initrd bootloader/stage1
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} -n "\033[32m initrd Generating initial RAM disk\033[0m"
|
2011-02-13 01:47:20 +03:00
|
|
|
@-rm -f toaruos-initrd
|
|
|
|
@${GENEXT} -d initrd -q -b 249 toaruos-initrd
|
2011-02-19 07:22:25 +03:00
|
|
|
@${DD} if=bootloader/stage1 of=toaruos-initrd 2>/dev/null
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} "\r\033[32;1m initrd Generated initial RAM disk image\033[0m"
|
2011-02-05 07:41:28 +03:00
|
|
|
|
2011-02-19 07:22:25 +03:00
|
|
|
################
|
|
|
|
# Bootloader #
|
|
|
|
################
|
|
|
|
bootloader/stage1: bootloader/stage1.s
|
|
|
|
@${ECHO} -n "\033[32m nasm bootloader/stage1.s\033[0m"
|
|
|
|
@${NASM} -f bin -o bootloader/stage1 bootloader/stage1.s
|
|
|
|
@${ECHO} "\r\033[32;1m nasm bootloader/stage1.s\033[0m"
|
|
|
|
|
|
|
|
|
2011-01-16 04:01:19 +03:00
|
|
|
clean:
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} -n "\033[31m RM Cleaning...\033[0m"
|
2011-02-13 01:47:20 +03:00
|
|
|
@-rm -f toaruos-kernel
|
|
|
|
@-rm -f toaruos-initrd
|
|
|
|
@-rm -f kernel/*.o
|
|
|
|
@-rm -f kernel/core/*.o
|
|
|
|
@-rm -f kernel/core/fs/*.o
|
2011-02-19 07:22:25 +03:00
|
|
|
@-rm -f bootloader/stage1
|
2011-02-10 21:59:44 +03:00
|
|
|
@${ECHO} "\r\033[31;1m RM Finished cleaning.\033[0m"
|