| 1 |
NAME = efibootmgr |
| 2 |
prefix ?= /usr |
| 3 |
libdir ?= $(prefix)/lib64 |
| 4 |
datadir ?= $(prefix)/share |
| 5 |
mandir ?= $(datadir)/man |
| 6 |
includedir ?= $(prefix)/include |
| 7 |
bindir ?= $(prefix)/bin |
| 8 |
sbindir ?= $(prefix)/sbin |
| 9 |
localedir ?= $(datadir)/locale/ |
| 10 |
PCDIR ?= $(libdir)/pkgconfig |
| 11 |
DESTDIR ?= |
| 12 |
ifneq ($(origin EXTRALIBDIRS),undefined) |
| 13 |
override EXTRALIBDIR := $(foreach dir,$(EXTRALIBDIRS),-L$(dir)) |
| 14 |
endif |
| 15 |
ifneq ($(origin EXTRAINCDIRS),undefined) |
| 16 |
override EXTRAINCDIR := $(foreach dir,$(EXTRAINCDIRS),-I$(dir)) |
| 17 |
endif |
| 18 |
|
| 19 |
EFIDIR ?= $(shell x=$$(which --skip-alias --skip-functions git 2>/dev/null) ; [ -n "$$x" ] && git config --get efibootmgr.efidir) |
| 20 |
ifeq ($(EFIDIR),) |
| 21 |
EFIDIR_ERROR = $(error EFIDIR or .gitconfig efibootmgr.efidir must be set to this distro's reserved EFI System Partition subdirectory name) |
| 22 |
endif |
| 23 |
EFI_LOADER := grub.efi |
| 24 |
|
| 25 |
INSTALL ?= install |
| 26 |
CROSS_COMPILE ?= |
| 27 |
PKG_CONFIG = $(CROSS_COMPILE)pkg-config |
| 28 |
CC := $(if $(filter default,$(origin CC)),$(CROSS_COMPILE)gcc,$(CC)) |
| 29 |
CCLD := $(if $(filter undefined,$(origin CCLD)),$(CC),$(CCLD)) |
| 30 |
CFLAGS ?= -O2 -g -flto |
| 31 |
AR := $(CROSS_COMPILE)gcc-ar |
| 32 |
NM := $(CROSS_COMPILE)gcc-nm |
| 33 |
RANLIB := $(CROSS_COMPILE)gcc-ranlib |
| 34 |
|
| 35 |
PKGS = |
| 36 |
|
| 37 |
SUBDIR_CFLAGS ?= |
| 38 |
clang_cflags = |
| 39 |
gcc_cflags = |
| 40 |
cflags = $(EXTRALIBDIR) $(EXTRAINCDIR) $(CFLAGS) $(SUBDIR_CFLAGS) \ |
| 41 |
-Werror -Wall -Wextra -Wsign-compare -Wstrict-aliasing \ |
| 42 |
-std=gnu11 -fPIC \ |
| 43 |
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DLOCALEDIR=\"$(localedir)\" \ |
| 44 |
-DEFIBOOTMGR_VERSION="\"$(VERSION)\"" \ |
| 45 |
-DDEFAULT_LOADER=\"\\\\EFI\\\\$(EFIDIR)\\\\$(EFI_LOADER)\" \ |
| 46 |
$(if $(findstring clang,$(CC)),$(clang_cflags),) \ |
| 47 |
$(if $(findstring gcc,$(CC)),$(gcc_cflags),) \ |
| 48 |
$(call pkg-config-cflags) |
| 49 |
clang_ccldflags = |
| 50 |
gcc_ccldflags = -fno-merge-constants \ |
| 51 |
-Wl,--fatal-warnings,--no-allow-shlib-undefined \ |
| 52 |
-Wl,-O2 -Wl,--no-undefined-version |
| 53 |
ccldflags = $(cflags) $(CCLDFLAGS) $(LDFLAGS) \ |
| 54 |
$(if $(findstring clang,$(CCLD)),$(clang_ccldflags),) \ |
| 55 |
$(if $(findstring gcc,$(CCLD)),$(gcc_ccldflags),) \ |
| 56 |
$(call pkg-config-ldflags) |
| 57 |
CPPFLAGS?= |
| 58 |
SOFLAGS=-shared |
| 59 |
LDLIBS=$(foreach lib,$(LIBS),-l$(lib)) $(call pkg-config-ldlibs) |
| 60 |
|
| 61 |
.PHONY: check_efidir_error |
| 62 |
check_efidir_error : ; $(EFIDIR_ERROR) $(info Building with EFIDIR as $(EFIDIR)) |
| 63 |
|
| 64 |
COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master) |