aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: adbf1b319e4a7bee78e2f95c5e519e2338443465 (plain)
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
obj-y = code16.o entry.o main.o string.o printf.o cstart.o fw_cfg.o
obj-y += linuxboot.o malloc.o tables.o hwsetup.o pci.o code32seg.o
obj-y += mptable.o

all-y = bios.bin
all: $(all-y)

CFLAGS := -O2 -g

BIOS_CFLAGS += $(autodepend-flags) -Wall
BIOS_CFLAGS += -m32
BIOS_CFLAGS += -march=i386
BIOS_CFLAGS += -mregparm=3
BIOS_CFLAGS += -fno-stack-protector -fno-delete-null-pointer-checks
BIOS_CFLAGS += -ffreestanding
BIOS_CFLAGS += -mstringop-strategy=rep_byte -minline-all-stringops
BIOS_CFLAGS += -Iinclude
BIOS_CFLAGS += -fno-pic

code32seg.o-cflags = -fno-jump-tables

dummy := $(shell mkdir -p .deps)
autodepend-flags = -MMD -MF .deps/cc-$(patsubst %/,%,$(dir $*))-$(notdir $*).d
-include .deps/*.d

.PRECIOUS: %.o
%.o: %.c
	$(CC) $(CFLAGS) $(BIOS_CFLAGS) $($@-cflags) -c -s $< -o $@
%.o: %.S
	$(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s $< -o $@

bios.bin.elf: $(obj-y) flat.lds
	$(LD) -T flat.lds -o bios.bin.elf $(obj-y)

bios.bin: bios.bin.elf
	objcopy -O binary bios.bin.elf bios.bin

clean:
	rm -f $(obj-y) $(all-y) bios.bin.elf
	rm -f cscope.* tags TAGS
	rm -rf .deps

.PHONY: cscope
cscope:
	rm -f cscope.*
	find . -name "*.[chsS]" -print | sed 's,^\./,,' > cscope.files
	cscope -b -i cscope.files

.PHONY: ctags
ctags:
	rm -f tags
	find . -name "*.[ch]" -exec ctags --append {} +

.PHONY: TAGS
TAGS:
	rm -f TAGS
	find . -name "*.[ch]" -exec etags --append {} +