Use filter instead of findstring make function when a whole word needs to match

This commit is contained in:
Pierre Muller 2021-11-25 21:41:35 +00:00
parent 5bddb3a435
commit 7d1b7eda0e

View File

@ -96,7 +96,7 @@ endif
endif endif
ifdef COMSPEC ifdef COMSPEC
ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),) ifneq ($(filter $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
ifndef RUNBATCH ifndef RUNBATCH
RUNBATCH=$(COMSPEC) /C RUNBATCH=$(COMSPEC) /C
endif endif
@ -311,11 +311,11 @@ endif
# Full name of the target, including CPU and OS. For OSs limited # Full name of the target, including CPU and OS. For OSs limited
# to 8.3 we only use the target OS # to 8.3 we only use the target OS
ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) ifneq ($(filter $(OS_SOURCE),$(LIMIT83fs)),)
TARGETSUFFIX=$(OS_TARGET) TARGETSUFFIX=$(OS_TARGET)
SOURCESUFFIX=$(OS_SOURCE) SOURCESUFFIX=$(OS_SOURCE)
else else
ifneq ($(findstring $(OS_TARGET),$(LIMIT83fs)),) ifneq ($(filter $(OS_TARGET),$(LIMIT83fs)),)
TARGETSUFFIX=$(OS_TARGET) TARGETSUFFIX=$(OS_TARGET)
else else
TARGETSUFFIX=$(FULL_TARGET) TARGETSUFFIX=$(FULL_TARGET)
@ -331,14 +331,14 @@ endif
# Check if the Makefile supports this target, but not # Check if the Makefile supports this target, but not
# when the make target is to rebuild the makefile # when the make target is to rebuild the makefile
ifeq ($(findstring makefile,$(MAKECMDGOALS)),) ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),) ifeq ($(filter $(FULL_TARGET),$(MAKEFILETARGETS)),)
$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first) $(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
endif endif
endif endif
# Detect BSD, since BSD uses a slightly different directory hierarchy. # Detect BSD, since BSD uses a slightly different directory hierarchy.
ifneq ($(findstring $(OS_TARGET),$(BSDs)),) ifneq ($(filter $(OS_TARGET),$(BSDs)),)
BSDhier=1 BSDhier=1
endif endif
@ -460,8 +460,8 @@ endif
# Default binutils prefix for cross compile when the # Default binutils prefix for cross compile when the
# crossbindir is not set (except for Darwin) # crossbindir is not set (except for Darwin)
ifneq ($(findstring $(OS_TARGET),darwin iphonesim ios),) ifneq ($(filter $(OS_TARGET),darwin iphonesim ios),)
ifneq ($(findstring $(OS_SOURCE),darwin ios),) ifneq ($(filter $(OS_SOURCE),darwin ios),)
DARWIN2DARWIN=1 DARWIN2DARWIN=1
endif endif
endif endif
@ -598,12 +598,12 @@ endif
# use the source os as default # use the source os as default
ifdef ZIPINSTALL ifdef ZIPINSTALL
# Zipinstall # Zipinstall
ifneq ($(findstring $(OS_TARGET),$(UNIXs)),) ifneq ($(filter $(OS_TARGET),$(UNIXs)),)
UNIXHier=1 UNIXHier=1
endif endif
else else
# Normal install # Normal install
ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),) ifneq ($(filter $(OS_SOURCE),$(UNIXs)),)
UNIXHier=1 UNIXHier=1
endif endif
endif endif
@ -844,7 +844,7 @@ ifeq ($(OS_SOURCE),linux)
# Amd64 to i386? # Amd64 to i386?
ifndef GCCLIBDIR ifndef GCCLIBDIR
ifeq ($(CPU_TARGET),i386) ifeq ($(CPU_TARGET),i386)
ifneq ($(findstring x86_64,$(shell uname -a)),) ifneq ($(filter x86_64,$(shell uname -a)),)
ifeq ($(BINUTILSPREFIX),) ifeq ($(BINUTILSPREFIX),)
GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`) GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`)
else else
@ -867,12 +867,12 @@ CROSSGCCOPT=-m64
endif endif
endif endif
ifeq ($(CPU_TARGET),sparc) ifeq ($(CPU_TARGET),sparc)
ifneq ($(findstring sparc64,$(shell uname -a)),) ifneq ($(filter sparc64,$(shell uname -a)),)
ifeq ($(BINUTILSPREFIX),) ifeq ($(BINUTILSPREFIX),)
GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`) GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`)
else else
# gcc mips seems not to recognize -m32/-m64 # gcc mips seems not to recognize -m32/-m64
ifneq ($(findstring $(FPCFPMAKE_CPU_OPT),mips mipsel),) ifneq ($(filter $(FPCFPMAKE_CPU_OPT),mips mipsel),)
CROSSGCCOPT=-mabi=32 CROSSGCCOPT=-mabi=32
else else
CROSSGCCOPT=-m32 CROSSGCCOPT=-m32
@ -889,19 +889,19 @@ ifeq ($(CPU_TARGET),$(FPCFPMAKE_CPU_TARGET))
# In that case use GCCLIBDIR value for FPCMAKEGCCLIBDIR # In that case use GCCLIBDIR value for FPCMAKEGCCLIBDIR
FPCMAKEGCCLIBDIR:=$(GCCLIBDIR) FPCMAKEGCCLIBDIR:=$(GCCLIBDIR)
else else
ifneq ($(findstring $(FPCFPMAKE_CPU_TARGET),aarch64 powerpc64 riscv64 sparc64 x86_64),) ifneq ($(filter $(FPCFPMAKE_CPU_TARGET),aarch64 powerpc64 riscv64 sparc64 x86_64),)
FPCMAKE_CROSSGCCOPT=-m64 FPCMAKE_CROSSGCCOPT=-m64
else else
ifneq ($(findstring $(FPCFPMAKE_CPU_OPT),mips64 mips64el),) ifneq ($(filter $(FPCFPMAKE_CPU_OPT),mips64 mips64el),)
FPCMAKE_CROSSGCCOPT=-mabi=64 FPCMAKE_CROSSGCCOPT=-mabi=64
else else
ifneq ($(findstring $(FPCFPMAKE_CPU_OPT),mips mipsel),) ifneq ($(filter $(FPCFPMAKE_CPU_OPT),mips mipsel),)
FPCMAKE_CROSSGCCOPT=-mabi=32 FPCMAKE_CROSSGCCOPT=-mabi=32
else else
ifneq ($(findstring $(FPCFPMAKE_CPU_OPT),riscv64),) ifeq ($(FPCFPMAKE_CPU_OPT),riscv64)
FPCMAKE_CROSSGCCOPT=-mabi=lp64 FPCMAKE_CROSSGCCOPT=-mabi=lp64
else else
ifneq ($(findstring $(FPCFPMAKE_CPU_OPT),riscv32),) ifeq ($(FPCFPMAKE_CPU_OPT),riscv32)
FPCMAKE_CROSSGCCOPT=-mabi=ilp32 FPCMAKE_CROSSGCCOPT=-mabi=ilp32
else else
FPCMAKE_CROSSGCCOPT=-m32 FPCMAKE_CROSSGCCOPT=-m32
@ -1143,7 +1143,7 @@ IMPORTLIBPREFIX=imp
endif endif
# Darwin # Darwin
ifneq ($(findstring $(OS_TARGET),darwin iphonesim ios),) ifneq ($(filter $(OS_TARGET),darwin iphonesim ios),)
BATCHEXT=.sh BATCHEXT=.sh
EXEEXT= EXEEXT=
HASSHAREDLIB=1 HASSHAREDLIB=1
@ -1252,7 +1252,7 @@ endif
# For 8.3 limited OS's the short suffixes # For 8.3 limited OS's the short suffixes
# Otherwise use the full source/target names # Otherwise use the full source/target names
ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) ifneq ($(filter $(OS_SOURCE),$(LIMIT83fs)),)
FPCMADE=fpcmade.$(SHORTSUFFIX) FPCMADE=fpcmade.$(SHORTSUFFIX)
ZIPSUFFIX=$(SHORTSUFFIX) ZIPSUFFIX=$(SHORTSUFFIX)
ZIPCROSSPREFIX= ZIPCROSSPREFIX=
@ -1521,9 +1521,9 @@ else
# if we are compiling natively on aarch64-darwin and if -/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk exists, # if we are compiling natively on aarch64-darwin and if -/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk exists,
# add it to the compiler command line # add it to the compiler command line
ifeq ($(OS_TARGET),$(OS_SOURCE)) ifeq ($(OS_TARGET),$(OS_SOURCE))
ifneq ($(findstring $(OS_TARGET),darwin),) ifeq ($(OS_TARGET),darwin)
# so far the only tested one # so far the only tested one
ifneq ($(findstring $(CPU_TARGET),aarch64),) ifeq ($(CPU_TARGET),aarch64)
ifneq ($(wildcard /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk),) ifneq ($(wildcard /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk),)
override FPCOPT+=-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk override FPCOPT+=-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
endif endif
@ -1538,8 +1538,8 @@ endif
# create always pic'ed code on x86_64, mips and mipsel # create always pic'ed code on x86_64, mips and mipsel
# on unix-like systems # on unix-like systems
ifneq ($(findstring $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),) ifneq ($(filter $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),)
ifneq ($(findstring $(CPU_TARGET),x86_64 mips mipsel riscv64 powerpc64),) ifneq ($(filter $(CPU_TARGET),x86_64 mips mipsel riscv64 powerpc64),)
override FPCOPT+=-Cg override FPCOPT+=-Cg
endif endif
endif endif
@ -1609,10 +1609,10 @@ override COMPILER:=$(strip $(FPC) $(FPCOPT))
# also call ppas if with command option -s # also call ppas if with command option -s
# but only if the FULL_SOURCE and FULL_TARGET are equal # but only if the FULL_SOURCE and FULL_TARGET are equal
# or if -sh is used # or if -sh is used
ifneq (,$(findstring -sh ,$(COMPILER))) ifneq (,$(filter -sh,$(COMPILER)))
UseEXECPPAS=1 UseEXECPPAS=1
endif endif
ifneq (,$(findstring -s ,$(COMPILER))) ifneq (,$(filter -s,$(COMPILER)))
ifeq ($(FULL_SOURCE),$(FULL_TARGET)) ifeq ($(FULL_SOURCE),$(FULL_TARGET))
UseEXECPPAS=1 UseEXECPPAS=1
endif endif
@ -2344,7 +2344,7 @@ endif
# LCL Platform # LCL Platform
ifndef LCL_PLATFORM ifndef LCL_PLATFORM
ifneq ($(findstring $(OS_TARGET),win32 win64),) ifneq ($(filter $(OS_TARGET),win32 win64),)
LCL_PLATFORM=win32 LCL_PLATFORM=win32
else else
LCL_PLATFORM=gtk LCL_PLATFORM=gtk