2 # arch/x86/realmode/Makefile
4 # This file is subject to the terms and conditions of the GNU General Public
5 # License. See the file "COPYING" in the main directory of this archive
12 always := realmode.bin
14 realmode-y += header.o
15 realmode-$(CONFIG_X86_32) += reboot_32.o
16 realmode-y += trampoline_$(BITS).o
17 realmode-$(CONFIG_ACPI_SLEEP) += wakeup/wakeup.o
19 targets += $(realmode-y)
21 $(obj)/wakeup/wakeup.o: FORCE
22 $(Q)$(MAKE) $(build)=$(obj)/wakeup $@
24 REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))
26 sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'
28 quiet_cmd_pasyms = PASYMS $@
29 cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \
30 sed $(sed-pasyms) | sort | uniq > $@
32 $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
33 $(call if_changed,pasyms)
35 $(obj)/realmode.lds: $(obj)/pasyms.h
37 LDFLAGS_realmode.elf := --emit-relocs -T
38 CPPFLAGS_realmode.lds += -P -C -I$(obj)
40 $(obj)/realmode.elf: $(obj)/realmode.lds $(REALMODE_OBJS) FORCE
43 OBJCOPYFLAGS_realmode.bin := -O binary
45 $(obj)/realmode.bin: $(obj)/realmode.elf
46 $(call if_changed,objcopy)
48 quiet_cmd_relocs = RELOCS $@
49 cmd_relocs = scripts/x86-relocs --realmode $< > $@
50 $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
51 $(call if_changed,relocs)
53 # ---------------------------------------------------------------------------
55 # How to compile the 16-bit code. Note we always compile for -march=i386,
56 # that way we can complain to the user if the CPU is insufficient.
57 KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
58 -DDISABLE_BRANCH_PROFILING \
59 -Wall -Wstrict-prototypes \
60 -march=i386 -mregparm=3 \
61 -include $(srctree)/$(src)/../../boot/code16gcc.h \
62 -fno-strict-aliasing -fomit-frame-pointer \
63 $(call cc-option, -ffreestanding) \
64 $(call cc-option, -fno-toplevel-reorder,\
65 $(call cc-option, -fno-unit-at-a-time)) \
66 $(call cc-option, -fno-stack-protector) \
67 $(call cc-option, -mpreferred-stack-boundary=2)
68 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__