build: Correction des makefiles et ajout du disque dur UEFI

This commit is contained in:
Nicolas Hordé 2020-09-16 22:32:13 +02:00
parent 4f7aae792e
commit 349451ba33
10 changed files with 2097 additions and 413 deletions

File diff suppressed because it is too large Load Diff

BIN
final/harddiskuefi.img.xz Normal file

Binary file not shown.

View File

@ -1,48 +1,53 @@
all: harddisk.img.final floppy.img.final harddiskuefi.img.final
harddiskuefi.img.before:
(xz -d -k harddiskuefi.img.xz)
(dd if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512)
(dd if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512;sync)
(mkdir ./mnt -p)
harddiskuefi.img.final: harddiskuefi.img.before
(mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt)
(cp ../system/system.sys ./mnt/boot/;sync)
(fusermount ./mnt -u)
(cat harddiskuefi.img.before > harddiskuefi.img.final)
(cat harddiskuefi.img.part1 >> harddiskuefi.img.final;sync)
harddisk.img.before:
(xz -d -k harddisk.img.xz)
(dd if=harddisk.img of=harddisk.img.part1 skip=63 bs=512)
(dd if=harddisk.img of=harddisk.img.before count=63 bs=512;sync)
(mkdir ./mnt -p)
harddisk.img.final: harddisk.img.before
(mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt)
(cp ../system/system.sys ./mnt/boot/;sync)
(fusermount ./mnt -u)
(cat harddisk.img.before > harddisk.img.final)
(cat harddisk.img.part1 >> harddisk.img.final;sync)
floppy.img.final:
(dd if=/dev/zero of=floppy.img.final count=2880 bs=512)
(mkfs.msdos -F 12 -n "COS2000" floppy.img.final)
(mkdir ./mnt -p)
(fusefat floppy.img.final ./mnt -o rw+)
(cp ../boot/loader.sys ./mnt/)
(cp ../system/system.sys ./mnt/;sync)
(fusermount ./mnt -u)
(dd if=../boot/boot12.bin of=floppy.img.final seek=0 count=1 conv=notrunc;sync)
littleclean:
rm -f *.final
togit: clean
clean:
rm -f *.before
rm -f *.part1
rm -f *.img
rm -f *.final
REMOVE=rm -f
INSTALL=sudo apt-get install
COPY=cp
DISKCOPY=dd
COMPRESS=xz
SYNC=sync
CREATEDIR=mkdir
CAT=cat
all: harddisk.img.final harddiskuefi.img.final
harddiskuefi.img.before:
$(COMPRESS) -d -k harddiskuefi.img.xz
$(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.part1 skip=13672 bs=512
$(DISKCOPY) if=harddiskuefi.img of=harddiskuefi.img.before count=13672 bs=512
$(SYNC)
$(CREATEDIR) ./mnt -p
harddiskuefi.img.final: harddiskuefi.img.before
mount.fuse-ext2 -o rw+ harddiskuefi.img.part1 ./mnt
$(COPY) ../system/system.sys ./mnt/boot/
$(SYNC)
fusermount ./mnt -u
cat harddiskuefi.img.before > harddiskuefi.img.final
cat harddiskuefi.img.part1 >> harddiskuefi.img.final
$(SYNC)
harddisk.img.before:
$(COMPRESS) -d -k harddisk.img.xz
$(DISKCOPY) if=harddisk.img of=harddisk.img.part1 skip=63 bs=512
$(DISKCOPY) if=harddisk.img of=harddisk.img.before count=63 bs=512
$(SYNC)
$(CREATEDIR) ./mnt -p
harddisk.img.final: harddisk.img.before
mount.fuse-ext2 -o rw+ harddisk.img.part1 ./mnt
$(COPY) ../system/system.sys ./mnt/boot/
$(SYNC)
fusermount ./mnt -u
cat harddisk.img.before > harddisk.img.final
cat harddisk.img.part1 >> harddisk.img.final
$(SYNC)
littleclean:
$(REMOVE) *.final
togit: clean
clean:
$(REMOVE) *.before
$(REMOVE) *.part1
$(REMOVE) *.img
$(REMOVE) *.final

View File

@ -12,14 +12,30 @@ mkfs.ext2 ${lo}p2
mount ${lo}p1 /mnt
mkdir /mnt/grub
echo -en "(hd0) ${lo}\n(hd0,1) ${lo}p1\n(hd0,2) ${lo}p2" > /mnt/grub/device.map
grub-install --no-floppy --boot-directory=/mnt/ --efi-directory=/mnt/ ${lo} --install-modules="part_gpt ext2 configfile normal multiboot2 video video_colors video_cirrus video_fb videotest all_video" --locales=fr --target=x86_64-efi --no-nvram
#LS MINICMD pour avoir vision paritions
grub-install --no-floppy --boot-directory=/mnt/ --efi-directory=/mnt/ ${lo} --install-modules="part_gpt ext2 configfile normal linux16 video video_colors video_cirrus video_fb videotest all_video" --locales=fr --target=x86_64-efi --no-nvram
mkdir /mnt/EFI/BOOT
cp /mnt/EFI/ubuntu/grubx64.efi /mnt/EFI/BOOT/bootx64.efi
#grub-mkimage -d /usr/lib/grub/x86_64-efi -o /mnt/EFI/BOOT/bootx64.efi -c /mnt/EFI/ubuntu/grub.cfg -p "(hd0,1)/grub/" -O x86_64-efi part_gpt ext2 configfile normal multiboot2 video video_color video_cirrus video_fb videotest all_video
echo -en "set timeout=4\nset default=0\n\nmenuentry "cos2000" {\nmultiboot2 (hd0,2)/boot/system.sys\nboot\n}" > /mnt/grub/grub.cfg
echo -en "\
insmod ext2
insmod biosdisk
insmod part_msdos
insmod linux
insmod vbe
insmod gfxterm
insmod png
insmod font
set timeout=4\n\
set default=0\n\
menuentry "cos2000" {\n\
set root=(hd0,gpt2)\n\
linux16 /boot/system.sys root=hd0,gpt2\n
boot\n\
}" > /mnt/grub/grub.cfg
umount /mnt
mount ${lo}p2 /mnt
mkdir /mnt/boot/
umount /mnt
losetup -d ${lo}
#xz -c harddiskuefi.img > harddiskuefi.img.xzcl
xz -c harddiskuefi.img > harddiskuefi.img.xz

View File

@ -1,59 +1,61 @@
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -m32 -F elf_i386 -fno-pie -no-pie -I ../include -c
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie
LINK=ld -m elf_i386 -r -o
SRCS= $(wildcard *.c)
OBJS= $(SRCS:.c=.o)
SRCASM= $(wildcard *.S)
OBJASM= $(SRCASM:.S=.o)
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGEPERM=chmod 644
all: libs.o
sync
togit: clean indent
libs.o:$(OBJS) $(OBJASM)
$(LINK) libs.o $(OBJS) $(OBJASM)
.o: .S
$(ASM) $^
handlers.o:handlers.c
$(CC) -mgeneral-regs-only $^
keyboard.o:keyboard.c
$(CC) -mgeneral-regs-only $^
mouse.o:mouse.c
$(CC) -mgeneral-regs-only $^
syscall.o:syscall.c
$(CC) -fomit-frame-pointer $^
.o: .c
$(CC) $^
clean:
$(REMOVE) *.o
$(REMOVE) *.c~
$(REMOVE) */*.c~
$(REMOVE) ../include/*.h~
$(REMOVE) ./TEST/*.c
sync
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
$(CHANGEPERM) ./*/*.c
$(CONVERT) ./*/*.c
$(INDENT) ./*/*.c
$(REMOVE) */*.c~
$(CHANGEPERM) ../include/*.h
$(CONVERT) ../include/*.h
$(INDENT) ../include/*.h
$(REMOVE) ../include/*.h~
sync
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -m32 -F elf_i386 -fno-pie -no-pie -I ../include -c
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie
LINK=ld -m elf_i386 -r -o
SRCS= $(wildcard *.c)
OBJS= $(SRCS:.c=.o)
SRCASM= $(wildcard *.S)
OBJASM= $(SRCASM:.S=.o)
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGEPERM=chmod 644
SYNC=sync
all: libs.o
$(SYNC)
togit: clean indent
libs.o:$(OBJS) $(OBJASM)
$(LINK) libs.o $(OBJS) $(OBJASM)
.o: .S
$(ASM) $^
handlers.o:handlers.c
$(CC) -mgeneral-regs-only $^
keyboard.o:keyboard.c
$(CC) -mgeneral-regs-only $^
mouse.o:mouse.c
$(CC) -mgeneral-regs-only $^
syscall.o:syscall.c
$(CC) -fomit-frame-pointer $^
.o: .c
$(CC) $^
clean:
$(REMOVE) *.o
$(REMOVE) *.c~
$(REMOVE) */*.c~
$(REMOVE) ../include/*.h~
$(REMOVE) ./TEST/*.c
$(SYNC)
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
$(CHANGEPERM) ./*/*.c
$(CONVERT) ./*/*.c
$(INDENT) ./*/*.c
$(REMOVE) */*.c~
$(CHANGEPERM) ../include/*.h
$(CONVERT) ../include/*.h
$(INDENT) ../include/*.h
$(REMOVE) ../include/*.h~
$(SYNC)

334
makefile
View File

@ -1,151 +1,183 @@
DEBUG=exec gnome-terminal --geometry=120x55+1+1 -x ./debug/debug.sh
REMOVE=rm -f
INSTALL=sudo apt-get install
COPY=cp
EMULATOR=bochs -f
GIT=git status
MAKECALL=python makesyscall.py
all: tools programs bits32 bits64 harddisk uefi
sync
bits32: ARCH=bits32
bits32: lib/libs.o system/system.sys
sync
bits64: ARCH=bits64
bits64: lib/libs.o system/system.sys
sync
tools: tools/build
tools/build:
make -C tools
syscall: clean remakeapi all
remakeapi:
$(MAKECALL)
programs: programs/test lib/TEST/test.c lib/TEST/test2.c
lib/TEST/test.c:
xxd -i programs/test lib/TEST/test.c
lib/TEST/test2.c:
xxd -i programs/test2 lib/TEST/test2.c
programs/test:
make -C programs
harddisk: final/harddisk.img.final
uefi: final/harddiskuefi.img.final
install:
$(INSTALL) gcc qemu fusefat fuseext2 gdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios dos2unix gnome-terminal
togit:
make -C system togit
make -C lib togit
make -C final togit
make -C programs togit
make -C tools togit
$(GIT)
sync
clean:
$(RM) -f .gdb_history
make -C system clean
make -C lib clean
make -C final clean
make -C programs clean
make -C tools clean
sync
littleclean:
make -C system clean
make -C lib clean
make -C final littleclean
make -C programs clean
sync
indent:
make -C system indent
make -C lib indent
make -C programs indent
make -C tools indent
sync
backup: clean
cd ..
tar cf - Source\ C | gzip -f - > backup.tar.gz
test: tools programs bits32 harddisk qemu
test64: tools programs bits64 uefi qemu64
retest: littleclean test
retest64: littleclean test64
testbochs: tools programs bits32 harddisk bochs-debug
view:
hexdump -C ./final/harddisk.img.final|head -c10000
debug: debug-system
redebug: littleclean debug-system
debug64: debug-system64
redebug64: littleclean debug-system64
kernel: debug-kernel
debug-boot: tools programs bits32 harddisk qemu-debug
sleep 2
$(DEBUG) ./debug/boot.txt
debug-system: tools programs bits32 harddisk qemu-debug
sleep 2
$(DEBUG) ./debug/system.txt
debug-system64: tools programs bits64 uefi qemu-debug64
sleep 2
$(DEBUG) ./debug/system.txt
bochs-debug: killer
$(EMULATOR) ./debug/config.bochs
killer:
killall bochs-debug || true
killall qemu-system-x86_64 || true
killall qemu-system-i386 || true
killall gnome-terminal-server || true
tmux kill-session -t debug || true
qemu-debug: killer
qemu-system-i386 -monitor telnet:127.0.0.1:6666,server,nowait -m 1G -drive format=raw,file=./final/harddisk.img.final -s -S &
qemu-debug64: killer
qemu-system-x86_64 -monitor telnet:127.0.0.1:6666,server,nowait -m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd -s -S &
qemu: killer
qemu-system-i386 -m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s &
qemu64: killer
qemu-system-x86_64 -m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s &
system/system.sys:
make -C system
final/harddisk.img.final:
make -C final harddisk.img.final
final/harddiskuefi.img.final:
make -C final harddiskuefi.img.final
lib/libs.o:
make -C lib
##### Variables
GODEBUG=exec gnome-terminal --geometry=120x55+1+1 -x ./debug/debug.sh
REMOVE=rm -f
INSTALL=sudo apt-get install
COPY=cp
OLDEMUX86=bochs -f
GIT=git status
MAKECALL=python makesyscall.py
MAKE=make -C
SYNC=sync
KILL=killall
TAR=tar cf - Source\ C | gzip -f - > backup.tar.gz
HEXDUMP=hexdump -C ./final/harddisk.img.final|head -c10000
TMUXKILL=tmux kill-session -t
TRUE=|| true
SPICE=spicy --uri=spice://127.0.0.1?port=5900
SOURCE=xxd -i
EMUX86=qemu-system-i386
EMUX64=qemu-system-x86_64
LEGACY=-m 1G -drive format=raw,file=./final/harddisk.img.final --enable-kvm -cpu host -s -vga qxl -spice port=5900,addr=127.0.0.1,disable-ticketing
UEFI=-m 5G -drive format=raw,file=./final/harddiskuefi.img.final --bios /usr/share/qemu/OVMF.fd --enable-kvm -cpu host -s -vga qxl -spice port=5900,addr=127.0.0.1,disable-ticketing
DEBUG=-S -monitor telnet:127.0.0.1:6666,server,nowait
WAIT2S=sleep 2
##### Construction
all: tools programs system32 system64 harddisk harddiskuefi
$(SYNC)
system32: ARCH=bits32
system32: lib/libs.o system/system.sys
$(SYNC)
system64: ARCH=bits64
system64: lib/libs.o system/system.sys
$(SYNC)
tools: tools/build
tools/build:
$(MAKE) tools
syscall: clean remakeapi all
remakeapi:
$(MAKECALL)
programs: programs/test lib/TEST/test.c lib/TEST/test2.c
lib/TEST/test.c:
$(SOURCE) programs/test lib/TEST/test.c
lib/TEST/test2.c:
$(SOURCE) programs/test2 lib/TEST/test2.c
programs/test:
$(MAKE) programs
harddisk: final/harddisk.img.final
harddiskuefi: final/harddiskuefi.img.final
install:
$(INSTALL) gcc qemu fusefat fuseext2 gdb ovmf bsdmainutils tar bsdmainutils indent binutils bochs bochs-x bochsbios dos2unix gnome-terminal spice-client-gtk python2
togit:
$(MAKE) system togit
$(MAKE) lib togit
$(MAKE) final togit
$(MAKE) programs togit
$(MAKE) tools togit
$(GIT)
$(SYNC)
clean:
$(REMOVE) .gdb_history
$(MAKE) system clean
$(MAKE) lib clean
$(MAKE) final clean
$(MAKE) programs clean
$(MAKE) tools clean
$(SYNC)
littleclean:
$(MAKE) system clean
$(MAKE) lib clean
$(MAKE) final littleclean
$(MAKE) programs clean
$(SYNC)
indent:
$(MAKE) system indent
$(MAKE) lib indent
$(MAKE) programs indent
$(MAKE) tools indent
$(SYNC)
backup: clean
cd ..
$(TAR)
test: test32
retest: retest32
test32: tools programs system32 harddisk qemu32
test64: tools programs system64 harddiskuefi qemu64
retest32: littleclean test32
retest64: littleclean test64
testbochs: tools programs system32 harddisk bochs-debug
view:
$(HEXDUMP)
##### Debuguage
debug: debug-system32
redebug32: littleclean debug-system32
debug64: debug-system64
redebug64: littleclean debug-system64
kernel: debug-kernel
debug-boot: tools programs system32 harddisk qemu-debug32
$(WAIT2S)
$(GODEBUG) ./debug/boot.txt
debug-system32: tools programs system32 harddisk qemu-debug32
$(WAIT2S)
$(GODEBUG) ./debug/system.txt
debug-system64: tools programs system32 harddiskuefi qemu-debug64
$(WAIT2S)
$(GODEBUG) ./debug/system.txt
bochs-debug: killer
$(OLDEMUX86) ./debug/config.bochs
killer:
$(KILL) bochs-debug $(TRUE)
$(KILL) qemu-system-x86_64 $(TRUE)
$(KILL) qemu-system-i386 $(TRUE)
$(KILL) gnome-terminal-server $(TRUE)
$(TMUXKILL) debug $(TRUE)
##### Emulation
qemu-debug32: killer
$(EMUX86) $(LEGACY) $(DEBUG) &
$(SPICE) &
qemu-debug64: killer
$(EMUX64) $(UEFI) $(DEBUG) &
$(SPICE) &
qemu32: killer
$(EMUX86) $(LEGACY) &
$(WAIT2S)
$(SPICE)
qemu64: killer
$(EMUX64) $(UEFI) &
$(WAIT2S)
$(SPICE)
system/system.sys:
$(MAKE) system
final/harddisk.img.final:
$(MAKE) final harddisk.img.final
final/harddiskuefi.img.final:
$(MAKE) final harddiskuefi.img.final
lib/libs.o:
$(MAKE) lib

View File

@ -1,38 +1,41 @@
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -m32 -I ./include -fno-pie -no-pie -c -o
LINK=ld -m elf_i386 -T linker.lds -n -o
SRCS= $(wildcard *.c)
EXECS= $(SRCS:.c=)
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644
all: lib/libs.a $(EXECS)
sync
togit: clean indent
lib/libs.a:
make -C lib
%: %.c
$(CC) $@.o $<
$(LINK) $@ $@.o lib/libs.a
$(CHANGEPERM) $@
$(CHANGELF) $@
clean:
make -C lib clean
$(REMOVE) *.o
$(REMOVE) *.c~
find . -type f ! -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync
indent:
make -C lib indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -m32 -I ./include -fno-pie -no-pie -c -o
LINK=ld -m elf_i386 -T linker.lds -n -o
SRCS= $(wildcard *.c)
EXECS= $(SRCS:.c=)
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644
MAKE=make -C
SYNC=sync
all: lib/libs.a $(EXECS)
$(SYNC)
togit: clean indent
lib/libs.a:
$(MAKE) lib
%: %.c
$(CC) $@.o $<
$(LINK) $@ $@.o lib/libs.a
$(CHANGEPERM) $@
$(CHANGELF) $@
clean:
$(MAKE) lib clean
$(REMOVE) *.o
$(REMOVE) *.c~
find . -maxdepth 1 -type f ! -perm /u=x -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
$(SYNC)
indent:
$(MAKE) lib indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
$(SYNC)

View File

@ -1,83 +1,86 @@
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../include -m32 -fno-pie -no-pie -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -D__ASSEMBLY__ -c -o
LINK=ld -m elf_i386 -n
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGEPERM=chmod 644
NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug
ZOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
COMP=gzip -9 -f
BUILD=../tools/build
MKPIGGY=../tools/mkpiggy
all: system.sys
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys
sync
allpiggy.o: piggy.o decompress.o header.o
$(LINK) -T allpiggy piggy.o decompress.o header.o
voffset.h: system
$(NM) system|$(VOFFSET)>voffset.h
zoffset.h: piggy.o
$(NM) piggy.o|$(ZOFFSET)>zoffset.h
togit: clean indent
piggy.o: piggy.S
$(ASM) $@ $^
system: system.o system_asm.o ../lib/libs.o
$(LINK) -T system.ld system.o system_asm.o ../lib/libs.o
$(OBJDEBUG) system system.sym
$(NM) system > system.map
system.bin: system
$(OBJCOPY) $^ $@
system.bin.gz: system.bin
cat $^|$(COMP) > $@
piggy.S: system.bin.gz
$(MKPIGGY) $^ > $@
realmode/setup.bin:
make -C realmode
system.o: system.c
$(GCC) $@ $^
system_asm.o: system_asm.S
$(ASM) $@ $^
clean:
make -C realmode clean
$(REMOVE) system
$(REMOVE) piggy.S
$(REMOVE) *.o
$(REMOVE) *.tmp
$(REMOVE) *.sym
$(REMOVE) *.map
$(REMOVE) *.gz
$(REMOVE) *.h
$(REMOVE) *.out
$(REMOVE) *.bin
$(REMOVE) *.sys
$(REMOVE) *.s
$(REMOVE) *.c~
sync
indent:
make -C realmode indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../include -m32 -fno-pie -no-pie -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -D__ASSEMBLY__ -c -o
LINK=ld -m elf_i386 -n
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGEPERM=chmod 644
NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug
ZOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
COMP=gzip -9 -f
BUILD=../tools/build
MKPIGGY=../tools/mkpiggy
MAKE=make -C
SYNC=sync
all: system.sys
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys
$(SYNC)
allpiggy.o: piggy.o decompress.o header.o
$(LINK) -T allpiggy piggy.o decompress.o header.o
voffset.h: system
$(NM) system|$(VOFFSET)>voffset.h
zoffset.h: piggy.o
$(NM) piggy.o|$(ZOFFSET)>zoffset.h
togit: clean indent
piggy.o: piggy.S
$(ASM) $@ $^
system: system.o system_asm.o ../lib/libs.o
$(LINK) -T system.ld system.o system_asm.o ../lib/libs.o
$(OBJDEBUG) system system.sym
$(NM) system > system.map
system.bin: system
$(OBJCOPY) $^ $@
system.bin.gz: system.bin
cat $^|$(COMP) > $@
piggy.S: system.bin.gz
$(MKPIGGY) $^ > $@
realmode/setup.bin:
$(MAKE) realmode
system.o: system.c
$(GCC) $@ $^
system_asm.o: system_asm.S
$(ASM) $@ $^
clean:
$(MAKE) realmode clean
$(REMOVE) system
$(REMOVE) piggy.S
$(REMOVE) *.o
$(REMOVE) *.tmp
$(REMOVE) *.sym
$(REMOVE) *.map
$(REMOVE) *.gz
$(REMOVE) *.h
$(REMOVE) *.out
$(REMOVE) *.bin
$(REMOVE) *.sys
$(REMOVE) *.s
$(REMOVE) *.c~
$(SYNC)
indent:
$(MAKE) realmode indent
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
$(SYNC)

View File

@ -9,9 +9,10 @@ NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug
$(eval VERSION=$(shell git describe --tags))
SYNC=sync
all: setup.bin
sync
$(SYNC)
setup: setupc.o setup.o setup32.o
$(LINK) -T setup.ld setupc.o setup.o setup32.o
@ -40,11 +41,12 @@ clean:
$(REMOVE) *.sys
$(REMOVE) *.s
$(REMOVE) *.c~
sync
$(SYNC)
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
$(SYNC)

View File

@ -1,28 +1,28 @@
CC=gcc -DCONFIG_X86_32 -I . -o
SRCS= $(wildcard *.c)
EXECS= $(SRCS:.c=)
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644
all: $(EXECS)
sync
togit: clean indent
%: %.c
$(CC) $@ $<
clean:
$(REMOVE) *.o
$(REMOVE) *.c~
find . -type f ! -name makefile -perm /u=x -maxdepth 1 -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync
CC=gcc -DCONFIG_X86_32 -I . -o
SRCS= $(wildcard *.c)
EXECS= $(SRCS:.c=)
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
REMOVE=rm -f
CHANGELF=elfedit --output-osabi FenixOS
CHANGEPERM=chmod 644
all: $(EXECS)
sync
togit: clean indent
%: %.c
$(CC) $@ $<
clean:
$(REMOVE) *.o
$(REMOVE) *.c~
find . -maxdepth 1 -type f ! -name makefile -perm /u=x -regex '.+/\.?[^\.]+' -exec $(REMOVE) {} \;
sync
indent:
$(CHANGEPERM) *.c
$(CONVERT) *.c
$(INDENT) *.c
$(REMOVE) *.c~
sync