108f8f979b47f34b93744e5196eb7cadb368891e
[coreboot.git] / src / cpu / x86 / smm / Makefile.inc
1 ##
2 ## This file is part of the coreboot project.
3 ##
4 ## Copyright (C) 2008-2010 coresystems GmbH
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; version 2 of the License.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18 ##
19
20 ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smmrelocate.S
21 ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
22 ramstage-srcs += $(obj)/cpu/x86/smm/smm_wrap
23 endif
24
25 # Use TSEG specific entry point and linker script
26 ifeq ($(CONFIG_SMM_TSEG),y)
27 smm-y += smmhandler_tseg.S
28 SMM_LDFLAGS  := $(LDFLAGS) -pie
29 SMM_LDSCRIPT := smm_tseg.ld
30 else
31 smm-y += smmhandler.S
32 SMM_LDFLAGS  := $(LDFLAGFS)
33 SMM_LDSCRIPT := smm.ld
34 endif
35
36 smm-y += smihandler.c
37 smm-y += smiutil.c
38
39 $(obj)/cpu/x86/smm/smm.o: $$(smm-objs)
40         $(CC) $(LDFLAGS) -nostdlib -r -o $@ $^
41
42 $(obj)/cpu/x86/smm/smm_wrap: $(obj)/cpu/x86/smm/smm.o $(src)/cpu/x86/smm/$(SMM_LDSCRIPT) $(obj)/ldoptions
43         $(CC) $(SMM_LDFLAGS) -nostdlib -nostartfiles -static -o $(obj)/cpu/x86/smm/smm.elf -T $(src)/cpu/x86/smm/$(SMM_LDSCRIPT) $(obj)/cpu/x86/smm/smm.o
44         $(NM) -n $(obj)/cpu/x86/smm/smm.elf | sort > $(obj)/cpu/x86/smm/smm.map
45         $(OBJCOPY) -O binary $(obj)/cpu/x86/smm/smm.elf $(obj)/cpu/x86/smm/smm
46
47 # change to the target path because objcopy will use the path name in its
48 # ELF symbol names.
49 $(obj)/cpu/x86/smm/smm_wrap.ramstage.o: $(obj)/cpu/x86/smm/smm_wrap
50         @printf "    OBJCOPY    $(subst $(obj)/,,$(@))\n"
51         cd $(obj)/cpu/x86/smm; $(OBJCOPY) -I binary smm -O elf32-i386 -B i386 smm_wrap.ramstage.o
52