Forked from SCUCCS-CST-SRA-group / LoOS
Loading
Makefile 1.26 KiB
include scripts/main.mk
PARTS = core lolibc driver
RSHELL := konsole
all: build
build: kernel.bin user
kernel: make_dir archive link
kernel.bin: kernel
	$(OBJCOPY) -O binary ${BUILD}/kernel ${BUILD}/kernel.bin
	cp ${BUILD}/kernel.bin /srv/tftp/kernel.bin
user: archive
	@$(MAKE) -f ${SRC}/user/Makefile all \
		MK=${SCRIPTS}/main.mk --no-print-directory
run: build
	clear
	make -C tools/ clean
	make -C tools/
	cp tools/kernel.img /tmp/qemu/2k1000/2kfs.img
	@echo 'scsi reset; ext4load scsi 0:0 0x9000000008000000 /boot/kernel.bin ; go 0x9000000008000000' | wl-copy
	cd /tmp/qemu; ./runqemu
debug: build
	clear
	make -C tools/ clean
	make -C tools/
	cp tools/kernel.img /tmp/qemu/2k1000/2kfs.img
	@echo 'scsi reset; ext4load scsi 0:0 0x9000000008000000 /boot/kernel.bin ; go 0x9000000008000000' | wl-copy
	$(RSHELL) -e '/opt/gdb/bin/loongarch64-unknown-linux-gnu-gdb build/kernel -ex "target remote 127.0.0.1:3456"' &
	(cd /tmp/qemu ; ./runqemu-debug)
make_dir:
	@mkdir -p ${BUILD}
${PARTS}: %:
	@$(MAKE) -f ${SCRIPTS}/archive.mk archive \
		DIR=${SRC}/$* NAME=$* MK=${SCRIPTS}/main.mk \
		--no-print-directory
archive: ${PARTS}
link: archive
	$(LD) ${LDFLAGS} -o ${BUILD}/kernel $(foreach part, ${PARTS}, $(BUILD)/${part}.a)
clean:
	rm -rf ${BUILD}
	find src/ -name '*.o' | xargs rm