diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | config.mk | 9 | ||||
-rwxr-xr-x | devices/mk (renamed from devices/build.mk) | 0 | ||||
-rwxr-xr-x | i686/mk (renamed from i686/build.mk) | 0 | ||||
-rwxr-xr-x | lib/mk (renamed from lib/build.mk) | 0 | ||||
-rwxr-xr-x | mach | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | mk (renamed from Makefile) | 72 | ||||
-rw-r--r-- | root.mk | 2 | ||||
-rw-r--r-- | rules.mk | 11 | ||||
-rwxr-xr-x | src/mk (renamed from src/build.mk) | 4 | ||||
-rwxr-xr-x | tools/kconfig/mk (renamed from tools/kconfig/build.mk) | 0 |
11 files changed, 50 insertions, 63 deletions
@@ -8,3 +8,7 @@ src/conf.h .config.old doc include/ + +# test files +test_* +!test_*.cc @@ -6,18 +6,15 @@ # # Toolchain # +CONFIG_ARCH_i686=y +# CONFIG_ARCH_mips is not set +CONFIG_TOOLCHAIN_i686_gcc=y CONFIG_CFLAGS="-g -Og" CONFIG_CXXFLAGS="-g -Og" CONFIG_LDFLAGS="" # end of Toolchain # -# Target -# -CONFIG_ARCH_i686=y -# end of Target - -# # Devices # CONFIG_PIC_8259=y diff --git a/devices/build.mk b/devices/mk index b27d945..b27d945 100755 --- a/devices/build.mk +++ b/devices/mk @@ -1,20 +1,21 @@ #!/bin/sh # ===================================================================== # filename: mach -# description: make wrapper used to run build.mk +# description: make wrapper used to run mk files # To use, add the relative path to this script as a -# shebang in build.mk and make it executable. +# shebang in mk and make it executable. # spdx-license-identifier: ISC # ===================================================================== -if [[ $1 != "./build.mk" ]] +if [[ $1 != "./mk" ]] then - echo "Run from subdir" + echo "Usage: $0 ./mk; argument passed: $1" exit 1 fi -# remove ./build.mk from args +# remove ./mk from args ARGS=${@:2} + # root.mk should be next to this script ROOT=`dirname $0` @@ -1,71 +1,57 @@ -# ===================================================================== -# spdx-license-identifier: ISC -# glitch top-level makefile -# ===================================================================== +#!./mach -MAKE := make -MAKEID := $(shell ${MAKE} --version | head -n1) -MAKEFLAGS += -rR --no-print-directory +SUBDIRS := lib ${ARCH} devices src -ARCH := $(shell sed -nE "s/CONFIG_ARCH_(.+)=y/\1/p" .config) +${ARCH}_LDFLAGS += -T ${ROOTDIR}${ARCH}/linker.ld -SUBDIRS := lib ${ARCH} devices src +TARGETBIN += glitch +glitch.OBJS += ${ARCH}/arch.a src/kernel.a devices/devs.a lib/libk.a -.PHONY: help info run doc clean test valgrind -help: - @echo "run: run kernel image in qemu" - @echo "test: run all tests" - @echo "valgrind: run all tests in valgrind" +lib/libk.a: + @${MAKE} -C lib -f ../root.mk libk.a +i686/arch.a: + @${MAKE} -C ${ARCH} -f ../root.mk arch.a +devices/devs.a: + @${MAKE} -C devices -f ../root.mk devs.a +src/kernel.a: + @${MAKE} -C src -f ../root.mk kernel.a +kconfig: + @${MAKE} -C tools/kconfig -f ../../root.mk run: glitch.iso qemu-system-i386 -accel kvm -machine pc -cdrom $^ -d cpu_reset -display gtk,zoom-to-fit=on -clean: - @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk clean; done - -test: - @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk test.quiet; done - -valgrind: - @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk valgrind.quiet; done - # configure targets -kconfig: - @make -C tools/kconfig -f ../../root.mk - .config: Kconfig @alldefconfig config.mk: .config ${ARCH}/toolchain.mk - @cat .config >> $@ + @cat .config > $@ @echo -e '\n## toolchain.mk' >> $@ @cat ${ARCH}/toolchain.mk >> $@ -# build targets -lib/libk.a: - @${MAKE} -C lib -f ../root.mk libk.a -i686/arch.a: - @${MAKE} -C ${ARCH} -f ../root.mk arch.a -devices/devs.a: - @${MAKE} -C devices -f ../root.mk devs.a -src/kernel.a: - @${MAKE} -C src -f ../root.mk kernel.a - -src/glitch.elf: lib/libk.a i686/arch.a devices/devs.a src/kernel.a - @${MAKE} -C src -f ../root.mk glitch.elf - # iso image -glitch.iso: src/glitch.elf grub/grub.cfg - @grub-file --is-x86-multiboot2 src/glitch.elf +glitch.iso: glitch.elf grub/grub.cfg + @grub-file --is-x86-multiboot2 glitch.elf @mkdir -p isodir/boot/grub @mkdir -p isodir/boot/glitch @grub-script-check grub/grub.cfg @cp grub/grub.cfg isodir/boot/grub/grub.cfg - @cp src/glitch.elf isodir/boot/glitch/glitch.elf + @cp glitch.elf isodir/boot/glitch/glitch.elf @i686-elf-strip isodir/boot/glitch/glitch.elf @rm -f isodir/boot/glitch/checksums @sha512sum isodir/boot/glitch/* > isodir/boot/glitch/checksums @sed -i s/isodir// isodir/boot/glitch/checksums @grub-mkrescue -o glitch.iso isodir +clean: clean_subdirs +clean_subdirs: + @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk clean; done + +test: test_subdirs +test_subdirs: + @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk test.quiet; done +valgrind: valgrind_subdirs +valgrind_subdirs: + @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk valgrind.quiet; done @@ -33,7 +33,7 @@ info: list-targets: # include build from current dir -include build.mk +include mk SUBDIR := $(dir $(abspath $(lastword ${MAKEFILE_LIST}))) COMPONENT := $(lastword $(subst /, ,${SUBDIR})) @@ -1,3 +1,6 @@ +# variables +VCS_ROOT = $(shell git rev-parse --show-toplevel) + # generate build rules from variables # This makefile defines the following targets: # - all: default goal, build all default targets @@ -118,19 +121,19 @@ build/%.o: %.cc .PHONY: test test.quiet valgrind valgrind.quiet clean.base FORCE test: ${TESTS} @echo " -> Running tests in $(shell pwd | xargs basename)" - @../scripts/test_runner.py --verbose ${TESTS} + @[[ -z "${TESTS}" ]] || ${VCS_ROOT}/scripts/test_runner.py --verbose ${TESTS} test.quiet: ${TESTS} @echo " -> Running tests in $(shell pwd | xargs basename)" - @../scripts/test_runner.py ${TESTS} + @[[ -z "${TESTS}" ]] || ${VCS_ROOT}/scripts/test_runner.py ${TESTS} valgrind: ${TESTS} @echo " -> Running valgrind on tests in $(shell pwd | xargs basename)" - @../scripts/test_runner.py --verbose --valgrind ${TESTS} + @[[ -z "${TESTS}" ]] || ${VCS_ROOT}/scripts/test_runner.py --verbose --valgrind ${TESTS} valgrind.quiet: ${TESTS} @echo " -> Running valgrind on tests in $(shell pwd | xargs basename)" - @../scripts/test_runner.py --valgrind ${TESTS} + @[[ -z "${TESTS}" ]] || ${VCS_ROOT}/scripts/test_runner.py --valgrind ${TESTS} clean: FORCE @echo " -> Cleaning $(shell pwd | xargs basename)" @@ -3,10 +3,6 @@ INCLUDES := -isystem${ROOTDIR}grub -I${ROOTDIR}${ARCH} -I${ROOTDIR}devices ${ARCH}_CFLAGS += ${INCLUDES} ${ARCH}_CXXFLAGS += ${INCLUDES} -${ARCH}_LDFLAGS += -T ${ROOTDIR}${ARCH}/linker.ld - -TARGETBIN += glitch -glitch.OBJS += ${ROOTDIR}${ARCH}/arch.a kernel.a ${ROOTDIR}devices/devs.a ${ROOTDIR}lib/libk.a TARGETLIB += kernel kernel.SRCS := multiboot2.c mmap.c kernel.cpp mem/vmm.c diff --git a/tools/kconfig/build.mk b/tools/kconfig/mk index a11a6d4..a11a6d4 100755 --- a/tools/kconfig/build.mk +++ b/tools/kconfig/mk |