##################################################################### # 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=format FLOPPY_IMAGE=floppy.img FLOPPY_BLOCK_COUNT=1440 FLOPPY_FS=FAT12 FLOPPY_FAT_SIZE=12 # Floppy images are good for programs like VMware and Bochs Pentium Emulator. ;-) # Program for copying COPY_BIN=copy ########################################## # 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 -f Makefile.ms ################################################# # Clean up the source directory of any binaries # ################################################# clean: cd boot; make clean cd kernel; make 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) a: /q /v:HOS partcopy stage1.bin 0 200 -f0 ################################# # Copy the files onto the drive # ################################# File_Copy: @echo "Copying stage 2 bootloader to the floppy..." $(COPY_BIN) boot/stage2.bin a:\ @echo "Copying kernel to the floppy..." $(COPY_BIN) kernel/kernel.bin a:\ ############################################ # 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=stage1.bin of=$(FLOPPY_IMAGE) seek=0 ################################# # Copy the files onto the image # ################################# @echo "Mounting floppy image..." mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop @echo "Copying stage 2 bootloader to the floppy image..." $(COPY_BIN) stage2.bin $(FLOPPY_MOUNT) @echo "Copying kernel to the floppy image..." $(COPY_BIN) kernel.bin $(FLOPPY_MOUNT) @echo "Unmounting floppy image..." mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop