summaryrefslogtreecommitdiffstats
path: root/01_exercise/Makefile
blob: 3576c2bdb885e9a111ace5059d50870931d3ad16 (plain) (blame)
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
#!/usr/bin/make
.SUFFIXES:
SRC = bootloader.c
TAR = bootloader.bin
PCK = lab-1.zip

CFLAGS = -m32 -c -Os -march=i686 -ffreestanding -Wall -Werror
LFLAGS = -m elf_i386 -static -Tlinker.ld -nostdlib --nmagic

%.o: %.c
	clang-format -i $^
	$(CC) $(CFLAGS)  $^ -o $@

%.elf: %.o
	$(LD) $(LFLAGS) -o $@ $^

%.bin: %.elf
	objcopy -O binary $^ $@

all: $(TAR)

run: $(TAR)
	qemu-system-x86_64 -drive format=raw,file=$^

pack:
	zip $(PCK) Makefile *.c *.h *.s

clean:
	$(RM) $(RMFILES) $(TAR) $(PCK)