From cb6aa7dd9703eb3dba275905f98de682b57d3a78 Mon Sep 17 00:00:00 2001 From: aqua Date: Sun, 11 Jun 2023 23:11:25 +0300 Subject: Rework leaf makefiles to be included from top-level - remove Makefile.all --- .config | 9 ++---- Kconfig | 22 +++++++++------ Makefile | 77 +++++++++++++++++++++++++++----------------------- Makefile.all | 61 --------------------------------------- Makefile.config | 67 ------------------------------------------- config.mk | 64 +++++++++++++++++++++++++++++++++++++++++ devices/Makefile | 16 ----------- devices/build.mk | 14 +++++++++ i686/Makefile | 18 ------------ i686/build.mk | 16 +++++++++++ lib/Makefile | 38 ------------------------- lib/build.mk | 36 +++++++++++++++++++++++ mach | 21 ++++++++++++++ root.mk | 43 ++++++++++++++++++++++++++++ rules.mk | 27 ++++++++++++------ src/Makefile | 27 ------------------ src/build.mk | 29 +++++++++++++++++++ tools/kconfig/Makefile | 28 ------------------ tools/kconfig/build.mk | 26 +++++++++++++++++ 19 files changed, 326 insertions(+), 313 deletions(-) delete mode 100644 Makefile.all delete mode 100644 Makefile.config create mode 100644 config.mk delete mode 100644 devices/Makefile create mode 100755 devices/build.mk delete mode 100644 i686/Makefile create mode 100755 i686/build.mk delete mode 100644 lib/Makefile create mode 100755 lib/build.mk create mode 100755 mach create mode 100644 root.mk delete mode 100644 src/Makefile create mode 100755 src/build.mk delete mode 100644 tools/kconfig/Makefile create mode 100755 tools/kconfig/build.mk diff --git a/.config b/.config index e04ec16..23ee0fe 100644 --- a/.config +++ b/.config @@ -6,17 +6,14 @@ # # 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 # diff --git a/Kconfig b/Kconfig index d50a25e..db565cc 100644 --- a/Kconfig +++ b/Kconfig @@ -1,4 +1,18 @@ menu "Toolchain" + choice + prompt "Target architecture" + config ARCH_i686 + bool "i686" + config ARCH_mips + bool "mips" + endchoice + choice + prompt "Toolchain" + config TOOLCHAIN_i686_gcc + bool "i686-elf-gcc" + depends on ARCH_i686 + endchoice + config CFLAGS string "Additional C compiler flags" config CXXFLAGS @@ -7,14 +21,6 @@ menu "Toolchain" string "Additional linker flags" endmenu -menu "Target" - choice - prompt "Target architecture" - config ARCH_i686 - bool "i686" - endchoice -endmenu - menu "Devices" config PIC_8259 bool "PIC 8259" diff --git a/Makefile b/Makefile index 363673d..8bc5de5 100644 --- a/Makefile +++ b/Makefile @@ -9,56 +9,63 @@ MAKEFLAGS += -rR --no-print-directory ARCH := $(shell sed -nE "s/CONFIG_ARCH_(.+)=y/\1/p" .config) -.PHONY: all help info run doc clean test valgrind -all: Makefile.config - @${MAKE} -f Makefile.all +SUBDIRS := lib ${ARCH} devices src +.PHONY: help info run doc clean test valgrind help: - @echo "info: show current configuration" - @echo "all: build kernel image" @echo "run: run kernel image in qemu" @echo "test: run all tests" @echo "valgrind: run all tests in valgrind" -info: Makefile.config - @echo "- make:" - @echo " MAKE: ${MAKE}" - @echo " MAKEID: ${MAKEID}" - @echo " MAKEFLAGS: ${MAKEFLAGS}" - @${MAKE} -f Makefile.all $@ - -run: Makefile.config - @${MAKE} -f Makefile.all $@ - -doc: doxygen.config - doxygen $< +run: glitch.iso + qemu-system-i386 -accel kvm -machine pc -cdrom $^ -d cpu_reset -display gtk,zoom-to-fit=on clean: - @${MAKE} -C lib clean - @${MAKE} -C ${ARCH} clean - @${MAKE} -C devices clean - @${MAKE} -C src clean + @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk clean; done test: - @make -C ${ARCH} test.quiet - @make -C lib test.quiet - @make -C devices test.quiet - @make -C src test.quiet + @for d in ${SUBDIRS}; do make -C $$d -f ../root.mk test.quiet; done valgrind: - @make -C ${ARCH} valgrind.quiet - @make -C lib valgrind.quiet - @make -C devices valgrind.quiet - @make -C src valgrind.quiet + @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 -Makefile.config: .config ${ARCH}/toolchain.mk - @echo -e '## This is a generated file, manual edits might be lost' > Makefile.config - @echo -e '\n## .config' >> Makefile.config - @cat .config >> Makefile.config - @echo -e '\n## toolchain.mk' >> Makefile.config - @cat ${ARCH}/toolchain.mk >> Makefile.config +config.mk: .config ${ARCH}/toolchain.mk + @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 + @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 + @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 + diff --git a/Makefile.all b/Makefile.all deleted file mode 100644 index a92631f..0000000 --- a/Makefile.all +++ /dev/null @@ -1,61 +0,0 @@ -# ===================================================================== -# spdx-license-identifier: ISC -# glitch kernel binary and image generation -# ===================================================================== - -include Makefile.config - -${ARCH}_LDFLAGS += -T ${ARCH}/linker.ld - -TARGETBIN += glitch -glitch.OBJS += ${ARCH}/arch.a src/kernel.a devices/devs.a lib/libk.a - -include rules.mk - -.PHONY: run info -run: glitch.iso - @${QEMU} -cdrom $^ -d cpu_reset -display gtk,zoom-to-fit=on - -info: - @echo "- target:" - @echo " ARCH: ${ARCH}" - @echo " CC: ${${ARCH}_CC}" - @echo " CCID: ${${ARCH}_CCID}" - @echo " CFLAGS: ${${ARCH}_CFLAGS}" - @echo " CXX: ${${ARCH}_CXX}" - @echo " CXXID: ${${ARCH}_CXXID}" - @echo " CXXFLAGS: ${${ARCH}_CXXFLAGS}" - @echo " LD: ${${ARCH}_LD}" - @echo " LDID: ${${ARCH}_LDID}" - @echo " LDFLAGS: ${${ARCH}_LDFLAGS}" - @echo "- host:" - @echo " CC: ${HOST_CC}" - @echo " CFLAGS: ${HOST_CFLAGS}" - @echo " CXX: ${HOST_CXX}" - @echo " CXXFLAGS: ${HOST_CXXFLAGS}" - @echo " QEMU: ${QEMU}" - -# build targets - -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 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 - -lib/libk.a: FORCE - @${MAKE} -C lib libk.a -i686/arch.a: FORCE - @${MAKE} -C ${ARCH} arch.a -devices/devs.a: FORCE - @${MAKE} -C devices devs.a -src/kernel.a: FORCE - @${MAKE} -C src kernel.a - diff --git a/Makefile.config b/Makefile.config deleted file mode 100644 index 8ac0c3c..0000000 --- a/Makefile.config +++ /dev/null @@ -1,67 +0,0 @@ -## This is a generated file, manual edits might be lost - -## .config -# -# Automatically generated file; DO NOT EDIT. -# Main menu -# - -# -# Toolchain -# -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 -CONFIG_UART_16550=y -CONFIG_VGA_TEXT_MODE=y -CONFIG_KB_PS2=y -# end of Devices - -## toolchain.mk -ARCH=i686 - -# define compiler, linker, archiver and strip and their flags -${ARCH}_AS := i686-elf-as - -${ARCH}_CC := i686-elf-gcc -ansi -${ARCH}_CCID := $(shell ${${ARCH}_CC} --version | head -n1) -${ARCH}_CFLAGS := -Wall -Wextra -Wpedantic -Werror=shadow -Wconversion -fanalyzer \ - -D__ARCH__="${ARCH}" -ffreestanding -mgeneral-regs-only \ - $(shell echo ${CONFIG_CFLAGS}) - -${ARCH}_LD := i686-elf-ld -${ARCH}_LDID := $(shell ${${ARCH}_LD} --version | head -n1) -${ARCH}_LDFLAGS := -static -nostdlib \ - $(shell echo ${CONFIG_LDFLAGS}) - -${ARCH}_AR := i686-elf-ar -${ARCH}_ARFLAGS := -crus - -${ARCH}_STRIP := i686-elf-strip - -# define compiler and flags for test targets -HOST_CC := gcc -HOST_CFLAGS := -Wall -Wextra -Wpedantic -Werror=shadow -Wconversion \ - ${CFLAGS} -HOST_CXX := g++ -HOST_CXXFLAGS := -Wall -Wextra -Wpedantic -Werror=shadow -Wconversion -g -Og \ - $(shell pkg-config --cflags gtest gtest_main gmock) \ - ${CXXFLAGS} - -HOST_LDFLAGS := $(shell pkg-config --libs gtest gtest_main gmock) - -# emulator name and flags -QEMU := qemu-system-i386 -accel kvm -machine pc - diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..56039f0 --- /dev/null +++ b/config.mk @@ -0,0 +1,64 @@ +# +# Automatically generated file; DO NOT EDIT. +# Main menu +# + +# +# Toolchain +# +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 +CONFIG_UART_16550=y +CONFIG_VGA_TEXT_MODE=y +CONFIG_KB_PS2=y +# end of Devices + +## toolchain.mk +ARCH=i686 + +# define compiler, linker, archiver and strip and their flags +${ARCH}_AS := i686-elf-as + +${ARCH}_CC := i686-elf-gcc -ansi +${ARCH}_CCID := $(shell ${${ARCH}_CC} --version | head -n1) +${ARCH}_CFLAGS := -Wall -Wextra -Wpedantic -Werror=shadow -Wconversion -fanalyzer \ + -D__ARCH__="${ARCH}" -ffreestanding -mgeneral-regs-only \ + $(shell echo ${CONFIG_CFLAGS}) + +${ARCH}_LD := i686-elf-ld +${ARCH}_LDID := $(shell ${${ARCH}_LD} --version | head -n1) +${ARCH}_LDFLAGS := -static -nostdlib \ + $(shell echo ${CONFIG_LDFLAGS}) + +${ARCH}_AR := i686-elf-ar +${ARCH}_ARFLAGS := -crus + +${ARCH}_STRIP := i686-elf-strip + +# define compiler and flags for test targets +HOST_CC := gcc +HOST_CFLAGS := -Wall -Wextra -Wpedantic -Werror=shadow -Wconversion \ + ${CFLAGS} +HOST_CXX := g++ +HOST_CXXFLAGS := -Wall -Wextra -Wpedantic -Werror=shadow -Wconversion -g -Og \ + $(shell pkg-config --cflags gtest gtest_main gmock) \ + ${CXXFLAGS} + +HOST_LDFLAGS := $(shell pkg-config --libs gtest gtest_main gmock) + +# emulator name and flags +QEMU := qemu-system-i386 -accel kvm -machine pc + diff --git a/devices/Makefile b/devices/Makefile deleted file mode 100644 index 3222ad8..0000000 --- a/devices/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -include ../Makefile.config - -INCLUDES := -I../${ARCH} -${ARCH}_CFLAGS += ${INCLUDES} -${ARCH}_CXXFLAGS += ${INCLUDES} - -TARGETLIB += devs -devs.SRCS = pic_8259.c uart/uart_16550.c vga.c i8042.c pckbd.c mouse.c - -HOSTTARGETBIN += uart/test_uart_16550 -uart/test_uart_16550.SRCS = uart/uart_16550.c uart/unittest_uart_16550.cc - -TESTS += uart/test_uart_16550 - -include ../rules.mk - diff --git a/devices/build.mk b/devices/build.mk new file mode 100755 index 0000000..b27d945 --- /dev/null +++ b/devices/build.mk @@ -0,0 +1,14 @@ +#!../mach + +INCLUDES := -I../${ARCH} +${ARCH}_CFLAGS += ${INCLUDES} +${ARCH}_CXXFLAGS += ${INCLUDES} + +TARGETLIB += devs +devs.SRCS = pic_8259.c uart/uart_16550.c vga.c i8042.c pckbd.c mouse.c + +HOSTTARGETBIN += uart/test_uart_16550 +uart/test_uart_16550.SRCS = uart/uart_16550.c uart/unittest_uart_16550.cc + +TESTS += uart/test_uart_16550 + diff --git a/i686/Makefile b/i686/Makefile deleted file mode 100644 index 3702bef..0000000 --- a/i686/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -include ../Makefile.config - -INCLUDES := -isystem../grub -${ARCH}_CFLAGS += ${INCLUDES} -${ARCH}_CXXFLAGS += ${INCLUDES} - -TARGETLIB += arch -arch.SRCS = boot.s init.s \ - gdt.c lgdt.c \ - lidt.c isr.c - -HOSTTARGETBIN += test_gdt -test_gdt.SRCS = test_gdt.cc - -TESTS += test_gdt - -include ../rules.mk - diff --git a/i686/build.mk b/i686/build.mk new file mode 100755 index 0000000..312e553 --- /dev/null +++ b/i686/build.mk @@ -0,0 +1,16 @@ +#!../mach + +INCLUDES := -isystem../grub +${ARCH}_CFLAGS += ${INCLUDES} +${ARCH}_CXXFLAGS += ${INCLUDES} + +TARGETLIB += arch +arch.SRCS = boot.s init.s \ + gdt.c lgdt.c \ + lidt.c isr.c + +HOSTTARGETBIN += test_gdt +test_gdt.SRCS = test_gdt.cc + +TESTS += test_gdt + diff --git a/lib/Makefile b/lib/Makefile deleted file mode 100644 index 0494a85..0000000 --- a/lib/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -include ../Makefile.config - -# minimal C standard library -TARGETLIB += libk -libk.SRCS = \ - libk/endian/little.c \ - libk/stdio/printf.c libk/stdio/fprintf.c libk/stdio/vfprintf.cpp \ - libk/stdlib/memcpy.c libk/stdlib/memset.c libk/stdlib/linked_list_allocator.c \ - libk/string/itoa.c - -HOSTTARGETBIN += libk/endian/test_endian_little -libk/endian/test_endian_little.SRCS = libk/endian/test_endian_little.cc - -HOSTTARGETBIN += libk/stdlib/test_linked_list_allocator -libk/stdlib/test_linked_list_allocator.SRCS = libk/stdlib/test_linked_list_allocator.cc - -HOSTTARGETBIN += libk/stdlib/test_mem -libk/stdlib/test_mem.SRCS = libk/stdlib/test_mem.cc - -HOSTTARGETBIN += libk/string/test_string -libk/string/test_string.SRCS = libk/string/test_string.cc - -TESTS += \ - libk/endian/test_endian_little \ - libk/stdlib/test_linked_list_allocator libk/stdlib/test_mem \ - libk/string/test_string - -# blake2s hash algorithm -TARGETLIB += blake2 -blake2.SRCS = blake2/blake2s.c - -HOSTTARGETBIN += blake2/test_blake2s_selftest -blake2/test_blake2s_selftest.SRCS = blake2/test_blake2s_selftest.cc - -TESTS += blake2/test_blake2s_selftest - -include ../rules.mk - diff --git a/lib/build.mk b/lib/build.mk new file mode 100755 index 0000000..06c6006 --- /dev/null +++ b/lib/build.mk @@ -0,0 +1,36 @@ +#!../mach + +# minimal C standard library +TARGETLIB += libk +libk.SRCS = \ + libk/endian/little.c \ + libk/stdio/printf.c libk/stdio/fprintf.c libk/stdio/vfprintf.cpp \ + libk/stdlib/memcpy.c libk/stdlib/memset.c libk/stdlib/linked_list_allocator.c \ + libk/string/itoa.c + +HOSTTARGETBIN += libk/endian/test_endian_little +libk/endian/test_endian_little.SRCS = libk/endian/test_endian_little.cc + +HOSTTARGETBIN += libk/stdlib/test_linked_list_allocator +libk/stdlib/test_linked_list_allocator.SRCS = libk/stdlib/test_linked_list_allocator.cc + +HOSTTARGETBIN += libk/stdlib/test_mem +libk/stdlib/test_mem.SRCS = libk/stdlib/test_mem.cc + +HOSTTARGETBIN += libk/string/test_string +libk/string/test_string.SRCS = libk/string/test_string.cc + +TESTS += \ + libk/endian/test_endian_little \ + libk/stdlib/test_linked_list_allocator libk/stdlib/test_mem \ + libk/string/test_string + +# blake2s hash algorithm +TARGETLIB += blake2 +blake2.SRCS = blake2/blake2s.c + +HOSTTARGETBIN += blake2/test_blake2s_selftest +blake2/test_blake2s_selftest.SRCS = blake2/test_blake2s_selftest.cc + +TESTS += blake2/test_blake2s_selftest + diff --git a/mach b/mach new file mode 100755 index 0000000..76d73ea --- /dev/null +++ b/mach @@ -0,0 +1,21 @@ +#!/bin/sh +# ===================================================================== +# filename: mach +# description: make wrapper used to run build.mk +# To use, add the relative path to this script as a +# shebang in build.mk and make it executable. +# spdx-license-identifier: ISC +# ===================================================================== + +if [[ $1 != "./build.mk" ]] +then + echo "Run from subdir" + exit 1 +fi + +# remove ./build.mk from args +ARGS=${@:2} +# root.mk should be next to this script +ROOT=`dirname $0` + +make --silent -f ${ROOT}/root.mk -C ${PWD} ${ARGS} diff --git a/root.mk b/root.mk new file mode 100644 index 0000000..b42e078 --- /dev/null +++ b/root.mk @@ -0,0 +1,43 @@ +# glitch root makefile +# usage: make -C -f + +# location of root makefile +ROOTDIR := $(dir $(abspath $(lastword ${MAKEFILE_LIST}))) +# include config and toolchain +include $(join ${ROOTDIR},config.mk) + +help: + @echo "info: show current configuration" + @echo "all: build kernel image" + @echo "run: run kernel image in qemu" + @echo "test: run all tests" + @echo "valgrind: run all tests in valgrind" + +info: + @echo "- target:" + @echo " ARCH: ${ARCH}" + @echo " CC: ${${ARCH}_CC}" + @echo " CCID: ${${ARCH}_CCID}" + @echo " CFLAGS: ${${ARCH}_CFLAGS}" + @echo " LD: ${${ARCH}_LD}" + @echo " LDID: ${${ARCH}_LDID}" + @echo " LDFLAGS: ${${ARCH}_LDFLAGS}" + @echo "- host:" + @echo " CC: ${HOST_CC}" + @echo " CFLAGS: ${HOST_CFLAGS}" + @echo " CXX: ${HOST_CXX}" + @echo " CXXFLAGS: ${HOST_CXXFLAGS}" + @echo " QEMU: ${QEMU}" + +# for auto-completion purposes +list-targets: + +# include build from current dir +include build.mk + +SUBDIR := $(dir $(abspath $(lastword ${MAKEFILE_LIST}))) +COMPONENT := $(lastword $(subst /, ,${SUBDIR})) + +# generate build rules +include $(join ${ROOTDIR},rules.mk) + diff --git a/rules.mk b/rules.mk index 8adbdbe..f8ad6d9 100644 --- a/rules.mk +++ b/rules.mk @@ -1,3 +1,7 @@ +# generate build rules from variables +# This makefile defines the following targets: +# - all: default goal, build all default targets + # generate objects from sources # arg 1: target.SRCS # arg 2: object suffix prefix @@ -41,14 +45,19 @@ $(foreach T,${HOSTTARGETBIN},\ $(eval DEFAULT_TARGETS += $T) \ ) -debug: - @echo "TARGETBIN ${TARGETBIN}" - @echo "TARGETLIB ${TARGETLIB}" - @echo "HOSTTARGETBIN ${HOSTTARGETBIN}" - @echo "HOSTTARGETLIB ${HOSTTARGETLIB}" - @echo "DEFAULT_TARGETS ${DEFAULT_TARGETS}" - @echo "TESTS ${TESTS}" - @echo " DEPS ${TESTS.DEPS}" +list-targets: + @echo TARGETBIN + @echo ${TARGETBIN} | tr ' ' '\n' | xargs -n1 echo " " + @echo TARGETLIB + @echo ${TARGETLIB} | tr ' ' '\n' | xargs -n1 echo " " + @echo HOSTTARGETBIN + @echo ${HOSTTARGETBIN} | tr ' ' '\n' | xargs -n1 echo " " + @echo HOSTTARGETLIB + @echo ${HOSTTARGETLIB} | tr ' ' '\n' | xargs -n1 echo " " + @echo DEFAULT_TARGETS + @echo ${DEFAULT_TARGETS} | tr ' ' '\n' | xargs -n1 echo " " + @echo TESTS + @echo ${TESTS} | tr ' ' '\n' | xargs -n1 echo " " %.info: @echo "Target: $(basename $@)" @@ -58,7 +67,7 @@ debug: @echo " DEPS: ${$(basename $@).DEPS}" all: ${DEFAULT_TARGETS} - @echo " -> Built ${DEFAULT_TARGETS}" + @echo " -> Built all in ${COMPONENT}" # extra flags ${ARCH}_CFLAGS += -I../lib/libk \ diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 0d02c5d..0000000 --- a/src/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include ../Makefile.config - -INCLUDES := -isystem../grub -I../${ARCH} -I../devices -${ARCH}_CFLAGS += ${INCLUDES} -${ARCH}_CXXFLAGS += ${INCLUDES} - -TARGETLIB += kernel -kernel.SRCS := multiboot2.c mmap.c kernel.cpp mem/vmm.c - -HOSTTARGETBIN += sched/test_taskqueue -sched/test_taskqueue.SRCS = sched/test_taskqueue.cc - -HOSTTARGETBIN += sched/test_roundrobin -sched/test_roundrobin.SRCS = sched/test_roundrobin.cc - -TESTS += \ - sched/test_taskqueue sched/test_roundrobin - -include ../rules.mk - -kernel.c: conf.h -conf.h: conf.h.in - @echo ' GEN $@' - @cp conf.h.in conf.h - @sed -i 's/@VERSION@/$(shell git describe)/' conf.h - @sed -i 's/@CC@/${${ARCH}_CCID}/' conf.h - diff --git a/src/build.mk b/src/build.mk new file mode 100755 index 0000000..bdc1e3b --- /dev/null +++ b/src/build.mk @@ -0,0 +1,29 @@ +#!../mach + +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 + +HOSTTARGETBIN += sched/test_taskqueue +sched/test_taskqueue.SRCS = sched/test_taskqueue.cc + +HOSTTARGETBIN += sched/test_roundrobin +sched/test_roundrobin.SRCS = sched/test_roundrobin.cc + +TESTS += \ + sched/test_taskqueue sched/test_roundrobin + +kernel.c: conf.h +conf.h: conf.h.in + @echo ' GEN $@' + @cp conf.h.in conf.h + @sed -i 's/@VERSION@/$(shell git describe)/' conf.h + @sed -i 's/@CC@/${${ARCH}_CCID}/' conf.h + diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile deleted file mode 100644 index b7dd104..0000000 --- a/tools/kconfig/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -include ../../Makefile.config - -HOSTTARGETBIN += conf mconf - -lxdiag_srcs := \ - lxdialog/checklist.c lxdialog/inputbox.c lxdialog/menubox.c lxdialog/textbox.c lxdialog/util.c lxdialog/yesno.c - -parser_srcs := \ - confdata.c expr.c menu.c preprocess.c symbol.c util.c \ - lex.yy.c parser.tab.c - -conf.SRCS := ${parser_srcs} conf.c - -mconf.SRCS := ${parser_srcs} ${lxdiag_srcs} mconf.c - -HOST_CFLAGS := -D_GNU_SOURCE $(shell pkg-config --cflags ncursesw) -HOST_LDFLAGS := $(shell pkg-config --libs ncursesw) - -include ../../rules.mk - -%.tab.c: %.y - bison --header --debug $< - -lex.yy.c: lexer.l parser.tab.c - flex $< - -clean: clean.base - @rm -f parser.tab.h parser.tab.c lex.yy.c diff --git a/tools/kconfig/build.mk b/tools/kconfig/build.mk new file mode 100755 index 0000000..060dd99 --- /dev/null +++ b/tools/kconfig/build.mk @@ -0,0 +1,26 @@ +#!../../mach + +HOSTTARGETBIN += conf mconf + +lxdiag_srcs := \ + lxdialog/checklist.c lxdialog/inputbox.c lxdialog/menubox.c lxdialog/textbox.c lxdialog/util.c lxdialog/yesno.c + +parser_srcs := \ + confdata.c expr.c menu.c preprocess.c symbol.c util.c \ + lex.yy.c parser.tab.c + +conf.SRCS := ${parser_srcs} conf.c + +mconf.SRCS := ${parser_srcs} ${lxdiag_srcs} mconf.c + +HOST_CFLAGS := -D_GNU_SOURCE $(shell pkg-config --cflags ncursesw) +HOST_LDFLAGS := $(shell pkg-config --libs ncursesw) + +%.tab.c: %.y + bison --header --debug $< + +lex.yy.c: lexer.l parser.tab.c + flex $< + +clean: clean.base + @rm -f parser.tab.h parser.tab.c lex.yy.c -- cgit v1.2.1