只用两个文件来拼系统,程序结构真是太糟糕了,于是花了足足几个小时整理文件

 F:\mytest 的目录

[.]            boot.s         [i386++]       [memman]       start.cmd
[..]           [clib]         [kb_mouse]     mount.cmd      temp.txt
[asm]          detach.txt     kernel.c       multiboot2.h   [video]
attach.txt     [fifo]         linker.ld      [myhead]       
[backup]       [font]         Makefile       [sheet]        
              10 个文件         31,044 字节

 F:\mytest\asm 的目录

[.]  [..] 
               0 个文件              0 字节

 F:\mytest\backup 的目录

[.]            boot.s         multiboot2.h   
[..]           kernel.c       
               3 个文件         15,711 字节

 F:\mytest\clib 的目录

[.]         [..]        sprintf.c   sprintf.h   
               2 个文件          7,924 字节

 F:\mytest\fifo 的目录

[.]      [..]     fifo.c   fifo.h   
               2 个文件          1,423 字节

 F:\mytest\font 的目录

[.]            bin2obj.exe    font.o         hankaku.txt    
[..]           font.bin       font.obj       makefont.exe   
               6 个文件         60,798 字节

 F:\mytest\i386++ 的目录

[.]        [..]       gdtidt.c   gdtidt.h   
               2 个文件          4,292 字节

 F:\mytest\kb_mouse 的目录

[.]          [..]         kb_mouse.c   kb_mouse.h   
               2 个文件          3,375 字节

 F:\mytest\memman 的目录

[.]        [..]       memman.c   memman.h   
               2 个文件          7,257 字节

 F:\mytest\myhead 的目录

[.]        [..]       int.c      myhead.h   
               2 个文件          8,719 字节

 F:\mytest\sheet 的目录

[.]       [..]      sheet.c   sheet.h   
               2 个文件          5,489 字节

 F:\mytest\video 的目录

[.]       [..]      video.c   video.h   
               2 个文件          2,980 字节

当然Makefile也做了改动,不过因为不懂所以改的很糟糕了

CC=gcc -m32 -march=i386 -I. -w -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs

LD=ld -m i386pe
OBJFILES = boot.o kernel.o gdtidt.o int.o video.o sprintf.o fifo.o kb_mouse.o memman.o sheet.o font.o 
 
all: kernel
 
.s.o:
    nasm -felf -o $@ $<
.c.o:
    $(CC) $(CFLAGS) -o $@ -c $<
    gcc -w -c -m32 -o gdtidt.o .\i386++\gdtidt.c
    gcc -w -c -m32 -o int.o .\myhead\int.c
    gcc -w -c -m32 -o video.o .\video\video.c
    gcc -w -c -m32 -o sprintf.o .\clib\sprintf.c
    gcc -w -c -m32 -o kb_mouse.o .\kb_mouse\kb_mouse.c
    gcc -w -c -m32 -o fifo.o .\fifo\fifo.c    
    gcc -w -c -m32 -o memman.o .\memman\memman.c
    gcc -w -c -m32 -o sheet.o .\sheet\sheet.c
    copy /y .\font\font.o .\font.o
    


 
kernel: $(OBJFILES)
    $(LD) -T linker.ld -o $@ $^
 

default:    
    make all
    objcopy -I pe-i386 -O elf32-i386 kernel
    mount.cmd
  
run: 
    make default
    start virtualbox --startvm "C:\Users\Administrator\VirtualBox VMs\newos\newos.vbox" 
clean:
    del *.o
    del kernel
 

猜你喜欢

转载自blog.csdn.net/weixin_39410618/article/details/81900751