Code: Select all
all: floppy.img
loader.o: loader.asm
nasm -f aout -o loader.o loader.asm
main.o: main.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
memory.o: memory.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o memory.o memory.c
string.o: string.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o string.o string.c
kernel.bin: loader.o main.o memory.o string.o
ld -T link.ld -o kernel.bin loader.o main.o memory.o string.o
floppy.img: kernel.bin
cat stage1 stage2 pad kernel.bin > floppy.img
Code: Select all
COMPILER := gcc
ASSEMBLER := nasm
PRJDIRS := loader memory string
NASM_SOURCE_FILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.asm")
C_SOURCE_FILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
C_HEADER_FILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.h")
ALL_SOURCE_FILES := $(NASM_SOURCE_FILES) $(C_SOURCE_FILES) $(C_HEADER_FILES)
OBJECT_FILES := $(patsubst %.c,%.o,$(C_SOURCE_FILES)) $(patsubst %.asm,%.o,$(NASM_SOURCE_FILES))
COMPILER_FLAGS := -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin
all: kernel.bin
kernel.bin: $(OBJECT_FILES)
ld -T link.ld -o kernel.bin $(OBJECT_FILES)
%.o: %.c
$(COMPILER) $(COMPILER_FLAGS) -I./include -c -o $@ $<
%.o: %.asm
$(ASSEMBLER) -f aout -o $@ $<
The error:
Code: Select all
make -k all
ld -T link.ld -o kernel.bin ./string/string.o ./main.o ./memory/memory.o ./loader/loader.o
./main.o: In function `kmain':
main.c:(.text+0x0): multiple definition of `kmain'
./string/string.o:(.text+0x0): first defined here
./memory/memory.o: In function `memcpy':
memory.c:(.text+0x0): multiple definition of `memcpy'
./string/string.o:(.text+0x10): first defined here
./memory/memory.o: In function `memset':
memory.c:(.text+0x29): multiple definition of `memset'
./string/string.o:(.text+0x39): first defined here
./memory/memory.o: In function `memsetw':
memory.c:(.text+0x4b): multiple definition of `memsetw'
./string/string.o:(.text+0x5b): first defined here
./loader/loader.o:./loader/loader.o:(.text+0x20): multiple definition of `_loader'
./string/string.o:(.text+0xa0): first defined here
make: *** [kernel.bin] Error 1
make: Target `all' not remade because of errors.