Skip to content

Commit

Permalink
make: fix possible PATH issues (#1630)
Browse files Browse the repository at this point in the history
Ensure our possibly updated `PATH` variable is picked up by `$(shell …)` invocations when using older (<4.4) make versions.
  • Loading branch information
benoit-pierre committed Jul 11, 2023
1 parent a9da0a1 commit 2c09cd2
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Makefile.defs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
SHELL:=/usr/bin/env bash
# Note: ensure our possibly updated `PATH` variable is picked up by
# `$(shell …)` invocations when using older (<4.4) make versions.
SHELL = env PATH='$(PATH)' bash

# Use ccache in build system by default. Define USE_NO_CCACHE=1 to force disable it.
ifeq ($(USE_NO_CCACHE), 1)
Expand Down Expand Up @@ -315,9 +317,9 @@ LIBTOOLIZE:=$(if $(DARWIN),glibtoolize,libtoolize)
ifndef DARWIN
# TODO: Detect/support libc++ Clang TCs?
ifdef ANDROID
SHARED_STL_LIB:=$(shell PATH='$(PATH)' $(CC) -print-file-name=libc++_shared.so)
SHARED_STL_LIB:=$(shell $(CC) -print-file-name=libc++_shared.so)
else
SHARED_STL_LIB:=$(shell PATH='$(PATH)' $(CC) -print-file-name=libstdc++.so.6)
SHARED_STL_LIB:=$(shell $(CC) -print-file-name=libstdc++.so.6)
endif
endif

Expand Down Expand Up @@ -398,7 +400,7 @@ ifeq ($(TARGET), kobo)
# NOTE: If we only care about Kobos w/ a Touch screen, we're good.
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=hard
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabihf)
ifeq ($(shell $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabihf)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
Expand All @@ -416,28 +418,28 @@ else ifeq ($(TARGET), pocketbook)
# so, ideally, we shouldn't be using this on those newer devices...
COMPAT_CFLAGS:=$(STLABI_COMPAT_CFLAGS) $(PB_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(STLABI_COMPAT_CFLAGS) $(PB_COMPAT_CFLAGS)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS+=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS+=$(UBUNTU_COMPAT_CFLAGS)
endif
else ifeq ($(TARGET), kindle)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
else ifeq ($(TARGET), kindlepw2)
ARM_ARCH:=$(ARMV7_A9_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
else ifeq ($(TARGET), kindle-legacy)
ARM_ARCH:=$(ARMV6_1136_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(MG2K12_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(MG2K12_COMPAT_CXXFLAGS)
endif
Expand Down Expand Up @@ -473,7 +475,7 @@ else ifeq ($(TARGET), sony-prstux)
else ifeq ($(TARGET), cervantes)
ARM_ARCH:=$(ARMV7_GENERIC_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
ifeq ($(shell $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
endif
Expand Down Expand Up @@ -556,7 +558,7 @@ ifeq ($(TARGET), win32)
endif

# this will create a path named build/arm-none-linux-gnueabi or similar
TARGET_MARCHINE:=$(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null)
TARGET_MARCHINE:=$(shell $(CC) -dumpmachine)
ifdef KODEBUG
MACHINE=$(TARGET_MARCHINE)-debug
else
Expand Down Expand Up @@ -595,7 +597,7 @@ else
# Use a CMake toolchain file to avoid all kinds of CMake insanity
export CROSS_TC:=$(CHOST)
ifndef SYSROOT
export SYSROOT:=$(shell PATH='$(PATH)' $(CC) -print-sysroot)
export SYSROOT:=$(shell $(CC) -print-sysroot)
endif
export CROSS_STAGING:=$(CMAKE_STAGING_DIR)
export CMAKE_TCF:=-DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/thirdparty/cmake_modules/CMakeCross.cmake
Expand Down Expand Up @@ -665,7 +667,7 @@ ifndef WIN32
# We only care about that on non-emulated builds (i.e., arm), because compat symbols may be pinned
# to different versions on different arches, and we only account for arm in our patches.
ifndef EMULATE_READER
GLIBC_FILE=$(basename $(notdir $(realpath $(shell PATH='$(PATH)' $(CC) -print-file-name=libc.so.6))))
GLIBC_FILE=$(basename $(notdir $(realpath $(shell $(CC) -print-file-name=libc.so.6))))
GLIBC_VER=$(shell echo $(GLIBC_FILE) | cut -f2 -d'-')
GLIBC_2_22_SORT=$(shell echo -e "$(GLIBC_VER)\n2.22" | sort -V | head -n1)
ifeq ($(GLIBC_2_22_SORT), 2.22)
Expand Down

0 comments on commit 2c09cd2

Please sign in to comment.