.SUFFIXES: .SUFFIXES: .c .S .o .elf TOP != pwd PREFIX = /usr/local TARGET = riscv64-unknown-linux-musl CROSS = ./tools/bin/${TARGET} include config.mk COPT = -g -O2 CFLAGS = ${CFLAGS_OS} ${COPT} -std=c2x -Wall -Wextra LDFLAGS = ${LDFLAGS_OS} -lpthread OBJ = src/linurv.o src/ecall.o src/cpu.o src/exec.o src/signal.o src/data.o T = signal PROGS = examples/test.elf \ examples/echo.elf \ examples/cat.elf \ examples/hello.elf \ examples/asm.elf \ examples/signal.elf \ examples/true.elf all: linurv ${PROGS} config: @echo "CC=${CC}" @echo "CXX=${CXX}" @echo "SUDO=${SUDO}" @echo "CFLAGS=${CFLAGS}" @echo "LDFLAGS=${LDFLAGS}" @echo "CHROOT=${CHROOT}" od: examples/$T.elf ${CROSS}-objdump -d examples/$T.elf | less od-bb: ${CROSS}-objdump -d rootfs/bb/bin/busybox | less run: linurv ${PROGS} mkdir -p rootfs/bin cp -f linurv rootfs/bin/ for f in ${PROGS:.elf=}; do cp -f $$f.elf rootfs/bin/$$(basename "$$f"); done cp -f test.txt rootfs/ ${CHROOT} rootfs /bin/linurv -v /bin/$T distclean: clean (cd tools; ${MAKE} distclean) clean: rm -f linurv src/*.o examples/*.elf *.core src/syscalls.h src/signal-bootstrap-code.h src/sbc.* src/data.[ch] rm -rf rootfs install: linurv mkdir -p ${DESTDIR}${PREFIX}/bin cp -f linurv ${DESTDIR}${PREFIX}/bin/ linurv: ${OBJ} ${CC} -o $@ ${OBJ} ${LDFLAGS} ${OBJ}: src/linurv.h src/data.h src/ecall.o: src/syscalls.h src/cpu.o: src/signal-bootstrap-code.h src/syscalls.h: src/syscalls.inc src/gensyscalls.sh sh src/gensyscalls.sh < src/syscalls.inc > $@ .c.o: ${CC} -c -o $@ $< ${CFLAGS} src/signal-bootstrap-code.h: src/signal-bootstrap-code.S ${CROSS}-as -o src/sbc.o src/signal-bootstrap-code.S ${CROSS}-objcopy -O binary src/sbc.o src/sbc.bin hexdump -v -e '16/1 "0x%02x," "\n"' $@ rm -f src/sbc.* .c.elf: ${CROSS}-gcc -g -o $@ $< -Og .S.elf: ${CROSS}-gcc -g -o $@ $< src/data.c src/data.h: src/data.dst (cd src && ../tools/bin/destruct -e little -H data.h -o data.c data.dst)