From 6d4d11f1b6b69f73963fbebb5cc3e2d35230d2b2 Mon Sep 17 00:00:00 2001 From: Mark Gates Date: Wed, 28 Apr 2021 10:22:25 -0400 Subject: [PATCH] allow overriding LD --- GNUmakefile | 12 +++++++++--- INSTALL.md | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 3330246d..0fcaf71d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,7 +4,7 @@ # Configuration # Variables defined in make.inc, or use make's defaults: # CXX, CXXFLAGS -- C compiler and flags -# LDFLAGS, LIBS -- Linker options, library paths, and libraries +# LD, LDFLAGS, LIBS -- Linker, options, library paths, and libraries # AR, RANLIB -- Archiver, ranlib updates library TOC # prefix -- where to install BLAS++ @@ -30,6 +30,11 @@ make.inc: RANLIB ?= ranlib prefix ?= /opt/slate +# Default LD=ld won't work; use CXX. Can override in make.inc or environment. +ifeq ($(origin LD),default) + LD = $(CXX) +endif + # auto-detect OS # $OSTYPE may not be exported from the shell, so echo it ostype := $(shell echo $${OSTYPE}) @@ -156,7 +161,7 @@ lib = lib/libblaspp.$(lib_ext) $(lib_so): $(lib_obj) mkdir -p lib - $(CXX) $(LDFLAGS) -shared $(install_name) $(lib_obj) $(LIBS) -o $@ + $(LD) $(LDFLAGS) -shared $(install_name) $(lib_obj) $(LIBS) -o $@ $(lib_a): $(lib_obj) mkdir -p lib @@ -180,7 +185,7 @@ endif #------------------------------------------------------------------------------- # tester $(tester): $(tester_obj) $(lib) $(testsweeper) - $(CXX) $(TEST_LDFLAGS) $(LDFLAGS) $(tester_obj) \ + $(LD) $(TEST_LDFLAGS) $(LDFLAGS) $(tester_obj) \ $(TEST_LIBS) $(LIBS) -o $@ # sub-directory rules @@ -314,6 +319,7 @@ echo: @echo "CXX = $(CXX)" @echo "CXXFLAGS = $(CXXFLAGS)" @echo + @echo "LD = $(LD)" @echo "LDFLAGS = $(LDFLAGS)" @echo "LIBS = $(LIBS)" @echo diff --git a/INSTALL.md b/INSTALL.md index 5c4dee4a..f0fa4755 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -26,6 +26,7 @@ Environment variables (Makefile and CMake) Standard environment variables affect both Makefile (configure.py) and CMake. These include: + LD Linker; defaults to CXX CXX C++ compiler CXXFLAGS C++ compiler flags LDFLAGS linker flags