1 CURRENT_MAKEFILE
:= $(realpath
$(word $(words $(MAKEFILE_LIST
)),$(MAKEFILE_LIST
)))
2 SRC_DIR
:= $(dir $(CURRENT_MAKEFILE
))
3 TOPSRC_DIR
:= $(SRC_DIR
)/..
/..
6 all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin
7 # Dummy command so that make thinks it has done something
10 include ..
/..
/config-host.mak
12 quiet-command
= $(if
$(V
),$1,$(if
$(2),@printf
" %-7s %s\n" $2 $3 && $1, @
$1))
13 cc-option
= $(if
$(shell $(CC
) $1 -S
-o
/dev
/null
-xc
/dev
/null
>/dev
/null
2>&1 && echo OK
), $1, $2)
15 # Compiling with no optimization creates ROMs that are too large
16 ifeq ($(lastword
$(filter -O
%, -O0
$(CFLAGS
))),-O0
)
17 override CFLAGS
+= -O2
19 override CFLAGS
+= -march
=i486
21 # Flags for dependency generation
22 override CPPFLAGS
+= -MMD
-MP
-MT
$@
-MF
$(@D
)/$(*F
).d
24 override CFLAGS
+= $(filter -W
%, $(QEMU_CFLAGS
))
25 override CFLAGS
+= $(CFLAGS_NOPIE
) -ffreestanding
-I
$(TOPSRC_DIR
)/include
26 override CFLAGS
+= $(call cc-option
, -fno-stack-protector
)
27 override CFLAGS
+= $(call cc-option
, -m16
)
29 ifeq ($(filter -m16
, $(CFLAGS
)),)
30 # Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
31 # On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with
32 # respect to the rest of the code. clang does not have -fno-toplevel-reorder,
33 # but it places all asm blocks at the beginning and we're relying on it for
34 # the option ROM header. So just force clang not to use the integrated
35 # assembler, which doesn't support .code16gcc.
36 override CFLAGS
+= $(call cc-option
, -fno-toplevel-reorder
)
37 override CFLAGS
+= $(call cc-option
, -no-integrated-as
)
38 override CFLAGS
+= -m32
-include $(SRC_DIR
)/code16gcc.h
42 override ASFLAGS
+= -32
43 override CFLAGS
+= $(call cc-option
, $(Wa
)-32)
46 LD_I386_EMULATION ?
= elf_i386
47 override LDFLAGS
= -m
$(LD_I386_EMULATION
) -T
$(SRC_DIR
)/flat.lds
48 override LDFLAGS
+= $(LDFLAGS_NOPIE
)
50 all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin
52 pvh.img
: pvh.o pvh_main.o
55 $(call quiet-command
,$(CPP
) $(CPPFLAGS
) -c
-o
- $< |
$(AS
) $(ASFLAGS
) -o
$@
,"AS","$@")
58 $(call quiet-command
,$(CC
) $(CPPFLAGS
) $(CFLAGS
) -c
$< -o
$@
,"CC","$@")
61 $(call quiet-command
,$(LD
) $(LDFLAGS
) -s
-o
$@
$^
,"BUILD","$@")
64 $(call quiet-command
,$(OBJCOPY
) -O binary
-j .text
$< $@
,"BUILD","$@")
67 $(call quiet-command
,$(PYTHON
) $(TOPSRC_DIR
)/scripts
/signrom.py
$< $@
,"SIGN","$@")
69 include $(wildcard *.d
)
72 rm -f
*.o
*.d
*.raw
*.img
*.bin
*~
74 # suppress auto-removal of intermediate files