toaruos/Makefile

181 lines
5.0 KiB
Makefile
Raw Normal View History

# ToAruOS Primary Build Script
2012-10-09 21:00:50 -07:00
ifeq ($(CCC_ANALYZE),yes)
2013-06-06 21:59:20 -07:00
# CC is set by CCC_ANALYZE to clang
# It is not recommended that you use a kernel built this way
2012-10-09 21:00:50 -07:00
else
2013-06-06 21:59:20 -07:00
CC = i686-pc-toaru-gcc
2012-10-09 21:00:50 -07:00
endif
# CFLAGS for core components
2014-02-26 20:58:08 -08:00
CFLAGS = -Wall -Wextra -pedantic -m32 -O0 -std=c99 -finline-functions -ffreestanding -Wno-unused-function -Wno-unused-parameter -Wstrict-prototypes -g
# Linker for core
2013-05-08 22:21:20 -07:00
LD = i686-pc-toaru-ld
YASM = yasm
2014-03-08 21:46:43 -08:00
# All of the core parts of the kernel are built directly.
# TODO: Modules would be fantastic
2013-12-13 20:50:04 -08:00
SUBMODULES = $(patsubst %.c,%.o,$(wildcard kernel/*/*.c))
2014-03-08 21:46:43 -08:00
SUBMODULES += $(patsubst %.c,%.o,$(wildcard kernel/*/*/*.c))
2013-12-13 20:50:04 -08:00
2014-03-08 21:46:43 -08:00
# We also want to rebuild when a header changes.
# This is a naive approach, but it works...
HEADERS = $(shell find kernel/include/ -type f -name '*.h')
2014-03-08 21:46:43 -08:00
# We'll call out to our userspace build script if we
# see changes to any of the userspace sources as well.
USERSPACE = $(shell find userspace/ -type f -name '*.c')
USERSPACE += $(shell find userspace/ -type f -name '*.cpp')
USERSPACE += $(shell find userspace/ -type f -name '*.h')
# Pretty output utilities.
2011-10-27 17:39:40 -05:00
BEG = util/mk-beg
END = util/mk-end
INFO = util/mk-info
2012-01-18 19:52:11 -06:00
ERRORS = 2>>/tmp/.`whoami`-build-errors || util/mk-error
ERRORSS = >>/tmp/.`whoami`-build-errors || util/mk-error
2011-10-27 17:39:40 -05:00
BEGRM = util/mk-beg-rm
ENDRM = util/mk-end-rm
2011-01-17 13:58:31 -06:00
2014-03-08 21:46:43 -08:00
# Hard disk image generation
GENEXT = genext2fs
DISK_SIZE = `util/disk_size.sh`
DD = dd conv=notrunc
# Emulator settings
EMU = qemu-system-i386
EMUARGS = -sdl -kernel toaruos-kernel -m 1024
EMUARGS += -serial stdio -vga std
EMUARGS += -hda toaruos-disk.img -k en-us -no-frame
EMUARGS += -rtc base=localtime -net nic,model=rtl8139 -net user
EMUKVM = -enable-kvm
2013-12-13 20:50:04 -08:00
.PHONY: all system clean clean-once clean-hard clean-soft clean-bin clean-aux clean-core install run
2014-03-08 21:46:43 -08:00
# Prevents Make from removing intermediary files on failure
.SECONDARY:
2011-01-17 13:58:31 -06:00
2014-03-08 21:46:43 -08:00
# Disable built-in rules
.SUFFIXES:
all: .passed system tags
2012-04-11 12:47:39 -05:00
system: .passed toaruos-disk.img toaruos-kernel
2011-01-15 20:01:19 -05:00
install: system
2011-10-27 17:39:40 -05:00
@${BEG} "CP" "Installing to /boot..."
@cp toaruos-kernel /boot/toaruos-kernel
2011-10-27 17:39:40 -05:00
@${END} "CP" "Installed to /boot"
2011-01-15 20:01:19 -05:00
# Various different quick options
run: system
${EMU} ${EMUARGS} -append "vid=qemu hdd"
kvm: system
${EMU} ${EMUARGS} ${EMUKVM} -append "vid=qemu hdd"
vga: system
${EMU} ${EMUARGS} -append "vgaterm hdd"
vga-kvm: system
${EMU} ${EMUARGS} ${EMUKVM} -append "vgaterm hdd"
term: system
${EMU} ${EMUARGS} -append "vid=qemu single hdd"
term-kvm: system
${EMU} ${EMUARGS} ${EMUKVM} -append "vid=qemu single hdd"
2012-12-02 21:43:54 -08:00
debug: system
${EMU} ${EMUARGS} -append "logtoserial=0 vid=qemu hdd"
2012-12-09 16:59:55 -08:00
debug-term: system
${EMU} ${EMUARGS} -append "logtoserial=0 vid=qemu single hdd"
2013-05-22 21:59:28 -07:00
debug-vga: system
${EMU} ${EMUARGS} -append "logtoserial=0 vgaterm hdd"
2013-11-27 19:15:28 -08:00
headless: system
${EMU} ${EMUARGS} -display none -append "vgaterm hdd"
2012-08-20 22:26:22 -07:00
run-config: system
2013-11-28 15:58:57 -08:00
util/config-parser ${EMU}
test: system
2014-02-12 13:33:19 -08:00
python2 util/run-tests.py 2>/dev/null
.passed:
@util/check-reqs > /dev/null
@touch .passed
2011-02-18 22:22:25 -06:00
################
# Kernel #
################
2012-02-05 17:43:32 -06:00
toaruos-kernel: kernel/start.o kernel/link.ld kernel/main.o ${SUBMODULES} .passed
2011-10-29 00:33:57 -05:00
@${BEG} "LD" "$<"
2014-02-26 20:58:08 -08:00
@${CC} -T kernel/link.ld -nostdlib -o toaruos-kernel kernel/*.o ${SUBMODULES} -lgcc ${ERRORS}
2011-10-27 17:39:40 -05:00
@${END} "LD" "$<"
@${INFO} "--" "Kernel is ready!"
2011-01-15 20:01:19 -05:00
2011-02-27 21:08:55 -06:00
kernel/start.o: kernel/start.s
2011-10-27 17:39:40 -05:00
@${BEG} "yasm" "$<"
@${YASM} -f elf -o kernel/start.o kernel/start.s ${ERRORS}
@${END} "yasm" "$<"
2011-02-05 13:27:04 -06:00
2012-01-28 17:06:07 -06:00
kernel/sys/version.o: kernel/*/*.c kernel/*.c
2014-03-08 21:46:43 -08:00
%.o: %.c ${HEADERS}
2011-10-27 17:39:40 -05:00
@${BEG} "CC" "$<"
@${CC} ${CFLAGS} -I./kernel/include -c -o $@ $< ${ERRORS}
@${END} "CC" "$<"
2011-01-17 13:58:31 -06:00
####################
# Hard Disk Images #
####################
.userspace-check: ${USERSPACE}
2014-02-12 13:33:19 -08:00
@cd userspace && python2 build.py
2012-12-09 19:56:56 -08:00
@touch .userspace-check
2013-02-10 01:53:23 -08:00
toaruos-disk.img: .userspace-check
@${BEG} "hdd" "Generating a Hard Disk image..."
@-rm -f toaruos-disk.img
2013-08-04 00:04:22 -07:00
@${GENEXT} -B 4096 -d hdd -U -b ${DISK_SIZE} -N 4096 toaruos-disk.img ${ERRORS}
@${END} "hdd" "Generated Hard Disk image"
@${INFO} "--" "Hard disk image is ready!"
2012-01-27 01:38:08 -06:00
##############
# ctags #
##############
tags: kernel/*/*.c kernel/*.c .userspace-check
2012-01-27 01:38:08 -06:00
@${BEG} "ctag" "Generating CTags..."
2012-05-31 18:37:17 +09:00
@ctags -R --c++-kinds=+p --fields=+iaS --extra=+q kernel userspace util
2012-01-27 01:38:08 -06:00
@${END} "ctag" "Generated CTags."
2011-02-21 13:29:09 -06:00
###############
# clean #
###############
clean-soft:
2011-10-27 17:39:40 -05:00
@${BEGRM} "RM" "Cleaning modules..."
@-rm -f kernel/*.o
@-rm -f ${SUBMODULES}
2011-10-27 17:39:40 -05:00
@${ENDRM} "RM" "Cleaned modules."
clean-bin:
2011-10-27 17:39:40 -05:00
@${BEGRM} "RM" "Cleaning native binaries..."
2012-04-11 12:47:39 -05:00
@-rm -f hdd/bin/*
2011-10-27 17:39:40 -05:00
@${ENDRM} "RM" "Cleaned native binaries"
clean-core:
2011-10-27 17:39:40 -05:00
@${BEGRM} "RM" "Cleaning final output..."
@-rm -f toaruos-kernel
2011-10-27 17:39:40 -05:00
@${ENDRM} "RM" "Cleaned final output"
clean: clean-soft clean-core
2011-10-27 17:39:40 -05:00
@${INFO} "--" "Finished soft cleaning"
2013-12-13 20:50:04 -08:00
clean-hard: clean clean-bin
2011-10-27 17:39:40 -05:00
@${INFO} "--" "Finished hard cleaning"
2011-04-17 17:44:29 -05:00
2011-12-26 19:23:58 -06:00
clean-disk:
@${BEGRM} "RM" "Deleting hard disk image..."
@-rm -f toaruos-disk.img
@${ENDRM} "RM" "Deleted hard disk image"
clean-once:
@${BEGRM} "RM" "Cleaning one-time files..."
@-rm -f .passed
@${ENDRM} "RM" "Cleaned one-time files"
2011-04-17 17:44:29 -05:00
# vim:noexpandtab
# vim:tabstop=4
# vim:shiftwidth=4