Blob


1 .SUFFIXES:
2 .SUFFIXES: .c .S .o .elf
4 TOP != pwd
5 PREFIX = /usr/local
6 TARGET = riscv64-unknown-linux-musl
7 CROSS = ./tools/bin/${TARGET}
9 include config.mk
11 COPT = -g -O2
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
16 T = signal
17 PROGS = examples/test.elf \
18 examples/echo.elf \
19 examples/cat.elf \
20 examples/hello.elf \
21 examples/asm.elf \
22 examples/signal.elf \
23 examples/true.elf
25 all: linurv ${PROGS}
27 config:
28 @echo "CC=${CC}"
29 @echo "CXX=${CXX}"
30 @echo "SUDO=${SUDO}"
31 @echo "CFLAGS=${CFLAGS}"
32 @echo "LDFLAGS=${LDFLAGS}"
33 @echo "CHROOT=${CHROOT}"
35 od: examples/$T.elf
36 ${CROSS}-objdump -d examples/$T.elf | less
38 run: linurv ${PROGS}
39 mkdir -p rootfs/bin
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
45 distclean: clean
46 (cd tools; ${MAKE} distclean)
48 clean:
49 rm -f linurv src/*.o examples/*.elf *.core src/syscalls.h src/signal-bootstrap-code.h src/sbc.* src/data.[ch]
50 rm -rf rootfs
52 install: linurv
53 mkdir -p ${DESTDIR}${PREFIX}/bin
54 cp -f linurv ${DESTDIR}${PREFIX}/bin/
56 linurv: ${OBJ}
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 > $@
67 .c.o:
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 >$@
74 rm -f src/sbc.*
76 .c.elf:
77 ${CROSS}-gcc -g -o $@ $< -Og
79 .S.elf:
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)