-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (47 loc) · 1.42 KB
/
Makefile
File metadata and controls
61 lines (47 loc) · 1.42 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
OBJS=boot.o main.o printf.o subr_prf.o vsprintf.o
LDS=taroo.lds
CC=gcc
HOSTCC=gcc
LD=ld
OBJCOPY=objcopy
LDS=taroo.lds
CFLAGS=-c -fno-builtin -g -O2 -I. -pipe -Wall -Werror -nostdinc
LDFLAGS=-nostdlib -Wl,-e,_start -Wl,-T./taroo.lds -Wl,--build-id=none -Wl,-Ttext=0x100000
all: taroo.vdi taroo.img
taroo.vdi: taroo.bin
@dd if=$^ of=$^.dsk ibs=1G conv=sync,sparse
@rm -f $@
@vboxmanage convertfromraw $^.dsk $@ --uuid 6fc5e387-dcc8-4578-be77-fa8aa7dc8a74
imghdr: imghdr.c
$(HOSTCC) -O2 $^ -o $@
taroo.img: taroo.bin
@dd if=taroo.bin of=$@ bs=8M count=1 conv=sync
taroo.bin: taroo.elf imghdr
@$(OBJCOPY) -O binary taroo.elf $@
@./imghdr $@
taroo.elf: $(OBJS)
@echo -n "Linking $@ --- "
@$(CC) -o $@ $(LDFLAGS) $(OBJS)
@echo "Done"
clean:
@rm -f imghdr taroo.elf taroo.bin $(OBJS) $(OBJS:.o=.d) taroo.bin.dsk taroo.vdi
%.o: %.c
@echo -n "Building $@ --- "
@$(CC) -c $(CFLAGS) $*.c -o $*.o
@$(CC) -MM $(CFLAGS) $*.c > $*.d
@cp -f $*.d $*.d.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' -e 's/^.*\.o:/&/' >> $*.d
@rm -f $*.d.tmp
@sed -i -e 's/^.*\.o:/&/' $*.d
@echo "Done"
%.o: %.S
@echo -n "Building $@ --- "
@$(CC) -c $(CFLAGS) $*.S -o $*.o
@$(CC) -MM $(CFLAGS) $*.S > $*.d
@cp -f $*.d $*.d.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' -e 's/^.*\.o:/&/' >> $*.d
@rm -f $*.d.tmp
@sed -i -e 's/^.*\.o:/&/' $*.d
@echo "Done"