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