2011-10-28 03:19:39 +04:00
|
|
|
# ToAruOS Primary Build Script
|
|
|
|
# This script will pull either clang (with -fcolor-diagnostics), gcc (with no extra options), or cc
|
|
|
|
CC = `util/compiler`
|
2011-03-22 07:50:50 +03:00
|
|
|
# Sometimes we just have to use GCC
|
2011-02-21 12:11:30 +03:00
|
|
|
GCC = gcc
|
2011-03-22 07:50:50 +03:00
|
|
|
# CFLAGS for core components
|
2011-03-02 02:48:39 +03:00
|
|
|
CFLAGS = -Wall -Wextra -pedantic -m32 -O0 -std=c99 -finline-functions -fno-stack-protector -nostdinc -ffreestanding -Wno-unused-function -Wno-unused-parameter -g
|
2011-03-22 07:50:50 +03:00
|
|
|
# CFLAGS for native utils
|
2011-03-22 07:51:30 +03:00
|
|
|
NATIVEFLAGS = -std=c99 -g -pedantic -Wall -Wextra -Wno-unused-parameter
|
2011-03-22 07:50:50 +03:00
|
|
|
# Linker for core
|
2011-02-11 08:55:03 +03:00
|
|
|
LD = ld -m elf_i386
|
2011-02-21 05:15:39 +03:00
|
|
|
YASM = yasm
|
2011-03-22 07:50:50 +03:00
|
|
|
# Feel free to be specific, but I'd rather you not be.
|
2011-12-15 08:15:47 +04:00
|
|
|
FILESYSTEMS = $(patsubst %.c,%.o,$(wildcard kernel/fs/*.c))
|
|
|
|
VIDEODRIVERS = $(patsubst %.c,%.o,$(wildcard kernel/video/*.c))
|
|
|
|
DEVICES = $(patsubst %.c,%.o,$(wildcard kernel/devices/*.c))
|
|
|
|
VIRTUALMEM = $(patsubst %.c,%.o,$(wildcard kernel/mem/*.c))
|
|
|
|
MISCMODS = $(patsubst %.c,%.o,$(wildcard kernel/misc/*.c))
|
|
|
|
SYSTEM = $(patsubst %.c,%.o,$(wildcard kernel/sys/*.c))
|
|
|
|
DATASTRUCTS = $(patsubst %.c,%.o,$(wildcard kernel/ds/*.c))
|
|
|
|
CPUBITS = $(patsubst %.c,%.o,$(wildcard kernel/cpu/*.c))
|
VESA mode switching support.
BIOS execution is provided through the `v8086` module, which provides
software emulation of an 8086 processor. It is not currently working
with some BIOSes and may (read: probably will be) replaced with another
emulator (x86emu comes to mind) at some point in the near future. In the
meantime, the default video mode for QEMU works with this and it's
enough to get us on real VESA instead of fake VBE. The `bochs` module
will be renamed in a future commit. Userspace programs have been
adjusted to work at bitrates other than 32 *POORLY*. If you write pixels
left-to-right, they should work fine. They only work with 24-bpp
otherwise, and then you need to be careful of what pixels you are
writing when, or you will overwrite things in other pixels.
You may pass a commandline argument like the following to set display
modes:
vid=vesa,1024,768
Or for stranger modes under QEMU or Bochs, use the bochs VBE
initializer:
vid=bochs,1280,720
Note that the address of the linear framebuffer is still found via
hackish probing instead of PCI or trusting the VBE information, so if
you have things in the wrong memory ranges (0xE0000000+), be prepared to
have them get read.
Once again, this entire commit is a massive hack. I am happy that it
worked, and I will continue to make it less hacky, but in the meantime,
this is what we've got.
Happy holidays.
2011-12-25 10:40:40 +04:00
|
|
|
REALEMU = $(patsubst %.c,%.o,$(wildcard kernel/v8086/*.c))
|
2011-12-15 08:15:47 +04:00
|
|
|
|
VESA mode switching support.
BIOS execution is provided through the `v8086` module, which provides
software emulation of an 8086 processor. It is not currently working
with some BIOSes and may (read: probably will be) replaced with another
emulator (x86emu comes to mind) at some point in the near future. In the
meantime, the default video mode for QEMU works with this and it's
enough to get us on real VESA instead of fake VBE. The `bochs` module
will be renamed in a future commit. Userspace programs have been
adjusted to work at bitrates other than 32 *POORLY*. If you write pixels
left-to-right, they should work fine. They only work with 24-bpp
otherwise, and then you need to be careful of what pixels you are
writing when, or you will overwrite things in other pixels.
You may pass a commandline argument like the following to set display
modes:
vid=vesa,1024,768
Or for stranger modes under QEMU or Bochs, use the bochs VBE
initializer:
vid=bochs,1280,720
Note that the address of the linear framebuffer is still found via
hackish probing instead of PCI or trusting the VBE information, so if
you have things in the wrong memory ranges (0xE0000000+), be prepared to
have them get read.
Once again, this entire commit is a massive hack. I am happy that it
worked, and I will continue to make it less hacky, but in the meantime,
this is what we've got.
Happy holidays.
2011-12-25 10:40:40 +04:00
|
|
|
SUBMODULES = ${MODULES} ${FILESYSTEMS} ${VIDEODRIVERS} ${DEVICES} ${VIRTUALMEM} ${MISCMODS} ${SYSTEM} ${DATASTRUCTS} ${CPUBITS} ${REALEMU}
|
2011-12-15 08:15:47 +04:00
|
|
|
|
2011-04-16 06:48:20 +04:00
|
|
|
UTILITIES = util/bin/readelf util/bin/typewriter
|
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-10-28 02:39:40 +04:00
|
|
|
BEG = util/mk-beg
|
|
|
|
END = util/mk-end
|
|
|
|
INFO = util/mk-info
|
2012-01-19 05:52:11 +04:00
|
|
|
ERRORS = 2>>/tmp/.`whoami`-build-errors || util/mk-error
|
|
|
|
ERRORSS = >>/tmp/.`whoami`-build-errors || util/mk-error
|
2011-10-28 02:39:40 +04:00
|
|
|
|
|
|
|
BEGRM = util/mk-beg-rm
|
|
|
|
ENDRM = util/mk-end-rm
|
2011-01-17 22:58:31 +03:00
|
|
|
|
2012-02-07 02:20:23 +04:00
|
|
|
EMUARGS = -kernel toaruos-kernel -m 256 -initrd toaruos-initrd -append "vid=qemu hdd" -serial stdio -vga std -hda toaruos-disk.img -k en-us
|
2011-10-28 04:37:01 +04:00
|
|
|
EMUKVM = -enable-kvm
|
|
|
|
|
2012-02-06 03:40:19 +04:00
|
|
|
.PHONY: all system clean clean-once clean-hard clean-soft clean-docs clean-bin clean-aux clean-core update-version install run docs utils
|
2011-04-11 08:08:34 +04:00
|
|
|
.SECONDARY:
|
2011-01-17 22:58:31 +03:00
|
|
|
|
2012-01-30 02:07:15 +04:00
|
|
|
all: .passed system docs utils tags
|
2012-02-06 03:40:19 +04:00
|
|
|
system: .passed toaruos-initrd toaruos-disk.img toaruos-kernel
|
2011-01-16 04:01:19 +03:00
|
|
|
|
2011-05-08 04:21:09 +04:00
|
|
|
install: system
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "CP" "Installing to /boot..."
|
2011-02-13 01:47:20 +03:00
|
|
|
@cp toaruos-kernel /boot/toaruos-kernel
|
|
|
|
@cp toaruos-initrd /boot/toaruos-initrd
|
2011-10-28 02:39:40 +04:00
|
|
|
@${END} "CP" "Installed to /boot"
|
2011-01-16 04:01:19 +03:00
|
|
|
|
2011-05-08 04:21:09 +04:00
|
|
|
run: system
|
2011-10-28 04:37:01 +04:00
|
|
|
${EMU} ${EMUARGS}
|
2011-01-29 23:52:44 +03:00
|
|
|
|
2011-05-08 04:21:09 +04:00
|
|
|
kvm: system
|
2011-10-28 04:37:01 +04:00
|
|
|
${EMU} ${EMUARGS} ${EMUKVM}
|
2011-05-08 04:21:09 +04:00
|
|
|
|
2011-04-07 01:54:57 +04:00
|
|
|
utils: ${UTILITIES}
|
|
|
|
|
2011-04-12 00:25:26 +04:00
|
|
|
.passed:
|
2011-04-12 00:13:34 +04:00
|
|
|
@util/check-reqs > /dev/null
|
2011-04-12 00:25:26 +04:00
|
|
|
@touch .passed
|
2011-04-12 00:13:34 +04:00
|
|
|
|
2011-03-18 05:45:26 +03:00
|
|
|
#################
|
|
|
|
# Documentation #
|
|
|
|
#################
|
2011-03-19 03:18:08 +03:00
|
|
|
docs: docs/core.pdf
|
2011-03-18 05:45:26 +03:00
|
|
|
|
2012-02-06 03:40:19 +04:00
|
|
|
docs/core.pdf: docs/*.tex
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "docs" "Generating documentation..."
|
|
|
|
@pdflatex -draftmode -halt-on-error -output-directory docs/ docs/core.tex > /dev/null ${ERRORS}
|
|
|
|
@makeindex -q docs/*.idx ${ERRORS}
|
|
|
|
@pdflatex -halt-on-error -output-directory docs/ docs/core.tex > /dev/null ${ERRORS}
|
|
|
|
@${END} "docs" "Generated documentation"
|
2011-03-18 05:45:26 +03:00
|
|
|
|
2011-02-19 07:22:25 +03:00
|
|
|
################
|
|
|
|
# Kernel #
|
|
|
|
################
|
2012-02-06 03:43:32 +04:00
|
|
|
toaruos-kernel: kernel/start.o kernel/link.ld kernel/main.o ${SUBMODULES} .passed
|
2011-10-29 09:33:57 +04:00
|
|
|
@${BEG} "LD" "$<"
|
2011-12-15 08:15:47 +04:00
|
|
|
@${LD} -T kernel/link.ld -o toaruos-kernel kernel/*.o ${SUBMODULES} ${ERRORS}
|
2011-10-28 02:39:40 +04:00
|
|
|
@${END} "LD" "$<"
|
|
|
|
@${INFO} "--" "Kernel is ready!"
|
2011-01-16 04:01:19 +03:00
|
|
|
|
2011-02-28 06:08:55 +03:00
|
|
|
kernel/start.o: kernel/start.s
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "yasm" "$<"
|
|
|
|
@${YASM} -f elf -o kernel/start.o kernel/start.s ${ERRORS}
|
|
|
|
@${END} "yasm" "$<"
|
2011-02-05 22:27:04 +03:00
|
|
|
|
2012-01-29 03:06:07 +04:00
|
|
|
kernel/sys/version.o: kernel/*/*.c kernel/*.c
|
|
|
|
|
2011-01-16 04:01:19 +03:00
|
|
|
%.o: %.c
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "CC" "$<"
|
|
|
|
@${CC} ${CFLAGS} -I./kernel/include -c -o $@ $< ${ERRORS}
|
|
|
|
@${END} "CC" "$<"
|
2011-01-17 22:58:31 +03:00
|
|
|
|
2011-02-19 07:22:25 +03:00
|
|
|
################
|
|
|
|
# Ram disk #
|
|
|
|
################
|
2012-02-06 03:40:19 +04:00
|
|
|
toaruos-initrd: .passed initrd/boot/kernel
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "initrd" "Generating initial RAM disk"
|
2011-03-22 08:14:54 +03:00
|
|
|
@# Get rid of the old one
|
2011-02-13 01:47:20 +03:00
|
|
|
@-rm -f toaruos-initrd
|
2011-10-28 02:39:40 +04:00
|
|
|
@${GENEXT} -d initrd -q -b 4096 toaruos-initrd ${ERRORS}
|
|
|
|
@${END} "initrd" "Generated initial RAM disk"
|
2011-10-28 04:37:01 +04:00
|
|
|
@${INFO} "--" "Ramdisk image is ready!"
|
2011-02-21 05:15:39 +03:00
|
|
|
|
|
|
|
### Ram Disk installers...
|
|
|
|
|
|
|
|
# Kernel
|
2011-03-22 08:14:54 +03:00
|
|
|
initrd/boot/kernel: toaruos-kernel
|
|
|
|
@mkdir -p initrd/boot
|
|
|
|
@cp toaruos-kernel initrd/boot/kernel
|
2011-02-21 05:15:39 +03:00
|
|
|
|
2011-10-28 04:37:01 +04:00
|
|
|
####################
|
|
|
|
# Hard Disk Images #
|
|
|
|
####################
|
|
|
|
|
|
|
|
# TODO: Install Grub to one of these by pulling newest grub builds
|
|
|
|
# from the Grub2 website.
|
|
|
|
|
|
|
|
hdd:
|
|
|
|
@mkdir hdd
|
|
|
|
|
2012-02-04 04:16:47 +04:00
|
|
|
toaruos-disk.img: hdd userspace/*.c
|
2011-10-28 04:37:01 +04:00
|
|
|
@${BEG} "hdd" "Generating a Hard Disk image..."
|
|
|
|
@-rm -f toaruos-disk.img
|
2011-11-18 05:01:14 +04:00
|
|
|
@${GENEXT} -d hdd -q -b 131072 -N 4096 toaruos-disk.img ${ERRORS}
|
2011-10-28 04:37:01 +04:00
|
|
|
@${END} "hdd" "Generated Hard Disk image"
|
|
|
|
@${INFO} "--" "Hard disk image is ready!"
|
|
|
|
|
2011-03-22 07:50:50 +03:00
|
|
|
################
|
|
|
|
# Utilities #
|
|
|
|
################
|
|
|
|
|
2011-04-16 06:48:20 +04:00
|
|
|
util/bin/%: util/%.c
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "CC" "$<"
|
|
|
|
@${CC} ${NATIVEFLAGS} -o $@ $< ${ERRORS}
|
|
|
|
@${END} "CC" "$<"
|
2011-04-07 01:50:37 +04:00
|
|
|
|
|
|
|
################
|
|
|
|
# Userspace #
|
|
|
|
################
|
|
|
|
loader/crtbegin.o: loader/crtbegin.s
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "yasm" "$<"
|
|
|
|
@${YASM} -f elf32 -o $@ $< ${ERRORS}
|
|
|
|
@${END} "yasm" "$<"
|
2011-04-07 01:50:37 +04:00
|
|
|
|
2011-11-19 00:45:19 +04:00
|
|
|
hdd/bin/%: loader/%.o loader/crtbegin.o loader/syscall.o
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEG} "LD" "$<"
|
2011-10-28 10:21:59 +04:00
|
|
|
@${LD} -T loader/link.ld -s -S -o $@ $< ${ERRORS}
|
2011-10-28 02:39:40 +04:00
|
|
|
@${END} "LD" "$<"
|
2011-04-07 01:50:37 +04:00
|
|
|
|
2012-01-27 11:38:08 +04:00
|
|
|
##############
|
|
|
|
# ctags #
|
|
|
|
##############
|
|
|
|
tags: kernel/*/*.c kernel/*.c userspace/*.c
|
|
|
|
@${BEG} "ctag" "Generating CTags..."
|
|
|
|
@ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
|
|
|
|
@${END} "ctag" "Generated CTags."
|
|
|
|
|
2011-02-21 22:29:09 +03:00
|
|
|
###############
|
|
|
|
# clean #
|
|
|
|
###############
|
2011-10-27 03:39:36 +04:00
|
|
|
|
|
|
|
clean-soft:
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEGRM} "RM" "Cleaning modules..."
|
2011-02-13 01:47:20 +03:00
|
|
|
@-rm -f kernel/*.o
|
2011-12-15 08:15:47 +04:00
|
|
|
@-rm -f ${SUBMODULES}
|
2011-10-28 02:39:40 +04:00
|
|
|
@${ENDRM} "RM" "Cleaned modules."
|
2011-10-27 03:39:36 +04:00
|
|
|
|
|
|
|
clean-docs:
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEGRM} "RM" "Cleaning documentation..."
|
2011-10-27 03:39:36 +04:00
|
|
|
@-rm -f docs/*.pdf docs/*.aux docs/*.log docs/*.out
|
|
|
|
@-rm -f docs/*.idx docs/*.ind docs/*.toc docs/*.ilg
|
2011-10-28 02:39:40 +04:00
|
|
|
@${ENDRM} "RM" "Cleaned documentation"
|
2011-10-27 03:39:36 +04:00
|
|
|
|
|
|
|
clean-bin:
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEGRM} "RM" "Cleaning native binaries..."
|
2011-10-27 03:39:36 +04:00
|
|
|
@-rm -f initrd/bin/*
|
2011-10-28 02:39:40 +04:00
|
|
|
@${ENDRM} "RM" "Cleaned native binaries"
|
2011-10-27 03:39:36 +04:00
|
|
|
|
|
|
|
clean-aux:
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEGRM} "RM" "Cleaning auxillary files..."
|
2011-10-27 03:39:36 +04:00
|
|
|
@-rm -f loader/*.o
|
2011-03-22 07:50:50 +03:00
|
|
|
@-rm -f util/bin/*
|
2011-10-28 02:39:40 +04:00
|
|
|
@${ENDRM} "RM" "Cleaned auxillary files"
|
2011-10-27 03:39:36 +04:00
|
|
|
|
|
|
|
clean-core:
|
2011-10-28 02:39:40 +04:00
|
|
|
@${BEGRM} "RM" "Cleaning final output..."
|
2011-10-27 03:39:36 +04:00
|
|
|
@-rm -f toaruos-kernel
|
|
|
|
@-rm -f toaruos-initrd
|
2011-10-28 02:39:40 +04:00
|
|
|
@${ENDRM} "RM" "Cleaned final output"
|
2011-10-27 03:39:36 +04:00
|
|
|
|
2012-01-30 02:07:15 +04:00
|
|
|
clean: clean-soft clean-core
|
2011-10-28 02:39:40 +04:00
|
|
|
@${INFO} "--" "Finished soft cleaning"
|
2011-10-28 01:36:56 +04:00
|
|
|
|
|
|
|
clean-hard: clean clean-bin clean-aux clean-docs
|
2011-10-28 02:39:40 +04:00
|
|
|
@${INFO} "--" "Finished hard cleaning"
|
2011-04-18 02:44:29 +04:00
|
|
|
|
2011-12-27 05:23:58 +04:00
|
|
|
clean-disk:
|
|
|
|
@${BEGRM} "RM" "Deleting hard disk image..."
|
|
|
|
@-rm -f toaruos-disk.img
|
|
|
|
@${ENDRM} "RM" "Deleted hard disk image"
|
|
|
|
|
2011-10-28 04:37:01 +04:00
|
|
|
clean-once:
|
|
|
|
@${BEGRM} "RM" "Cleaning one-time files..."
|
|
|
|
@-rm -f .passed
|
|
|
|
@${ENDRM} "RM" "Cleaned one-time files"
|
|
|
|
|
2011-04-18 02:44:29 +04:00
|
|
|
# vim:noexpandtab
|
|
|
|
# vim:tabstop=4
|
|
|
|
# vim:shiftwidth=4
|