summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-14 13:53:21 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-14 13:53:21 +0100
commitc3990b594d89036c0d1d514200f074b566fdfccb (patch)
tree219d4fb1f2d287a04b7cbf8e9301fff218ce7f8f /Makefile
parentef7a34fa88cf53d53f88e5e466d76c48467d95fa (diff)
improved recursive make invocations
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile91
1 files changed, 47 insertions, 44 deletions
diff --git a/Makefile b/Makefile
index 123fa77..f24ee1e 100644
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,18 @@
+
+
+.PHONY: all new
+
############ some constants ############
+#submodules
+SUBDIRS=boot1 boot2 font userspace
+
+FOOLOS=FoolOS.img
+FOOLOS_VDI=FoolOS.vdi
+
#take care to set this properly!
USB_STICK=/dev/sdf
@@ -65,79 +75,75 @@ all: FoolOS.vdi FoolOS.img
new: clean all
+
########### INCLUDES ###################3
include Makefile.common
-include $(DEPS)
+#### BINARIES AND SUBMODULES ########
+
+BIN_KERNEL=kernel.bin
+BIN_MBR=./boot1/mbr.bin
+BIN_STAGE2=./boot2/stage2.bin
+BIN_MP=./boot2/mp.bin
+BIN_FOOLFONT=./font/binfont.bin
+
+IMG_FILLUP=fill.img
+IMG_USERSPACE=./userspace/ext2.img
+
######### RECURSIVE MAKES ########################
-# master boot record
-MBR=./boot1/mbr.bin
-$(MBR):
- make -C boot1 mbr.bin
-# stage 2 bootloader
-STAGE2=./boot2/stage2.bin
-$(STAGE2):
- make -C boot2 stage2.bin
+CLEANDIRS=$(SUBDIRS:%=clean-%)
+
+.PHONY: $(SUBDIRS) $(CLEANDIRS)
-# multiprocessor binary entry
-MP_BIN=./boot2/mp.bin
-$(MP_BIN):
- make -C boot2 mp.bin
+$(SUBDIRS):
+ $(MAKE) -C $@
-# fonts
-FOOLFONT=./font/binfont.bin
-$(FOOLFONT):
- make -C font binfont.bin
+$(CLEANDIRS):
+ $(MAKE) -C $(@:clean-%=%) clean
-# userspace
-USERSPACE=./userspace/ext2.img
-$(USERSPACE):
- make -C userspace ext2.img
-
############ linking kernel binary ############
# the kernel_entry.o needs to be FIRST!!
-kernel.bin: $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS)
+$(BIN_KERNEL): $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS)
$(CC) $(CFLAGS) -o $@ -Wl,-Ttext,$(KERNEL_START),--oformat,binary $^
######## generate empty image ~25MB ###############
-FILLUP=fill.img
-$(FILLUP):
- dd if=/dev/zero of=$(FILLUP) bs=512 count=50000
+$(IMG_FILLUP):
+ dd if=/dev/zero of=$(IMG_FILLUP) bs=512 count=50000
############ assembling of final image ############
# master boot record, kernel binary and fool-font
-FoolOS.img: $(MBR) $(STAGE2) kernel.bin $(FILLUP) $(FOOLFONT) $(MP_BIN) $(USERSPACE)
- cp $(FILLUP) $@
- dd if=$(MBR) of=$@ bs=512 seek=0 conv=notrunc
- dd if=$(STAGE2) of=$@ bs=512 seek=1 conv=notrunc
+$(FOOLOS): $(IMG_FILLUP) $(BIN_KERNEL) $(SUBDIRS)
+ cp $(IMG_FILLUP) $@
+ dd if=$(BIN_MBR) of=$@ bs=512 seek=0 conv=notrunc
+ dd if=$(BIN_STAGE2) of=$@ bs=512 seek=1 conv=notrunc
dd if=kernel.bin of=$@ bs=512 seek=10 conv=notrunc #will end up at 0x100000 in ram (this is what the booloader starts loading secotr: 10)
#data starts at 0x168000
- dd if=$(MP_BIN) of=$@ bs=512 seek=842 conv=notrunc
- dd if=$(FOOLFONT) of=$@ bs=512 seek=843 conv=notrunc
- dd if=$(USERSPACE) of=$@ bs=512 seek=846 conv=notrunc #will end up at 0x80800 in ram
-
+ dd if=$(BIN_MP) of=$@ bs=512 seek=842 conv=notrunc
+ dd if=$(BIN_FOOLFONT) of=$@ bs=512 seek=843 conv=notrunc
+ dd if=$(IMG_USERSPACE) of=$@ bs=512 seek=846 conv=notrunc #will end up at 0x80800 in ram
############ virtual machines stuff ############
# vdi image for VirtualBox
-FoolOS.vdi: FoolOS.img
+$(FOOLOS_VDI): $(FOOLOS)
-rm FoolOS.vdi
- VBoxManage convertfromraw FoolOS.img FoolOS.vdi --uuid 2f11ca11-c35d-4240-b77e-79e37d32616c
+ VBoxManage convertfromraw $< $@ --uuid 2f11ca11-c35d-4240-b77e-79e37d32616c
# run in our local bochs (we need cirrus support for our vesa mode)
run: all
@@ -146,22 +152,19 @@ run: all
newrun: clean run
+
############ create bootable usb image ############
-stick: FoolOS.img
- cat FoolOS.img > $(USB_STICK) && sync
+stick: $(FOOLOS)
+ cat $< > $(USB_STICK) && sync
xxd $(USB_STICK) | head -n 50
############ cleanup ############
-clean:
- -rm *.bin FoolData.img bochs.log $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS) $(FILLUP) $(MBR) $(MP_BIN) bochs.out ne2k-tx.log ne2k-txdump.txt $(STAGE2) $(DEPS) $(ASM_OBJECTS)
- -rm FoolOS.img FoolOS.vdi
- make -C boot1 clean
- make -C boot2 clean
- make -C userspace clean
- make -C font clean
+clean: $(CLEANDIRS)
+ -rm *.bin $(FOOLOS) $(FOOLOS_DVI) $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS) $(IMG_FILLUP) $(BIN_MBR) $(BIN_MP) $(BIN_STAGE2) $(DEPS) bochs.out bochs.log ne2k-tx.log ne2k-txdump.txt
+