-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.mak
45 lines (33 loc) · 853 Bytes
/
common.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.PHONY: clean
vpath %.rs interrupts/
RUSTFLAGS += --target=../i686-unknown-elf.json -L. -L${DEPDIR} -g -C opt-level=3 -C panic=abort
RUSTC = rustc
RUSTFILES = $(notdir $(wildcard *.rs) $(wildcard interrupts/*.rs))
SFILES = $(notdir $(wildcard *.S) $(wildcard *.s))
OFILES = $(subst .s,.o,$(subst .S,.o,$(SFILES)))
BOOTFILES = $(sort $(filter boot%,${OFILES}))
NON_BOOTFILES = $(filter-out boot%,${OFILES})
AFILES = libasmcode.a librustcode.a
AR = ar
LD = ld
OBJCOPY = objcopy
DD = dd
CC = gcc
ASFLAGS += -m32
%.o: %.S
${CC} ${ASFLAGS} -c -o $@ $<
%.o: %.s
${CC} ${ASFLAGS} -c -o $@ $<
libasmcode.a: ${OFILES}
${AR} cr $@ ${NON_BOOTFILES}
librustcode.a: ${RUSTFILES}
${RUSTC} ${RUSTFLAGS} lib.rs
%.bin: %
${OBJCOPY} -O binary $< $@
%.img: %.bin
${DD} if=$< of=$@ bs=512 conv=sync
clean::
rm -f *.o
rm -f *.a
rm -f *.img
rm -f *.bin