X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1025235c72c31f7fa7b648c0e32ddcaa68a8f66a..a35bb9648f1a9eddb071a50ff6a4dcdb8f379f24:/lunaix-os/makefile diff --git a/lunaix-os/makefile b/lunaix-os/makefile index 4e13211..5b339d6 100644 --- a/lunaix-os/makefile +++ b/lunaix-os/makefile @@ -1,14 +1,15 @@ 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 +DEPS := $(CC) $(LD) $(AR) CMDLINE ?= console=/dev/ttyFB0 @@ -16,9 +17,8 @@ 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 $@ .... " @@ -28,95 +28,50 @@ $(DEPS): echo "failed" && exit 1;\ fi -define builder_data - .builder/sources.list - .builder/headers.list - .builder/includes.list -endef - -all_lconfigs = $(shell find . -name "LConfig") - $(kbuild_dir): @mkdir -p $(kbin_dir) @mkdir -p $(os_img_dir) - @mkdir -p $(os_img_dir)/boot - @mkdir -p $(os_img_dir)/boot/grub @mkdir -p $(os_img_dir)/usr -.builder/configs.h: $(all_lconfigs) - @echo restarting configuration... - @echo - @./scripts/build-tools/luna_build.py --config --lconfig-file LConfig -o $(@D) - -.builder/%.list: .builder/configs.h - @./scripts/build-tools/luna_build.py LBuild --lconfig-file LConfig -o $(@D) - .PHONY: kernel export BUILD_DIR=$(kbin_dir) export BUILD_NAME=$(kbin) -kernel: $(builder_data) +kernel: $(lbuild_mkinc) $(call status,TASK,$(notdir $@)) + @$(MAKE) $(MKFLAGS) -I $(mkinc_dir) -f kernel.mk all -.PHONY: image -export KCMD=$(CMDLINE) -export _OS_NAME=$(OS_NAME) -image: usr/build kernel - $(call status,TASK,$(notdir $@)) - @./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)" +.PHONY: rootfs all clean-user clean tool -usr/build: user +tool: + $(call status,TASK,$@) + @$(MAKE) $(MKFLAGS) -C scripts all -I $(mkinc_dir) -check: $(DEPS) check-cc scripts/grub/GRUB_TEMPLATE +.NOTPARALLEL: +export KCMD=$(CMDLINE) +export LBUILD ARCH MODE +all: $(kbuild_dir) tool kernel -prepare: check $(os_img_dir) +rootfs: usr/build + $(call status,TASK,$(notdir $@)) + @./scripts/mkrootfs -export BUILD_MODE=release -bootable: $(kbuild_dir) image +usr/build: user -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 +clean-user: + @$(MAKE) -C usr clean -I $(mkinc_dir) clean: - @$(MAKE) -C usr clean -I $(mkinc_dir) + @$(MAKE) $(MKFLAGS) -C usr clean -I $(mkinc_dir) + @$(MAKE) $(MKFLAGS) -C scripts clean -I $(mkinc_dir) @$(MAKE) -f kernel.mk clean -I $(mkinc_dir) + @rm -rf $(kbuild_dir) || exit 1 - @rm -f .builder/*.list || exit 1 - -run: all - @qemu-system-i386 $(call get_qemu_options,$(kimg)) - @sleep 1 - @telnet 127.0.0.1 $(QEMU_MON_PORT) - -debug-qemu: all-debug - @objcopy --only-keep-debug $(kbin) $(kbuild_dir)/kernel.dbg - @qemu-system-i386 $(call get_qemu_options,$(kimg)) - @sleep 1 - @QMPORT=$(QEMU_MON_PORT) gdb $(kbin) -ex "target remote localhost:1234" - -debug-qemu-vscode: all-debug - @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 .builder || exit 1