I started writing an OS kernel using the tutorial in this video. I've already written the Makefile
as you can see here:
x86_64_asm_source_files := $(shell find src/impl/x86_64 -name *.asm) # Holds the list of all of the assembly source files.
x86_64_asm_object_files := $(patsubst src/impl/x86_64/%.asm, build/x86_64/%.o, $(x86_64_asm_source_files)) # Holds the list of all of the obj files.
# Define the command we need to run to build one of the object files from the source files:
$(x86_64_asm_object_files): build/x86_64/%.o : src/impl/x86_64/%.asm
# For compiling the assembly files:
mkdir -p $(dir $@) && \
nasm -f elf64 $(patsubst build/x86_64/%.o, src/impl/x86_64/%.asm, $@) -o $@
# Create a custom phony command:
.PHONY: build-x86_64
# Run only if any of the object files have been changed:
build-x86_64: $(x86_64_asm_object_files)
# For generating the '.iso' file:
mkdir -p dist/x86_64 && \
x86_64-elf-ld -n -o dist/x86_64/kernel.bin -T targets/x86_64/linker.ld $(x86_64_asm_object_files) && \
cp dist/x86_64/kernel.bin targets/x86_64/iso/boot/kernel.bin && \
grub-mkrescue /usr/lib/grub/i386-pc -o dist/x86_64/kernel.iso targets/x86_64/iso
When I run make build-x86_64
inside a docker container, I get this error:
make: *** No rule to make target 'build-x86_64'. Stop.
When I write the make
command only it seems that there is no makefile
due to this error:
make: *** No targets specified and no makefile found. Stop.
When I use the make
command outside of docker, I get:
mkdir -p build/x86_64/boot/ && \
nasm -f elf64 src/impl/x86_64/boot/main.asm -o build/x86_64/boot/main.o
mkdir -p build/x86_64/boot/ && \
nasm -f elf64 src/impl/x86_64/boot/header.asm -o build/x86_64/boot/header.o
mkdir -p dist/x86_64 && \
x86_64-elf-ld -n -o dist/x86_64/kernel.bin -T targets/x86_64/linker.ld build/x86_64/boot/main.o build/x86_64/boot/header.o && \
cp dist/x86_64/kernel.bin targets/x86_64/iso/boot/kernel.bin && \
grub-mkrescue /use/lib/grub/i386-pc -o dist/x86_64/kernel.iso targets/x86_64/iso
/bin/sh: 2: x86_64-elf-ld: not found
make: *** [Makefile:16: build-x86_64] Error 127
The docker command I use for building the docker itself is: sudo docker build buildenv -t learnos-buildenv
The docker command I use for running the docker terminal is: sudo docker run --rm -it -v /root/env learnos-buildenv
Is there anything I can do to fix docker
? Or how can I get the x86_64-elf-ld
compiler without using docker
?
(My development OS is Ubuntu 20.04.2.0 LTS.)