Skip to content

Commit 875a555

Browse files
committed
make: Make TOPDIR and CROSS_COMPILE work right
Signed-off-by: Peter Jones <pjones@redhat.com>
1 parent 9190885 commit 875a555

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
VERSION = 1
22
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
3+
4+
ifeq ($(MAKELEVEL),0)
5+
TOPDIR ?= $(shell pwd)
6+
endif
7+
ifeq ($(TOPDIR),)
8+
override TOPDIR := $(shell pwd)
9+
endif
10+
override TOPDIR := $(abspath $(TOPDIR))
11+
VPATH = $(TOPDIR)
12+
export TOPDIR
13+
14+
CROSS_COMPILE =
315
DATADIR := /usr/share
416
LIBDIR := /usr/lib64
5-
GNUEFIDIR ?= gnu-efi/
6-
CC = gcc
17+
GNUEFIDIR ?= $(TOPDIR)/gnu-efi/
18+
COMPILER = gcc
19+
CC = $(CROSS_COMPILE)$(COMPILER)
720
CFLAGS ?= -O0 -g3
821
BUILDFLAGS := $(CFLAGS) -fPIC -Werror -Wall -Wextra -fshort-wchar \
922
-fno-merge-constants -ffreestanding \
@@ -15,14 +28,14 @@ CCLDFLAGS ?= -nostdlib -fPIC -Wl,--warn-common \
1528
-Wl,--no-undefined -Wl,--fatal-warnings \
1629
-Wl,-shared -Wl,-Bsymbolic -L$(LIBDIR) -L$(GNUEFIDIR) \
1730
-Wl,--build-id=sha1 -Wl,--hash-style=sysv
18-
LD = ld
19-
OBJCOPY = objcopy
31+
LD = $(CROSS_COMPILE)ld
32+
OBJCOPY = $(CROSS_COMPILE)objcopy
2033
OBJCOPY_GTE224 = $(shell expr $$($(OBJCOPY) --version |grep "^GNU objcopy" | sed 's/^.*\((.*)\|version\) //g' | cut -f1-2 -d.) \>= 2.24)
2134

2235
dbsize = \
2336
$(if $(filter-out undefined,$(origin VENDOR_DB_FILE)),$(shell /usr/bin/stat --printf="%s" $(VENDOR_DB_FILE)),0)
2437

25-
DB_ADDRESSES=$(shell objdump -h certmule.so | ./find-addresses dbsz=$(call dbsize))
38+
DB_ADDRESSES=$(shell objdump -h certmule.so | $(TOPDIR)/find-addresses dbsz=$(call dbsize))
2639
DB_ADDRESS=$(word $(2), $(call DB_ADDRESSES, $(1)))
2740

2841
DB_SECTION_ALIGN = 512

0 commit comments

Comments
 (0)