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
40 cp -f linurv rootfs/bin/
41 for f in ${PROGS:.elf=}; do cp -f $$f.elf rootfs/bin/$$(basename "$$f"); done
42 cp -f test.txt rootfs/
43 ${CHROOT} rootfs /bin/linurv -v /bin/$T
46 (cd tools; ${MAKE} distclean)
49 rm -f linurv src/*.o examples/*.elf *.core src/syscalls.h src/signal-bootstrap-code.h src/sbc.* src/data.[ch]
53 mkdir -p ${DESTDIR}${PREFIX}/bin
54 cp -f linurv ${DESTDIR}${PREFIX}/bin/
57 ${CC} -o $@ ${OBJ} ${LDFLAGS}
59 ${OBJ}: src/linurv.h src/data.h
60 src/ecall.o: src/syscalls.h
62 src/cpu.o: src/signal-bootstrap-code.h
64 src/syscalls.h: src/syscalls.inc src/gensyscalls.sh
65 sh src/gensyscalls.sh < src/syscalls.inc > $@
68 ${CC} -c -o $@ $< ${CFLAGS}
70 src/signal-bootstrap-code.h: src/signal-bootstrap-code.S
71 ${CROSS}-as -o src/sbc.o src/signal-bootstrap-code.S
72 ${CROSS}-objcopy -O binary src/sbc.o src/sbc.bin
73 hexdump -v -e '16/1 "0x%02x," "\n"' <src/sbc.bin >$@
77 ${CROSS}-gcc -g -o $@ $< -Og
80 ${CROSS}-gcc -g -o $@ $<
82 src/data.c src/data.h: src/data.dst
83 (cd src && ../tools/bin/destruct -e little -H data.h -o data.c data.dst)