xref: /linux/arch/x86/realmode/rm/Makefile (revision c9b77ccb52a5c77233b0e557b7d4417b00ef4012)
1#
2# arch/x86/realmode/Makefile
3#
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
6# for more details.
7#
8#
9
10subdir- := wakeup
11
12always := realmode.bin
13
14realmode-y			+= header.o
15realmode-$(CONFIG_X86_32)	+= reboot_32.o
16realmode-y			+= trampoline_$(BITS).o
17realmode-$(CONFIG_ACPI_SLEEP)	+= wakeup/wakeup.o
18
19targets	+= $(realmode-y)
20
21$(obj)/wakeup/wakeup.o: FORCE
22	$(Q)$(MAKE) $(build)=$(obj)/wakeup $@
23
24REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))
25
26sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'
27
28quiet_cmd_pasyms = PASYMS  $@
29      cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \
30		   sed $(sed-pasyms) | sort | uniq > $@
31
32$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
33	$(call if_changed,pasyms)
34
35$(obj)/realmode.lds: $(obj)/pasyms.h
36
37LDFLAGS_realmode.elf := --emit-relocs -T
38CPPFLAGS_realmode.lds += -P -C -I$(obj)
39
40$(obj)/realmode.elf: $(obj)/realmode.lds $(REALMODE_OBJS) FORCE
41	$(call if_changed,ld)
42
43OBJCOPYFLAGS_realmode.bin := -O binary
44
45$(obj)/realmode.bin: $(obj)/realmode.elf
46	$(call if_changed,objcopy)
47
48quiet_cmd_relocs = RELOCS  $@
49      cmd_relocs = scripts/x86-relocs --realmode $< > $@
50$(obj)/realmode.relocs: $(obj)/realmode.elf FORCE
51	$(call if_changed,relocs)
52
53# ---------------------------------------------------------------------------
54
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.
57KBUILD_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)
68KBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
69GCOV_PROFILE := n
70