Home | History | Annotate | Download | only in uefi
      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 
     30 EFI_CC      = gcc
     31 EFI_LD      = ld
     32 EFI_OBJCOPY = objcopy
     33 AVB         = ../..
     34 GNUEFI      = /usr/include/efi
     35 
     36 EFI_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 
     60 EFI_OBJ_FILES   = $(notdir $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(EFI_SRC_FILES))))
     61 EFI_TARGET      = avb_bootloader.efi
     62 EFI_SHARED_OBJ  = $(patsubst %.efi,%.so,$(EFI_TARGET))
     63 
     64 EFI_CFLAGS = \
     65     -DAVB_COMPILATION -std=gnu99 \
     66 	-I$(ANDROID_BUILD_TOP)/system/core/mkbootimg/ \
     67     -I$(AVB) \
     68     -I$(GNUEFI) \
     69     -I$(GNUEFI)/x86_64 \
     70     -I$(GNUEFI)/protocol \
     71     -fno-stack-protector -fpic \
     72     -fshort-wchar -mno-red-zone -Wall \
     73     -DEFI_FUNCTION_WRAPPER
     74 
     75 EFI_LDFLAGS = \
     76     -nostdlib -znocombreloc -T /usr/lib/elf_x86_64_efi.lds -shared \
     77     -Bsymbolic -L /usr/lib/ /usr/lib/crt0-efi-x86_64.o \
     78     /usr/lib/elf_x86_64_efi.lds
     79 
     80 EFI_LDLIBS  = -lefi -lgnuefi
     81 
     82 EFI_OBJCOPY_SECTIONS    = -j .text -j .sdata -j .data -j .dynamic \
     83                             -j .dynsym  -j .rel -j .rela -j .reloc
     84 
     85 EFI_OBJCOPY_TARGET      = --target=efi-app-x86_64
     86 
     87 all: $(EFI_TARGET)
     88 
     89 $(EFI_OBJ_FILES): $(EFI_SRC_FILES)
     90 	$(EFI_CC) $(EFI_CFLAGS) -c $(EFI_SRC_FILES)
     91 
     92 $(EFI_SHARED_OBJ): $(EFI_OBJ_FILES)
     93 	$(EFI_LD) $(EFI_LDFLAGS) $(EFI_OBJ_FILES) -o $@ $(EFI_LDLIBS)
     94 
     95 $(EFI_TARGET): $(EFI_SHARED_OBJ)
     96 	$(EFI_OBJCOPY) $(EFI_OBJCOPY_SECTIONS) $(EFI_OBJCOPY_TARGET) $^ $@
     97 
     98 clean:
     99 	rm -f  $(EFI_OBJ_FILES) $(EFI_SHARED_OBJ) $(EFI_TARGET) *~
    100