aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--config.mk9
-rwxr-xr-xdevices/mk (renamed from devices/build.mk)0
-rwxr-xr-xi686/mk (renamed from i686/build.mk)0
-rwxr-xr-xlib/mk (renamed from lib/build.mk)0
-rwxr-xr-xmach11
-rwxr-xr-x[-rw-r--r--]mk (renamed from Makefile)72
-rw-r--r--root.mk2
-rw-r--r--rules.mk11
-rwxr-xr-xsrc/mk (renamed from src/build.mk)4
-rwxr-xr-xtools/kconfig/mk (renamed from tools/kconfig/build.mk)0
11 files changed, 50 insertions, 63 deletions
diff --git a/.gitignore b/.gitignore
index ff952c7..6009cfd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,7 @@ src/conf.h
.config.old
doc
include/
+
+# test files
+test_*
+!test_*.cc
diff --git a/config.mk b/config.mk
index 56039f0..36fc32f 100644
--- a/config.mk
+++ b/config.mk
@@ -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
diff --git a/i686/build.mk b/i686/mk
index 312e553..312e553 100755
--- a/i686/build.mk
+++ b/i686/mk
diff --git a/lib/build.mk b/lib/mk
index 06c6006..06c6006 100755
--- a/lib/build.mk
+++ b/lib/mk
diff --git a/mach b/mach
index 76d73ea..fbc10d7 100755
--- a/mach
+++ b/mach
@@ -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`
diff --git a/Makefile b/mk
index 8bc5de5..f4de64b 100644..100755
--- a/Makefile
+++ b/mk
@@ -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
diff --git a/root.mk b/root.mk
index b42e078..87ac276 100644
--- a/root.mk
+++ b/root.mk
@@ -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}))
diff --git a/rules.mk b/rules.mk
index 3f750f8..5407a61 100644
--- a/rules.mk
+++ b/rules.mk
@@ -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)"
diff --git a/src/build.mk b/src/mk
index bdc1e3b..84a735f 100755
--- a/src/build.mk
+++ b/src/mk
@@ -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