rt-thread/bsp/x86/Makefile
SASANO Takayoshi 86742879f3 There is no problem to create hello.mo with default compiler on
Debian-9.5/amd64.

But building hello.mo with i386-elf-gcc (5.5.0) cross compiler on
OpenBSD-6.3/amd64, undefined reference to 'rt_kprintf' error occurs.

To avoid this error, "compile and link" process needs to be divided to
simply "compile" and "link".

On Debian-9.5, both previous and current method produces same hello.mo.

We have to improve disk image creation (Linux dependent),
this is a future homework.
2018-10-06 18:33:18 +09:00

47 lines
1002 B
Makefile

CC = gcc -O0 -m32 -fno-builtin -fno-stack-protector -nostdinc -nostdlib
LD = ld -melf_i386 -nostdlib
all: rtthread rtsym exe dll floppy.img
@mkdir -p tmp
@sudo mount -t vfat floppy.img tmp -o loop
@sudo cp -fv rtthread.elf tmp/boot/oskernel
@sudo rm tmp/bin/* -fr
@sudo cp out/*.mo tmp/bin/ -fv
@sudo umount tmp
rtthread:
@scons
rtsym:
@./src/extract.sh ./rtthread-ia32.map ./src/rt_thread_sym.h
obj:
mkdir -p obj
out:
mkdir -p out
dll: obj out
$(CC) -c -fPIC -Isrc src/hello.c -o out/hello.o
$(CC) -s -Wl,-shared,-melf_i386,--entry=main -o out/hello.mo out/hello.o
disasm: obj out
$(CC) -shared -S -fPIC -Isrc src/hello.c -o obj/hello.s
cat obj/hello.s
objdump --disassemble out/hello.mo
exe: obj out
clean:
scons -c clean
rm -fr build rtthread* out obj
floppy.img:
wget https://github.com/bajdcc/tinix/raw/master/floppy.img
# https://en.wikibooks.org/wiki/QEMU/Devices/Network
run:
qemu-system-i386 -fda floppy.img -boot a -m 64M -serial stdio -net nic,model=ne2k_pci