11BL_SRC_DIR = src/bootloader
22SYSCALLS_SRC_DIR = src/lib/syscalls
3+ LIB_SRC_DIR = src/lib
34UTIL_SRC_DIR = src/lib/util
45BUILD_DIR = build
56APP_DIR = src/app
@@ -12,6 +13,7 @@ bt_stage2_c_o = $(BUILD_DIR)/bt_stage2_c.o
1213bt_stage2_asm_o = $(BUILD_DIR ) /bt_stage2_asm.o
1314bt_stage2 = $(BUILD_DIR ) /bt_stage2
1415image_vmdk = $(BUILD_DIR ) /image.vmdk
16+ app_entry_o = $(BUILD_DIR ) /app_entry.o
1517
1618# Apps
1719app_calc = $(BUILD_DIR ) /calc
@@ -26,32 +28,44 @@ all: images binaries
2628
2729images : $(image_vmdk )
2830
29- binaries : $(bt_stage1 ) $(bt_stage2 )
31+ binaries : $(bt_stage1 ) $(bt_stage2 ) $( app_calc )
3032
31- $(image_vmdk ) : $(bt_stage1 ) $(bt_stage2 )
33+ $(image_vmdk ) : $(bt_stage1 ) $(bt_stage2 ) $( app_calc )
3234 dd bs=512 count=2 if=$(bt_stage1 ) of=$@
3335 /bin/echo -ne " \x55\xaa" | dd seek=510 bs=1 of=$@
34- dd seek=1 bs=512 if= $(bt_stage2 ) of= $@
35- truncate --size=%512 $@
36+ cat $(bt_stage2 ) >> $@
37+ cat $( app_calc ) >> $@
3638 @echo " Stage 1 Size : " $$(stat -c %s $(bt_stage1 ) )
3739 @echo " Stage 2 Size : " $$(stat -c %s $(bt_stage2 ) )
38- @echo " Stage 2 LoadSize : " $$(( $$( printf "%d\n" "0x" $( BT_STAGE2_SECTOR_COUNT ) ) * 512 ) )
40+ @echo " App Calc Size : " $$(stat -c %s $( app_calc ) )
3941 @echo " Image Size : " $$(stat -c %s $@ )
40- @echo " Want BT_STAGE2_SECTOR_COUNT : 0x" $$(printf "%x\n" $$(( $$(stat -c %s $@ ) / 512 - 1 ) ) )
42+ @echo " Want BT_STAGE2_SECTOR_COUNT : 0x" $$(printf "%x\n" $$(( $$(stat -c %s $( bt_stage2 ) ) / 512 ) ) )
4143 @echo " Got BT_STAGE2_SECTOR_COUNT : 0x" $(BT_STAGE2_SECTOR_COUNT )
44+ @echo " AppSector Sector Count : " $$(( $$(stat -c %s $(app_calc ) ) / 512 ) )
45+ @echo " AppSector Sector Start : " $$(( 1 + $$(stat -c %s $(bt_stage1 ) ) / 512 + $$(stat -c %s $(bt_stage2 ) ) / 512 ) )
4246
4347$(bt_stage1 ) : $(BL_SRC_DIR ) /stage1.asm $(BL_SRC_DIR ) /constants.asm $(BL_SRC_DIR ) /io.asm $(BL_SRC_DIR ) /disk.asm
4448 nasm -o $@ -f bin -i $(BL_SRC_DIR ) / -D BT_STAGE2_SECTOR_COUNT=$(BT_STAGE2_SECTOR_COUNT ) $<
49+ truncate --size=%512 $@
4550
4651$(bt_stage2 ) : $(bt_stage2_asm_o ) $(bt_stage2_c_o )
4752 ld --oformat binary -m elf_i386 -Ttext 0x8000 --strip-all -o $@ $^
53+ truncate --size=%512 $@
4854
49- $(bt_stage2_c_o ) : $(BL_SRC_DIR ) /stage2.c $(SYSCALLS_SRC_DIR ) /basic.h $(SYSCALLS_SRC_DIR ) /io.h $(SYSCALLS_SRC_DIR ) /time.h $(SYSCALLS_SRC_DIR ) /color.h $(UTIL_SRC_DIR ) /string.h $(APP_DIR ) /dashboard.c $( APP_DIR ) /calc.c
55+ $(bt_stage2_c_o ) : $(BL_SRC_DIR ) /stage2.c $(SYSCALLS_SRC_DIR ) /basic.h $(SYSCALLS_SRC_DIR ) /io.h $(SYSCALLS_SRC_DIR ) /time.h $(SYSCALLS_SRC_DIR ) /color.h $(UTIL_SRC_DIR ) /string.h $(APP_DIR ) /dashboard.c
5056 gcc -m16 -fno-pie -c -Isrc -o $@ $<
5157
52- $(bt_stage2_asm_o ) : $(BL_SRC_DIR ) /stage2.asm $(BL_SRC_DIR ) /constants.asm $(BL_SRC_DIR ) /io.asm $(SYSCALLS_SRC_DIR ) /io_syscall.asm $(SYSCALLS_SRC_DIR ) /time_syscall.asm $(bt_stage2_o )
58+ $(bt_stage2_asm_o ) : $(BL_SRC_DIR ) /stage2.asm $(BL_SRC_DIR ) /constants.asm $(BL_SRC_DIR ) /io.asm $(SYSCALLS_SRC_DIR ) /io_syscall.asm $(SYSCALLS_SRC_DIR ) /time_syscall.asm $(bt_stage2_o ) $( SYSCALLS_SRC_DIR ) /disk_syscall.asm
5359 nasm -o $@ -f elf32 -i $(BL_SRC_DIR ) / -i$(SYSCALLS_SRC_DIR ) / $<
5460
61+ $(app_entry_o ) : $(LIB_SRC_DIR ) /app/entry.asm $(BL_SRC_DIR ) /constants.asm $(BL_SRC_DIR ) /io.asm $(SYSCALLS_SRC_DIR ) /io_syscall.asm $(SYSCALLS_SRC_DIR ) /time_syscall.asm
62+ nasm -o $@ -f elf32 -i $(BL_SRC_DIR ) / -i$(SYSCALLS_SRC_DIR ) / $<
63+
64+ $(app_calc ) : $(app_entry_o ) $(APP_DIR ) /calc.c $(SYSCALLS_SRC_DIR ) /basic.h $(SYSCALLS_SRC_DIR ) /io.h $(SYSCALLS_SRC_DIR ) /time.h $(SYSCALLS_SRC_DIR ) /color.h $(UTIL_SRC_DIR ) /string.h $(BL_SRC_DIR ) /constants.asm $(BL_SRC_DIR ) /io.asm $(SYSCALLS_SRC_DIR ) /io_syscall.asm $(SYSCALLS_SRC_DIR ) /time_syscall.asm
65+ gcc -m16 -fno-pie -c -Isrc -o $(BUILD_DIR ) /calc.o $(APP_DIR ) /calc.c
66+ ld --oformat binary -m elf_i386 -Ttext 0xC000 --strip-all -o $@ $(app_entry_o ) $(BUILD_DIR ) /calc.o
67+ truncate --size=%512 $@
68+
5569debug_stage1 : $(bt_stage1 )
5670 objdump -b binary -mi386 -Maddr16,data16 -D $<
5771 xxd $<
0 commit comments