StupidOS/Makefile

124 lines
2.8 KiB
Makefile
Raw Permalink Normal View History

2024-03-20 09:48:47 +00:00
.EXPORT_ALL_VARIABLES:
TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SYSROOTDIR := $(TOPDIR)/sysroot
TOOLSDIR := $(TOPDIR)/tools
2024-03-26 06:48:32 +00:00
BINDIR = /bin
LIBDIR = /usr/lib
INCDIR = /usr/include
ASMDIR = /usr/asm
AS = fasm
2024-05-02 11:34:27 +00:00
CC ?= gcc
RM = rm -f
2024-03-20 09:48:47 +00:00
MK_BUGREPORT := \"https://git.cute.engineering/d0p1/StupidOS/issues\"
MK_COMMIT := \"$(shell git rev-parse --short HEAD)\"
2024-06-10 06:43:35 +00:00
MK_PACKAGE := \"StupidOS\"
2024-03-20 09:48:47 +00:00
2024-06-10 06:43:35 +00:00
CFLAGS = -DMK_COMMIT="$(MK_COMMIT)" \
-DMK_BUGREPORT="$(MK_BUGREPORT)" \
-DMK_PACKAGE="$(MK_PACKAGE)" \
-I$(TOPDIR)include
2024-05-02 11:34:27 +00:00
LDFLAGS =
2024-05-28 11:50:12 +00:00
2024-05-02 11:34:27 +00:00
2024-05-03 10:00:17 +00:00
QEMU_COMMON = \
-rtc base=localtime \
2024-07-08 07:03:39 +00:00
-vga cirrus \
2024-07-15 16:07:17 +00:00
-serial stdio \
-monitor telnet::4545,server,nowait \
-net nic,model=ne2k_isa \
-machine isapc
2024-05-03 10:00:17 +00:00
2024-07-08 07:03:39 +00:00
SUBDIRS := external tools include boot kernel modules lib bin
2024-03-20 09:48:47 +00:00
2024-05-28 04:54:10 +00:00
TARGET = stupid.tar.gz floppy1440.img floppy2880.img
2024-03-20 09:48:47 +00:00
ifneq ($(OS),Windows_NT)
EXEXT =
TARGET += stupid.iso stupid.hdd
else
EXEXT = .exe
endif
.PHONY: all
all: $(TARGET)
GOAL:=install
clean: GOAL:=clean
.PHONY: $(SUBDIRS)
$(SUBDIRS):
@echo "📁 $@"
@DESTDIR=$(SYSROOTDIR) $(MAKE) -C $@ $(GOAL)
2024-03-20 09:48:47 +00:00
.PHONY: stupid.iso
stupid.iso: $(SUBDIRS)
$(TOPDIR)/tools/create-iso $@ sysroot
.PHONY: stupid.hdd
stupid.hdd: $(SUBDIRS)
2024-05-28 04:54:10 +00:00
dd if=/dev/zero of=$@ bs=1M count=0 seek=64
mformat -L 12 -i $@
# mcopy -i $@ boot/loader/stpdldr.sys ::/STPDLDR.SYS
# mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS
2024-03-20 09:48:47 +00:00
.PHONY: stupid.tar.gz
stupid.tar.gz: $(SUBDIRS)
tar -czvf $@ sysroot
2024-04-04 10:13:02 +00:00
.PHONY: floppy1440.img
floppy1440.img: $(SUBDIRS)
2024-03-20 09:48:47 +00:00
dd if=/dev/zero of=$@ bs=512 count=1440
mformat -C -f 1440 -i $@
2024-04-04 10:13:02 +00:00
dd if=boot/bootsect/boot_floppy1440.bin of=$@ conv=notrunc
mcopy -i $@ boot/loader/stpdldr.sys ::/STPDLDR.SYS
2024-03-20 09:48:47 +00:00
mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS
2024-04-04 10:13:02 +00:00
.PHONY: floppy2880.img
floppy2880.img: $(SUBDIRS)
dd if=/dev/zero of=$@ bs=512 count=2880
mformat -C -f 2880 -i $@
dd if=boot/bootsect/boot_floppy2880.bin of=$@ conv=notrunc
mcopy -i $@ boot/loader/stpdldr.sys ::/STPDLDR.SYS
mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS
2024-03-26 09:04:06 +00:00
OVMF32.fd:
wget 'https://retrage.github.io/edk2-nightly/bin/DEBUGIa32_OVMF.fd' -O $@
2024-03-20 09:48:47 +00:00
.PHONY: run
run: all
qemu-system-i386 \
2024-05-03 10:00:17 +00:00
$(QEMU_COMMON) \
2024-04-04 10:13:02 +00:00
-drive file=floppy1440.img,if=none,format=raw,id=boot \
2024-03-20 09:48:47 +00:00
-drive file=fat:rw:./sysroot,if=none,id=hdd \
-device floppy,drive=boot \
2024-05-28 11:50:12 +00:00
-global isa-fdc.bootindexA=0
2024-05-03 10:00:17 +00:00
.PHONY: run-iso
run-iso: all
qemu-system-i386 \
$(QEMU_COMMON) \
-cdrom stupid.iso
2024-03-26 07:39:40 +00:00
2024-03-26 09:04:06 +00:00
.PHONY: run-efi
run-efi: all OVMF32.fd
qemu-system-i386 \
-bios OVMF32.fd \
-drive file=fat:rw:./sysroot,if=none,id=hdd \
2024-05-03 10:00:17 +00:00
-device ide-hd,drive=hdd
2024-03-20 09:48:47 +00:00
2024-03-26 07:39:40 +00:00
.PHONY: docs
docs:
@mkdir -p docs/html
2024-07-10 06:04:40 +00:00
wget -O docs/webring.json https://webring.devse.wiki/webring.json
python3 docs/devsewebring.py docs/webring.json docs/webring.txt
2024-03-26 07:39:40 +00:00
naturaldocs -p docs/config -img docs/img -xi sysroot -i . -ro -o HTML docs/html
cp docs/img/favicon.ico docs/html/
2024-03-20 09:48:47 +00:00
.PHONY: clean
clean: $(SUBDIRS)
$(RM) $(TARGET)