2 .SUFFIXES: .c .S .o .elf
6 TARGET = riscv64-unknown-linux-musl
7 CROSS = ./tools/bin/${TARGET}
12 CFLAGS = ${CFLAGS_OS} ${COPT} -std=c2x -Wall -Wextra
13 LDFLAGS = ${LDFLAGS_OS} -lpthread
15 OBJ = src/linurv.o src/ecall.o src/cpu.o src/exec.o src/signal.o src/data.o
17 PROGS = examples/test.elf \
31 @echo "CFLAGS=${CFLAGS}"
32 @echo "LDFLAGS=${LDFLAGS}"
33 @echo "CHROOT=${CHROOT}"
36 ${CROSS}-objdump -d examples/$T.elf | less
39 ${CROSS}-objdump -d rootfs/bb/bin/busybox | less
43 cp -f linurv rootfs/bin/
44 for f in ${PROGS:.elf=}; do cp -f $$f.elf rootfs/bin/$$(basename "$$f"); done
45 cp -f test.txt rootfs/
46 ${CHROOT} rootfs /bin/linurv -v /bin/$T
49 (cd tools; ${MAKE} distclean)
52 rm -f linurv src/*.o examples/*.elf *.core src/syscalls.h src/signal-bootstrap-code.h src/sbc.* src/data.[ch]
56 mkdir -p ${DESTDIR}${PREFIX}/bin
57 cp -f linurv ${DESTDIR}${PREFIX}/bin/
60 ${CC} -o $@ ${OBJ} ${LDFLAGS}
62 ${OBJ}: src/linurv.h src/data.h
63 src/ecall.o: src/syscalls.h
65 src/cpu.o: src/signal-bootstrap-code.h
67 src/syscalls.h: src/syscalls.inc src/gensyscalls.sh
68 sh src/gensyscalls.sh < src/syscalls.inc > $@
71 ${CC} -c -o $@ $< ${CFLAGS}
73 src/signal-bootstrap-code.h: src/signal-bootstrap-code.S
74 ${CROSS}-as -o src/sbc.o src/signal-bootstrap-code.S
75 ${CROSS}-objcopy -O binary src/sbc.o src/sbc.bin
76 hexdump -v -e '16/1 "0x%02x," "\n"' <src/sbc.bin >$@
80 ${CROSS}-gcc -g -o $@ $< -Og
83 ${CROSS}-gcc -g -o $@ $<
85 src/data.c src/data.h: src/data.dst
86 (cd src && ../tools/bin/destruct -e little -H data.h -o data.c data.dst)