2727# instances of "$" within them need to be escaped with a second "$" to
2828# accomodate the double expansion that occurs when eval is invoked.
2929
30- # Before doing ANYTHING, initialize submodules...if the version of
31- # git is compatible.
32- gitv := $(shell git --version | cut -d\ -f 3 | cut -c 1)
33- ifeq (1, $(gitv ) )
34- gitv := $(shell git --version | cut -d\ -f 3)
35- $(error git '$(shell which git)' version '$(gitv)' too old; at least version 2.12 is required)
36- endif
37-
30+ # Before doing ANYTHING, initialize submodules.
3831ifeq ($(wildcard utility/src/Makefile) , )
3932 $(info $(shell git submodule update --init utility))
4033 $(info $(space))
@@ -350,9 +343,8 @@ DIR_STACK :=
350343INCDIRS :=
351344TGT_STACK :=
352345
353- # Discover our OS and architecture. These were previously used to set
354- # BUILD_DIR and TARGET_DIR to allow multi-platform builds. DESTDIR will do
355- # that for us too.
346+ # Discover our OS and architecture. These are used to set the BUILD_DIR and TARGET_DIR to
347+ # something more useful than 'build' and '.'.
356348
357349OSTYPE := $(shell echo `uname`)
358350OSVERSION := $(shell echo `uname -r`)
@@ -377,18 +369,6 @@ ifeq (${OSTYPE}, SunOS)
377369 endif
378370endif
379371
380- # Set paths for building and installing. If DESTDIR doesn't exist, use the
381- # directory just above us.
382-
383- ifeq "$(strip ${DESTDIR}) " ""
384- BUILD_DIR := $(realpath ..) /build/obj
385- TARGET_DIR := $(realpath ..) /build
386- else
387- BUILD_DIR := $(DESTDIR ) /canu/build/obj
388- TARGET_DIR := $(DESTDIR ) /canu/build
389- endif
390-
391- #
392372# Set compiler and flags based on discovered hardware
393373#
394374# By default, debug symbols are included in all builds (even optimized).
@@ -405,6 +385,7 @@ endif
405385# BUILDJEMALLOC will enable jemalloc library support.
406386#
407387
388+
408389ifeq ($(origin CXXFLAGS ) , undefined)
409390 ifeq ($(BUILDOPTIMIZED), 1)
410391 else
@@ -456,27 +437,44 @@ endif
456437# So, we require gcc7 (from MacPorts) or gcc8 (from hommebrew).
457438#
458439# If from MacPorts:
459- # port install gcc9
460- # port select gcc mp-gcc9
440+ # port install gcc7
441+ # port select gcc mp-gcc7
461442#
462443# If CC is set to 'cc', the GNU make default, we'll automagically search for other
463- # versions and use those if found.
444+ # versions and use those if found, preferring gcc7 over gcc8 .
464445#
446+ # There' definitely a clever way to do this with 'foreach', but my Make is lacking.
447+ #
448+ ifeq (${OSTYPE}, Darwin)
449+ ifeq ($(CC), cc)
450+ CC7 := $(shell echo `which gcc-mp-7`)
451+ CXX7 := $(shell echo `which g++-mp-7`)
465452
466- define TEST_COMPILER
467- ifeq ($${CC}, cc)
468- CCTEST := $$(shell echo `which gcc-${1}`)
469- CXXTEST := $$(shell echo `which g++-${1}`)
453+ ifdef CXX7
454+ CC := $(CC7 )
455+ CXX := $(CXX7 )
456+ endif
457+ endif
458+
459+ ifeq ($(CC), cc)
460+ CC8 := $(shell echo `which gcc-7`)
461+ CXX8 := $(shell echo `which g++-7`)
470462
471- ifdef CXXTEST
472- CC := $${CCTEST}
473- CXX := $${CXXTEST}
463+ ifdef CXX8
464+ CC := $( CC8 )
465+ CXX := $( CXX8 )
474466 endif
475467 endif
476- endef
477468
478- ifeq (${OSTYPE}, Darwin)
479- $(foreach suffix,mp-9 9 mp-8 8 mp-7 7,$(eval $(call TEST_COMPILER,${suffix})))
469+ ifeq ($(CC), cc)
470+ CC8 := $(shell echo `which gcc-8`)
471+ CXX8 := $(shell echo `which g++-8`)
472+
473+ ifdef CXX8
474+ CC := $(CC8 )
475+ CXX := $(CXX8 )
476+ endif
477+ endif
480478
481479 ifneq ($(shell echo `$(CXX) --version 2>&1 | grep -c clang`), 0)
482480 CPATH := $(shell echo `which $(CXX ) `)
@@ -516,12 +514,9 @@ ifeq (${CANU_BUILD_ENV}, ports)
516514
517515else
518516
519- # Ignore the gmake default 'c++' and force g++9.
520- ifeq ($(origin CXX), default)
521- CC = gcc9
522- CXX = g++9
523- CCLIB = -rpath /usr/local/lib/gcc9
524- endif
517+ CC ?= gcc6
518+ CXX ?= g++6
519+ CCLIB ?= -rpath /usr/local/lib/gcc6
525520
526521 # GCC
527522 CXXFLAGS += -I/usr/local/include -pthread -fopenmp -fPIC
@@ -688,11 +683,11 @@ $(foreach TGT,${ALL_TGTS},\
688683# Makefile processed. Regenerate the version number file, make some
689684# directories, and report that we're starting the build.
690685
691- $( eval $( shell ../scripts/version_update.pl meryl utility/src/utility/version.H) )
686+ $( shell ../scripts/version_update.pl meryl utility/src/utility/version.H)
692687
693688$( shell mkdir -p ${TARGET_DIR} /bin)
694689
695- $( info For ' ${OSTYPE}' ' ${OSVERSION}' as ' ${MACHINETYPE}' into ' ${TARGET_DIR} /{bin,obj}' .)
690+ $( info For ' ${OSTYPE}' ' ${OSVERSION}' as ' ${MACHINETYPE}' into ' ${DESTDIR}${PREFIX}/$(OSTYPE)-$(MACHINETYPE) /{bin,obj}' .)
696691$( info Using ' $(shell which ${CXX})' version ' ${GXX_VV}' .)
697692ifneq ($( origin CXXFLAGSUSER) , undefined)
698693$( info Using user-supplied CXXFLAGS ' ${CXXFLAGSUSER}' .)
0 commit comments