X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/78cd005fac540973751b5a108c37a715bc64b5a2..270869139db617e29a35bb9ded41087bb702f9ac:/lunaix-os/makefile diff --git a/lunaix-os/makefile b/lunaix-os/makefile index 779a38e..f53d62e 100644 --- a/lunaix-os/makefile +++ b/lunaix-os/makefile @@ -1,22 +1,24 @@ mkinc_dir := $(CURDIR)/makeinc -include $(mkinc_dir)/os.mkinc include $(mkinc_dir)/toolchain.mkinc -include $(mkinc_dir)/qemu.mkinc include $(mkinc_dir)/utils.mkinc +include $(mkinc_dir)/lunabuild.mkinc +QEMU_HMP ?= 45454 ARCH ?= i386 +MODE ?= debug export ARCH DEPS := $(CC) $(LD) $(AR) xorriso grub-mkrescue +CMDLINE ?= console=/dev/ttyFB0 + kbuild_dir := build kbin_dir := $(kbuild_dir)/bin os_img_dir := $(kbuild_dir)/img -os_build_tag := $(OS_NAME)_$(ARCH)_$(OS_VER) kbin := $(kbin_dir)/kernel.bin -kimg := $(kbuild_dir)/$(os_build_tag).iso +kimg := $(kbuild_dir)/lunaix.iso $(DEPS): @echo -n "checking $@ .... " @@ -26,10 +28,6 @@ $(DEPS): echo "failed" && exit 1;\ fi -check-cc: - @echo -n "checking target i686-elf.... " - @test "`i686-elf-gcc -dumpmachine`" = "i686-elf" && echo ok || (echo "failed" && exit 1) - $(kbuild_dir): @mkdir -p $(kbin_dir) @mkdir -p $(os_img_dir) @@ -40,67 +38,37 @@ $(kbuild_dir): .PHONY: kernel export BUILD_DIR=$(kbin_dir) export BUILD_NAME=$(kbin) -kernel: +kernel: $(lbuild_mkinc) $(call status,TASK,$(notdir $@)) + @$(MAKE) $(MKFLAGS) -I $(mkinc_dir) -f kernel.mk all +.NOTPARALLEL: .PHONY: image -image: usr/build kernel +export KCMD=$(CMDLINE) +export LBUILD ARCH MODE +image: $(kbuild_dir) kernel usr/build $(call status,TASK,$(notdir $@)) - @./config-grub.sh ${OS_NAME} $(os_img_dir)/boot/grub/grub.cfg + $(call status,PACK,$(kimg)) + + @./scripts/grub/config-grub.sh $(os_img_dir)/boot/grub/grub.cfg @cp -r usr/build/* $(os_img_dir)/usr @cp -r $(kbin_dir)/* $(os_img_dir)/boot - @grub-mkrescue -o $(kimg) $(os_img_dir) -- -volid "$(OS_ID) $(OS_VER)" -system_id "$(OS_NAME)" + @grub-mkrescue -o $(kimg) $(os_img_dir)\ + -- -volid "LUNA" -system_id "Lunaix" \ + -report_about FAILURE -abort_on FAILURE usr/build: user -check: $(DEPS) check-cc GRUB_TEMPLATE - -prepare: check $(os_img_dir) - -export BUILD_MODE=release -bootable: $(kbuild_dir) image - -export BUILD_MODE=debug -bootable-debug: $(kbuild_dir) image +prepare: $(os_img_dir) +export LBUILD ARCH MODE user: - $(call status,$@) + $(call status,TASK,$@) @$(MAKE) $(MKFLAGS) -C usr all -I $(mkinc_dir) -all: bootable - -instable: CFLAGS := -g -std=gnu99 -ffreestanding $(O) $(W) $(ARCH_OPT) -D__LUNAIXOS_DEBUG__ -instable: all - -all-debug: bootable-debug - @echo "Dumping the disassembled kernel code to $(kbuild_dir)/kdump.txt" - clean: - @rm -rf $(kbuild_dir) || exit 1 @$(MAKE) -C usr clean -I $(mkinc_dir) @$(MAKE) -f kernel.mk clean -I $(mkinc_dir) - -run: $(BUILD_DIR)/$(OS_ISO) - @qemu-system-i386 $(QEMU_OPTIONS) - @sleep 1 - @telnet 127.0.0.1 $(QEMU_MON_PORT) - -debug-qemu: all-debug - @i686-elf-objcopy --only-keep-debug $(kbin) $(kbuild_dir)/kernel.dbg - @qemu-system-i386 $(call get_qemu_options,$(kimg)) - @sleep 1 - @QMPORT=$(QEMU_MON_PORT) gdb -s $(kbuild_dir)/kernel.dbg -ex "target remote localhost:1234" - -debug-qemu-vscode: all-debug - @i686-elf-objcopy --only-keep-debug $(kbin) $(kbuild_dir)/kernel.dbg - @qemu-system-i386 $(call get_qemu_options,$(kimg)) - @sleep 0.5 - @telnet 127.0.0.1 $(QEMU_MON_PORT) - -debug-bochs: all-debug - @bochs -q -f bochs.cfg - -debug-metal: - @printf "@cmc" > $(PORT) - @gdb -s $(kbuild_dir)/kernel.dbg -ex "target remote $(PORT)" \ No newline at end of file + @rm -rf $(kbuild_dir) || exit 1 + @rm -rf .builder || exit 1