summaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/multiboot/Makefile
blob: 58be4e0bc5134dfa277a2d05f1981d3a6383586a (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
# If you want run this makefile immediately, then set environment
# variables (CC, LD, AS, OBJDUMP) to path of your cross-compiler.
#
# The best way to build multiboot header is to run the corresponding
# target in the main Makefile, which is in the root of the
# project (.../path/to/os/Makefile)

MULTIBOOT_HEADER = $(ARCH_INCLUDE)/multiboot.h
BARE_MULTIBOOT_HEADER = bare_multiboot.h

.PHONY: all clean

all: $(BARE_MULTIBOOT_HEADER) head.o

head.o: head.s
	$(AS) $< -o $@

$(BARE_MULTIBOOT_HEADER): $(MULTIBOOT_HEADER)
	$(CC) -E -dM -undef -fsyntax-only $(MULTIBOOT_HEADER) > $(BARE_MULTIBOOT_HEADER)
# Delete all defines that have double underscore
	sed -i '/__/d' $(BARE_MULTIBOOT_HEADER)
# Replace "#define" with ".set" on each line
	sed -i 's/#define/.set/g' $(BARE_MULTIBOOT_HEADER)
# Put a comma after the macro name
	sed -i 's/\>/,/2' $(BARE_MULTIBOOT_HEADER)

clean:
	rm -f head.o $(BARE_MULTIBOOT_HEADER)