• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2017 The Android Open Source Project
3#
4# Permission is hereby granted, free of charge, to any person
5# obtaining a copy of this software and associated documentation
6# files (the "Software"), to deal in the Software without
7# restriction, including without limitation the rights to use, copy,
8# modify, merge, publish, distribute, sublicense, and/or sell copies
9# of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be
13# included in all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22# SOFTWARE.
23#
24
25# TODO(zeuthen): This is not invoked by Android build system and is
26# intended to aid users to locally build the EFI application. It would
27# be nice to add gnu-efi/ to external and rewrite this as an
28# Android.mk file.
29
30EFI_CC      = gcc
31EFI_LD      = ld
32EFI_OBJCOPY = objcopy
33AVB         = ../..
34GNUEFI      = /usr/include/efi
35
36EFI_SRC_FILES = \
37    main.c \
38    uefi_avb_sysdeps.c \
39    uefi_avb_ops.c \
40    uefi_avb_util.c \
41    uefi_avb_boot.c \
42	$(AVB)/libavb/avb_chain_partition_descriptor.c \
43    $(AVB)/libavb/avb_crc32.c \
44    $(AVB)/libavb/avb_crypto.c \
45    $(AVB)/libavb/avb_descriptor.c \
46    $(AVB)/libavb/avb_footer.c \
47    $(AVB)/libavb/avb_hash_descriptor.c \
48    $(AVB)/libavb/avb_hashtree_descriptor.c \
49    $(AVB)/libavb/avb_kernel_cmdline_descriptor.c \
50    $(AVB)/libavb/avb_property_descriptor.c \
51    $(AVB)/libavb/avb_rsa.c \
52    $(AVB)/libavb/avb_sha256.c \
53    $(AVB)/libavb/avb_sha512.c \
54    $(AVB)/libavb/avb_slot_verify.c \
55    $(AVB)/libavb/avb_util.c \
56    $(AVB)/libavb/avb_vbmeta_image.c \
57    $(AVB)/libavb/avb_version.c \
58    $(AVB)/libavb_ab/avb_ab_flow.c
59
60EFI_OBJ_FILES   = $(notdir $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(EFI_SRC_FILES))))
61EFI_TARGET      = avb_bootloader.efi
62EFI_SHARED_OBJ  = $(patsubst %.efi,%.so,$(EFI_TARGET))
63
64EFI_CFLAGS = \
65    -DAVB_COMPILATION -DAVB_ENABLE_DEBUG \
66    -DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED \
67    -std=gnu99 \
68	-I$(ANDROID_BUILD_TOP)/system/core/mkbootimg/ \
69    -I$(AVB) \
70    -I$(GNUEFI) \
71    -I$(GNUEFI)/x86_64 \
72    -I$(GNUEFI)/protocol \
73    -fno-stack-protector -fpic \
74    -fshort-wchar -mno-red-zone -Wall \
75    -DEFI_FUNCTION_WRAPPER
76
77EFI_LDFLAGS = \
78    -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared \
79    -Bsymbolic -L /usr/lib/ /usr/lib/crt0-efi-x86_64.o \
80    /usr/lib/elf_x86_64_efi.lds
81
82EFI_LDLIBS  = -lefi -lgnuefi
83
84EFI_OBJCOPY_SECTIONS    = -j .text -j .sdata -j .data -j .dynamic \
85                            -j .dynsym  -j .rel -j .rela -j .reloc
86
87EFI_OBJCOPY_TARGET      = --target=efi-app-x86_64
88
89all: $(EFI_TARGET)
90
91$(EFI_OBJ_FILES): $(EFI_SRC_FILES)
92	$(EFI_CC) $(EFI_CFLAGS) -c $(EFI_SRC_FILES)
93
94$(EFI_SHARED_OBJ): $(EFI_OBJ_FILES)
95	$(EFI_LD) $(EFI_LDFLAGS) $(EFI_OBJ_FILES) -o $@ $(EFI_LDLIBS)
96
97$(EFI_TARGET): $(EFI_SHARED_OBJ)
98	$(EFI_OBJCOPY) $(EFI_OBJCOPY_SECTIONS) $(EFI_OBJCOPY_TARGET) $^ $@
99
100clean:
101	rm -f  $(EFI_OBJ_FILES) $(EFI_SHARED_OBJ) $(EFI_TARGET) *~
102