projects
/
ld45_start_nothing
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
converted to protected mode, not done
[ld45_start_nothing]
/
Makefile
diff --git
a/Makefile
b/Makefile
index
90ea9da
..
165c473
100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-1,45
+1,63
@@
-src = $(wildcard src/*.asm)
+src = $(wildcard src/boot/*.asm) $(wildcard src/*.asm)
+obj = $(src:.asm=.o)
data = data/sprsheet.inc
data = data/sprsheet.inc
-bin = game
+name = game
+elf = $(name).elf
+bin = $(name).bin
-QEMU_FLAGS = -fda floppy.img -serial file:serial.log -soundhw sb16 -d guest_errors
+ASFLAGS = -f elf32
+LDFLAGS = -m elf_i386 -T game.ld -print-gc-sections
+
+QEMU_FLAGS = -fda floppy.img -serial file:serial.log -d guest_errors
.PHONY: all
all: floppy.img
.PHONY: all
all: floppy.img
-bootldr: src/boot/boot.asm $(bin)
- nasm -o $@ -f bin -DBINSIZE=`ls -l $(bin) | awk '{print $$5}'` $<
-
-$(bin): $(src) $(data)
- nasm -o $@ -f bin -i src/ src/main.asm
+floppy.img: boot.img
+ dd of=$@ if=/dev/zero bs=512 count=2880
+ dd of=$@ if=$< conv=notrunc
-boot.img: bootldr $(bin)
+boot.img: bootldr.bin $(bin)
cat $^ >$@
cat $^ >$@
-floppy.img: boot.img
- dd of=$@ if=/dev/zero bs=512 count=2880
- dd of=$@ if=$< bs=1 conv=notrunc
+bootldr.bin: $(elf)
+ objcopy -O binary -j '.boot*' $< $@
+
+$(bin): $(elf) $(data)
+ objcopy -O binary -R '.boot*' $< $@
+
+$(elf): $(obj)
+ $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
+
+%.o: %.asm
+ nasm -o $@ $(ASFLAGS) $<
data/sprsheet.inc: data/sprsheet.png
img2tiles -o $@ -n -t 32x32 $<
.PHONY: clean
clean:
data/sprsheet.inc: data/sprsheet.png
img2tiles -o $@ -n -t 32x32 $<
.PHONY: clean
clean:
- rm -f $(bin) bootldr floppy.img boot.img
+ rm -f $(bin) $(obj) bootldr.img floppy.img boot.img
.PHONY: disasm
disasm: bootldr.disasm $(bin).disasm
.PHONY: disasm
disasm: bootldr.disasm $(bin).disasm
-bootldr.disasm: bootldr
+bootldr.disasm: bootldr.img
ndisasm -b 16 -o 7c00h $< >$@
ndisasm -b 16 -o 7c00h $< >$@
-$(bin).disasm: $(bin)
- ndisasm -b 16 -o 7e00h $< >$@
+$(name).disasm: $(elf)
+ objdump -d $< -j .text -m i386 >$@
+
+$(name).sym: $(elf)
+ objcopy --only-keep-debug $< $@
.PHONY: run
.PHONY: run
-run: $(bin)
+run: floppy.img
qemu-system-i386 $(QEMU_FLAGS)
.PHONY: debug
qemu-system-i386 $(QEMU_FLAGS)
.PHONY: debug
-debug: $(bin)
+debug: floppy.img
qemu-system-i386 $(QEMU_FLAGS) -s -S
qemu-system-i386 $(QEMU_FLAGS) -s -S
+
+.PHONY: sym
+sym: $(name).sym