summaryrefslogtreecommitdiff
path: root/boot/Make.mk
diff options
context:
space:
mode:
Diffstat (limited to 'boot/Make.mk')
-rw-r--r--boot/Make.mk43
1 files changed, 43 insertions, 0 deletions
diff --git a/boot/Make.mk b/boot/Make.mk
new file mode 100644
index 0000000..a7396fb
--- /dev/null
+++ b/boot/Make.mk
@@ -0,0 +1,43 @@
+#
+# Makefile fragment for the bootstrap component of the system.
+#
+# THIS IS NOT A COMPLETE Makefile - run GNU make in the top-level
+# directory, and this will be pulled in automatically.
+#
+
+SUBDIRS += boot
+
+###################
+# FILES SECTION #
+###################
+
+BOOT_SRC := boot/boot.S
+
+BOOT_OBJ := $(BUILDDIR)/boot/boot.o
+
+# BLDFLAGS := -Ttext 0x7c00 -s --oformat binary -e bootentry
+# BLDFLAGS := -Ttext 0 -s --oformat binary -e bootentry
+# BLDFLAGS := -N -Ttext 0x7c00 -s -e bootentry
+BLDFLAGS := -N -Ttext 0 -s -e bootentry
+
+###################
+# RULES SECTION #
+###################
+
+bootstrap: $(BUILDDIR)/boot/boot
+
+$(BUILDDIR)/boot/%.o: boot/%.c $(BUILDDIR)/.vars.CFLAGS
+ @mkdir -p $(@D)
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BUILDDIR)/boot/%.o: boot/%.S $(BUILDDIR)/.vars.CFLAGS
+ @mkdir -p $(@D)
+ $(CPP) $(CPPFLAGS) -o $(@D)/$*.s $<
+ $(AS) $(ASFLAGS) -o $@ $(@D)/$*.s -a=$(@D)/$*.lst
+ $(RM) -f $(@D)/$*.s
+ $(NM) -n $@ > $(@D)/$*.sym
+
+$(BUILDDIR)/boot/boot: $(BOOT_OBJ)
+ @mkdir -p $(@D)
+ $(LD) $(LDFLAGS) $(BLDFLAGS) -o $@.out $^
+ $(OBJCOPY) -S -O binary -j .text $@.out $@