hos/Makefile

118 lines
3.6 KiB
Makefile

#####################################################################
# Author: Benjamen R. Meyer #
# Date: 2004-2-15 #
# Purpose: To build Josh Holtrop's OS (HOS) using GNU make #
# Note: This makefile is for use on Linux & other Unix-like systems #
#####################################################################
##############
# Variables: #
##############
# Information for creating a floppy image
# Note: FLOPPY_FS and FLOPPY_FAT_SIZE are related fields.
# FLOPPY_FAT_SIZE should be either 12 or 16,
# depending on if FLOPPY_FS is FAT12 or FAT16, respectively.
MKDOSFS_PROG=/sbin/mkdosfs
FLOPPY_IMAGE=floppy.img
FLOPPY_BLOCK_COUNT=1440
FLOPPY_FS=FAT12
FLOPPY_FAT_SIZE=12
FLOPPY_MOUNT=./floppy_image
# Floppy images are good for programs like VMware and Bochs Pentium Emulator. ;-)
# Program for copying
COPY_BIN=cp
##########################################
# Build the IPL (Boot Loader) and Kernel #
##########################################
all:
# A word of warning to users :-> And a little helpful information ;-)
@echo "Installation must be done as root."
@echo "Type 'make install' to install to a floppy in drive '/dev/fd0'"
@echo "Type 'make install_img' to create a floppy image and install to it."
cd boot; make
cd kernel; make
#################################################
# Clean up the source directory of any binaries #
#################################################
clean:
make -C boot clean
make -C kernel clean
###########################################
# The following is for the floppy drive #
# Note: This must be done on *nix as root #
###########################################
##########################
# Make install to floppy #
##########################
install: Install_IPL File_Copy
############################################
# Write the Stage 1 IPL to the boot sector #
############################################
Install_IPL:
$(MKDOSFS_PROG) /dev/fd0
dd if=boot/stage1.bin of=/dev/fd0
#################################
# Copy the files onto the drive #
#################################
File_Copy:
- mkdir floppy_mount
@echo "Mounting floppy to ./floppy_mount..."
mount /dev/fd0 ./floppy_mount
@echo "Copying stage 2 bootloader to the floppy..."
$(COPY_BIN) boot/stage2.bin ./floppy_mount
@echo "Copying kernel to the floppy..."
$(COPY_BIN) kernel/kernel.bin ./floppy_mount
@echo "Unmounting floppy..."
umount ./floppy_mount
- rm -rf floppy_mount
############################################
# The following is for the floppy image. #
# Note: This must be done on *nix as root. #
############################################
######################################
# Create and Format the floppy image #
######################################
install_img:
$(MKDOSFS_PROG) -C -F $(FLOPPY_FAT_SIZE) -r 112 $(FLOPPY_IMAGE) $(FLOPPY_BLOCK_COUNT)
############################################
# Write the Stage 1 IPL to the boot sector #
############################################
@echo "Writing boot sector to image..."
dd if=boot/stage1.bin of=$(FLOPPY_IMAGE) seek=0
#################################
# Copy the files onto the image #
#################################
- mkdir $(FLOPPY_MOUNT)
@echo "Mounting floppy image..."
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
@echo "Copying stage 2 bootloader to the floppy image..."
$(COPY_BIN) boot/stage2.bin $(FLOPPY_MOUNT)
@echo "Copying kernel to the floppy image..."
$(COPY_BIN) kernel/kernel.bin $(FLOPPY_MOUNT)
@echo "Unmounting floppy image..."
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop