Makefile 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. source_files := $(wildcard build/*.asm)
  2. source_files += $(addprefix build/,$(wildcard *.asm))
  3. obj_files := $(patsubst %.asm,%.o,$(source_files))
  4. host_executables := $(patsubst %.asm,%.bin,$(source_files))
  5. v86_executables := $(patsubst %.asm,%.img,$(source_files))
  6. inc_files := $(addprefix build/,$(wildcard *.inc))
  7. all: $(source_files) $(obj_files) $(inc_files) $(host_executables) $(v86_executables)
  8. .PHONY: all
  9. build/%.o: build/%.asm $(inc_files)
  10. nasm -w+error -felf32 -o $@ $<
  11. # To run / debug locally
  12. build/%.bin: build/%.o
  13. ld -g $< -m elf_i386 --section-start=.bss=0x100000 --section-start=.text=0x800000 -o $@
  14. # To use as a multiboot kernel image for v86
  15. build/%.img: build/%.o
  16. ld -g $< -m elf_i386 --section-start=.bss=0x100000 --section-start=.text=0x8000 --section-start=.multiboot=0x200 -o $@
  17. build/%.asm: %.asm
  18. mkdir -p build; cp $< $@
  19. build/%.inc: %.inc
  20. mkdir -p build; cp $< $@
  21. .PHONY: clean
  22. clean:
  23. rm -f *.o *.bin *.img *.fixture gen_*.asm # old location
  24. rm -f build/*.o build/*.bin build/*.img build/*.fixture build/*.asm