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 od-bb:
39 ${CROSS}-objdump -d rootfs/bb/bin/busybox | less
41 run: linurv ${PROGS}
42 mkdir -p rootfs/bin
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
48 distclean: clean
49 (cd tools; ${MAKE} distclean)
51 clean:
52 rm -f linurv src/*.o examples/*.elf *.core src/syscalls.h src/signal-bootstrap-code.h src/sbc.* src/data.[ch]
53 rm -rf rootfs
55 install: linurv
56 mkdir -p ${DESTDIR}${PREFIX}/bin
57 cp -f linurv ${DESTDIR}${PREFIX}/bin/
59 linurv: ${OBJ}
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 > $@
70 .c.o:
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 >$@
77 rm -f src/sbc.*
79 .c.elf:
80 ${CROSS}-gcc -g -o $@ $< -Og
82 .S.elf:
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)