diff options
Diffstat (limited to 'makefiles/Makefile.tools')
-rw-r--r-- | makefiles/Makefile.tools | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools index 86fac4c..40e4d10 100644 --- a/makefiles/Makefile.tools +++ b/makefiles/Makefile.tools @@ -121,12 +121,17 @@ ifeq ($(BUILD),$(HOST)) else # Cross compiling - # Make first-stab at identity of CC - CC__ := $(CC) - # Improve our guess at the identity of CC - # (only if CC was not specified by the user) - ifeq ($(origin CC),default) - CC__ := $(HOST)-gcc + ifneq ($(NS_ENV_CC),) + # If we have a CC specified by env.sh, start with that + CC__ := $(NS_ENV_CC) + else + # Make first-stab at identity of CC + CC__ := $(CC) + # Improve our guess at the identity of CC + # (only if CC was not specified by the user) + ifeq ($(origin CC),default) + CC__ := $(HOST)-gcc + endif endif # Search the path for the compiler @@ -139,7 +144,7 @@ else else CC__ := $(realpath $(toolpath_)) toolpath_ := $(dir $(CC__)) - toolprefix_ := $(subst :,/,$(dir $(subst -,/,$(subst /,:,$(CC__))))) + toolprefix_ := $(subst :,/,$(subst /,-,$(patsubst %/,%,$(dir $(subst -,/,$(subst /,:,$(CC__))))))) ifeq ($(origin AR),default) AR__ := $(toolprefix_)-ar endif @@ -153,26 +158,35 @@ else GCCSDK_INSTALL_ENV := $(realpath $(toolpath_)../../env) endif - ifeq ($(HOST),arm-unknown-riscos) + ifeq ($(findstring -riscos,$(HOST)),-riscos) # Cross compiling for RISC OS - CMHG ?= PATH="$(GCCSDK_INSTALL_CROSSBIN):$(PATH)" $(GCCSDK_INSTALL_CROSSBIN)/cmunge + ifeq ($(findstring gnueabi,$(HOST)),gnueabi) + # Can't build modules with this [arm-riscos-gnueabi(hf)] toolchain + CMHG ?= echo + else + CMHG ?= PATH="$(GCCSDK_INSTALL_CROSSBIN):$(PATH)" $(GCCSDK_INSTALL_CROSSBIN)/cmunge + endif GENHTML ?= echo LCOV ?= echo PKGCONFIG ?= PKG_CONFIG_LIBDIR="$(PREFIX)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/lib/pkgconfig:$(GCCSDK_INSTALL_ENV)/share/pkgconfig" pkg-config ifneq ($(COMPONENT_TYPE),riscos-module) + EXEEXT := ,ff8 ifneq ($(findstring arm-unknown-riscos-gcc,$(CC__)),) EXEEXT := ,e1f - else - EXEEXT := ,ff8 + endif + ifneq ($(findstring arm-riscos-gnueabi-gcc,$(CC__)),) + EXEEXT := ,e1f + endif + ifneq ($(findstring arm-riscos-gnueabihf-gcc,$(CC__)),) + EXEEXT := ,e1f endif else EXEEXT := ,ffa endif - # TODO: this assumes GCC - CFLAGS := $(CFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include - CXXFLAGS := $(CXXFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include + CFLAGS := $(CFLAGS) -I$(GCCSDK_INSTALL_ENV)/include + CXXFLAGS := $(CXXFLAGS) -I$(GCCSDK_INSTALL_ENV)/include LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib CMHGFLAGS := -p -tgcc -32bit -apcs 3/32/nonreent/fpe2/noswst/nofpr/nofp @@ -206,6 +220,10 @@ else CXXFLAGS := $(CXXFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib + ifeq ($(HOST),m68k-unknown-amigaos) + CFLAGS += -fomit-frame-pointer -m68020 + endif + PREFIX ?= $(GCCSDK_INSTALL_ENV) endif @@ -267,7 +285,7 @@ GENHTML ?= genhtml BUILD_CXX ?= c++ -INSTALL ?= install +INSTALL ?= install -C LCOV ?= lcov @@ -369,6 +387,11 @@ else endif endif + ifeq ($(findstring lcc:,$(ccvsn)),lcc:) + # MCST LCC pretends to be gcc + toolchain := gcc + endif + # "Norcroft ..." ifeq ($(word 1,$(ccvsn)),Norcroft) toolchain := norcroft @@ -399,6 +422,25 @@ ifeq ($(toolchain),) $(error Unable to detect toolchain) endif +# Detect if the toolchain ought to support sanitizers +SANITIZE_OK=no +ifeq ($(toolchain),gcc) + GCC_VERSION := $(shell $(CC) -dumpversion -dumpfullversion) + GCC_MAJOR := $(word 1,$(subst ., ,$(GCC_VERSION))) + ifeq ($(shell expr $(GCC_MAJOR) \>= 6),1) + SANITIZE_OK=yes + endif +else ifeq ($(toolchain),clang) + SANITIZE_OK=yes +endif + +# And fail if we can't sanitize and yet the user asked for it +ifeq ($(MAKECMDGOALS),sanitize) + ifeq ($(SANITIZE_OK),no) + $(error Unable to build with sanitizers enabled, compiler not compatible + endif +endif + # TODO: It would be nice to avoid this hard-coded path include $(NSBUILD)/Makefile.$(toolchain) @@ -435,7 +477,11 @@ LDFLAGS := $(LDFLAGS) $(OPTLDFLAGS) ifeq ($(COMPONENT_TYPE),lib-static) LIBEXT ?= .a else - LIBEXT ?= .so + ifeq ($(findstring darwin,$(HOST)),darwin) + LIBEXT ?= .dylib + else + LIBEXT ?= .so + endif endif # If we're building a shared library, modify the flags appropriately |