3 # Common make rules for building with gnu-efi
6 # This program is licensed under the terms of the GNU GPL, version 3,
7 # or (at your option) any later version.
8 # You should have received a copy of the GNU General Public License
9 # along with this program. If not, see <http://www.gnu.org/licenses/>.
11 EFIINC = /usr/include/efi
16 # Comment out above and uncomment below if using locally-compiled GNU-EFI....
17 #EFIINC = /usr/local/include/efi
18 #GNUEFILIB = /usr/local/lib
19 #EFILIB = /usr/local/lib
20 #EFICRT0 = /usr/local/lib
22 HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
24 OS = $(shell uname -s)
25 CPPFLAGS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I../include -I../refind -I../libeg -DCONFIG_$(ARCH) -D__MAKEWITH_GNUEFI
27 OPTIMFLAGS = -O2 -fno-strict-aliasing
29 #CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
30 CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fno-stack-protector -fpic -fshort-wchar $(DEBUGFLAGS)
40 RANLIB = $(prefix)ranlib
41 OBJCOPY = $(prefix)objcopy
44 # EFI specs allows only lower floating point partition to be used
45 CFLAGS += -frename-registers -mfixed-range=f32-f127
48 FORMAT = --target=efi-app-$(ARCH)
49 FORMAT_DRIVER = --target=efi-bsdrv-$(ARCH)
52 CFLAGS += -DEFI_FUNCTION_WRAPPER -mno-red-zone
54 LDFLAGS += -znocombreloc -zdefs
56 ifeq ($(HOSTARCH),ia32)
59 GNUEFILIB := $(GNUEFILIB)64
61 EFICRT0 := $(EFICRT0)64
66 CPPFLAGS += -DEFI32 -malign-double
67 LDFLAGS += -znocombreloc -zdefs
69 ifeq ($(HOSTARCH),x86_64)
72 GNUEFILIB := $(GNUEFILIB)32
74 EFICRT0 := $(EFICRT0)32
78 ifeq ($(ARCH), aarch64)
79 CFLAGS += -fno-stack-check -g -fno-merge-constants -ffreestanding -fno-stack-check
80 CPPFLAGS += -DEFIAARCH64
82 FORMAT_DRIVER = -O binary
83 LDFLAGS += --defsym=EFI_SUBSYSTEM=0xa --warn-common --no-undefined --fatal-warnings
84 DRV_LDFLAGS += --defsym=EFI_SUBSYSTEM=0xb --warn-common --no-undefined --fatal-warnings
87 CRTOBJS = $(EFICRT0)/crt0-efi-$(ARCH).o
89 ifneq (,$(findstring FreeBSD,$(OS)))
91 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_fbsd_efi.lds
93 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
96 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
99 LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS)
100 DRV_LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS)
101 LIBS = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
107 $(CC) $(LOCAL_CPPFLAGS) $(CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@
109 # rules for EFI applications
111 ifneq (,$(filter %.efi,$(TARGET)))
113 SHLIB_TARGET = $(subst .efi,.so,$(TARGET))
117 # rules for libraries
119 ifneq (,$(filter %.a,$(TARGET)))
129 rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib