Blame


1 28b38de8 2024-02-18 benni .SUFFIXES:
2 28b38de8 2024-02-18 benni .SUFFIXES: .c .S .o .elf
3 074dbafb 2024-02-18 benni
4 9c836066 2024-04-07 benni TOP != pwd
5 52a430f3 2024-02-18 benni PREFIX = /usr/local
6 d83e2c2b 2024-02-19 benni TARGET = riscv64-unknown-linux-musl
7 d83e2c2b 2024-02-19 benni CROSS = ./tools/bin/${TARGET}
8 3528385d 2024-04-06 benni
9 9c836066 2024-04-07 benni include config.mk
10 3528385d 2024-04-06 benni
11 3528385d 2024-04-06 benni COPT = -g -O2
12 fd7369d0 2024-06-11 benni CFLAGS = ${CFLAGS_OS} ${COPT} -std=c2x -Wall -Wextra
13 3528385d 2024-04-06 benni LDFLAGS = ${LDFLAGS_OS} -lpthread
14 3528385d 2024-04-06 benni
15 cd0438ce 2024-07-05 benni OBJ = src/linurv.o src/ecall.o src/cpu.o src/exec.o src/signal.o src/data.o
16 16107e2e 2024-06-16 benni T = signal
17 e46639b3 2024-02-20 benni PROGS = examples/test.elf \
18 e46639b3 2024-02-20 benni examples/echo.elf \
19 b4cef989 2024-02-21 benni examples/cat.elf \
20 6bf04703 2024-04-05 benni examples/hello.elf \
21 16107e2e 2024-06-16 benni examples/asm.elf \
22 310548d2 2024-07-06 benni examples/signal.elf \
23 310548d2 2024-07-06 benni examples/true.elf
24 074dbafb 2024-02-18 benni
25 80a2e72f 2024-04-15 benni all: linurv ${PROGS}
26 074dbafb 2024-02-18 benni
27 d81441f0 2024-07-16 benni config:
28 d81441f0 2024-07-16 benni @echo "CC=${CC}"
29 d81441f0 2024-07-16 benni @echo "CXX=${CXX}"
30 d81441f0 2024-07-16 benni @echo "SUDO=${SUDO}"
31 d81441f0 2024-07-16 benni @echo "CFLAGS=${CFLAGS}"
32 d81441f0 2024-07-16 benni @echo "LDFLAGS=${LDFLAGS}"
33 d81441f0 2024-07-16 benni @echo "CHROOT=${CHROOT}"
34 d81441f0 2024-07-16 benni
35 e46639b3 2024-02-20 benni od: examples/$T.elf
36 e46639b3 2024-02-20 benni ${CROSS}-objdump -d examples/$T.elf | less
37 a67f2fcd 2024-02-20 benni
38 1e8e3702 2024-07-23 benni od-bb:
39 1e8e3702 2024-07-23 benni ${CROSS}-objdump -d rootfs/bb/bin/busybox | less
40 1e8e3702 2024-07-23 benni
41 80a2e72f 2024-04-15 benni run: linurv ${PROGS}
42 e46639b3 2024-02-20 benni mkdir -p rootfs/bin
43 292ece60 2024-07-06 benni cp -f linurv rootfs/bin/
44 292ece60 2024-07-06 benni for f in ${PROGS:.elf=}; do cp -f $$f.elf rootfs/bin/$$(basename "$$f"); done
45 b4cef989 2024-02-21 benni cp -f test.txt rootfs/
46 292ece60 2024-07-06 benni ${CHROOT} rootfs /bin/linurv -v /bin/$T
47 e46639b3 2024-02-20 benni
48 3528385d 2024-04-06 benni distclean: clean
49 3528385d 2024-04-06 benni (cd tools; ${MAKE} distclean)
50 3528385d 2024-04-06 benni
51 074dbafb 2024-02-18 benni clean:
52 cd0438ce 2024-07-05 benni rm -f linurv src/*.o examples/*.elf *.core src/syscalls.h src/signal-bootstrap-code.h src/sbc.* src/data.[ch]
53 52a430f3 2024-02-18 benni rm -rf rootfs
54 074dbafb 2024-02-18 benni
55 80a2e72f 2024-04-15 benni install: linurv
56 52a430f3 2024-02-18 benni mkdir -p ${DESTDIR}${PREFIX}/bin
57 80a2e72f 2024-04-15 benni cp -f linurv ${DESTDIR}${PREFIX}/bin/
58 074dbafb 2024-02-18 benni
59 80a2e72f 2024-04-15 benni linurv: ${OBJ}
60 28b38de8 2024-02-18 benni ${CC} -o $@ ${OBJ} ${LDFLAGS}
61 28b38de8 2024-02-18 benni
62 764c5620 2024-07-05 benni ${OBJ}: src/linurv.h src/data.h
63 a8ceaca4 2024-02-20 benni src/ecall.o: src/syscalls.h
64 52a430f3 2024-02-18 benni
65 16107e2e 2024-06-16 benni src/cpu.o: src/signal-bootstrap-code.h
66 16107e2e 2024-06-16 benni
67 d68efc51 2024-06-15 benni src/syscalls.h: src/syscalls.inc src/gensyscalls.sh
68 d68efc51 2024-06-15 benni sh src/gensyscalls.sh < src/syscalls.inc > $@
69 52a430f3 2024-02-18 benni
70 ced16aa5 2024-04-06 benni .c.o:
71 28b38de8 2024-02-18 benni ${CC} -c -o $@ $< ${CFLAGS}
72 28b38de8 2024-02-18 benni
73 16107e2e 2024-06-16 benni src/signal-bootstrap-code.h: src/signal-bootstrap-code.S
74 16107e2e 2024-06-16 benni ${CROSS}-as -o src/sbc.o src/signal-bootstrap-code.S
75 16107e2e 2024-06-16 benni ${CROSS}-objcopy -O binary src/sbc.o src/sbc.bin
76 16107e2e 2024-06-16 benni hexdump -v -e '16/1 "0x%02x," "\n"' <src/sbc.bin >$@
77 16107e2e 2024-06-16 benni rm -f src/sbc.*
78 28b38de8 2024-02-18 benni
79 a8ceaca4 2024-02-20 benni .c.elf:
80 6bf04703 2024-04-05 benni ${CROSS}-gcc -g -o $@ $< -Og
81 6bf04703 2024-04-05 benni
82 6bf04703 2024-04-05 benni .S.elf:
83 6bf04703 2024-04-05 benni ${CROSS}-gcc -g -o $@ $<
84 cd0438ce 2024-07-05 benni
85 cd0438ce 2024-07-05 benni src/data.c src/data.h: src/data.dst
86 cd0438ce 2024-07-05 benni (cd src && ../tools/bin/destruct -e little -H data.h -o data.c data.dst)