# # Make.common # Common make rules for building with gnu-efi # # This program is licensed under the terms of the GNU GPL, version 3, # or (at your option) any later version. # You should have received a copy of the GNU General Public License # along with this program. If not, see . EFIINC = /usr/include/efi GNUEFILIB = /usr/lib EFILIB = /usr/lib EFICRT0 = /usr/lib # Comment out above and uncomment below if using locally-compiled GNU-EFI.... #EFIINC = /usr/local/include/efi #GNUEFILIB = /usr/local/lib #EFILIB = /usr/local/lib #EFICRT0 = /usr/local/lib HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) ARCH := $(HOSTARCH) OS = $(shell uname -s) CPPFLAGS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I../include -I../refind -I../libeg -DCONFIG_$(ARCH) -D__MAKEWITH_GNUEFI OPTIMFLAGS = -O2 -fno-strict-aliasing DEBUGFLAGS = -Wall #CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS) CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fno-stack-protector -fpic -fshort-wchar $(DEBUGFLAGS) ASFLAGS = $(ARCH3264) LDFLAGS = -nostdlib DRV_LDFLAGS = prefix = /usr/bin/ CC = $(prefix)gcc AS = $(prefix)as LD = $(prefix)ld AR = $(prefix)ar RANLIB = $(prefix)ranlib OBJCOPY = $(prefix)objcopy ifeq ($(ARCH),ia64) # EFI specs allows only lower floating point partition to be used CFLAGS += -frename-registers -mfixed-range=f32-f127 endif FORMAT = --target=efi-app-$(ARCH) FORMAT_DRIVER = --target=efi-bsdrv-$(ARCH) ifeq ($(ARCH),x86_64) CFLAGS += -DEFI_FUNCTION_WRAPPER -mno-red-zone CPPFLAGS += -DEFIX64 LDFLAGS += -znocombreloc -zdefs ifeq ($(HOSTARCH),ia32) ARCH3264 = -m64 GNUEFILIB := $(GNUEFILIB)64 EFILIB := $(EFILIB)64 EFICRT0 := $(EFICRT0)64 endif endif ifeq ($(ARCH),ia32) CPPFLAGS += -DEFI32 -malign-double LDFLAGS += -znocombreloc -zdefs ifeq ($(HOSTARCH),x86_64) ARCH3264 = -m32 GNUEFILIB := $(GNUEFILIB)32 EFILIB := $(EFILIB)32 EFICRT0 := $(EFICRT0)32 endif endif ifeq ($(ARCH), aarch64) CFLAGS += -fno-stack-check -g -fno-merge-constants -ffreestanding -fno-stack-check CPPFLAGS += -DEFIAARCH64 FORMAT = -O binary FORMAT_DRIVER = -O binary LDFLAGS += --defsym=EFI_SUBSYSTEM=0xa --warn-common --no-undefined --fatal-warnings DRV_LDFLAGS += --defsym=EFI_SUBSYSTEM=0xb --warn-common --no-undefined --fatal-warnings endif CRTOBJS = $(EFICRT0)/crt0-efi-$(ARCH).o ifneq (,$(findstring FreeBSD,$(OS))) ifeq ($(ARCH),x86_64) LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_fbsd_efi.lds else LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds endif else LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds endif LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS) DRV_LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS) LIBS = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name) # general rules %.o: %.c $(CC) $(LOCAL_CPPFLAGS) $(CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@ # rules for EFI applications ifneq (,$(filter %.efi,$(TARGET))) SHLIB_TARGET = $(subst .efi,.so,$(TARGET)) endif # rules for libraries ifneq (,$(filter %.a,$(TARGET))) $(TARGET): $(OBJS) $(AR) cq $@ $(OBJS) endif # utility rules clean: rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib # EOF