Makefile ifneq condition fails - makefile

I am adding some conditional flag which depends upon the gcc version
Below if the makefile snippet
CPPFLAGS := -O0 -g
CXXFLAGS := -fPIC
GCCVERSION = $(shell gcc --version | grep ^gcc |cut -b11-16)
ifneq ($(GCCVERSION),"4.1.2")
CPPFLAGS += -std=c++0x
CXXFLAGS += -m64
endif
The ifneq condition fails. I have checked that my $(GCCVERSION)=4.1.2 as expected.
EDIT:
I have already tried below options
ifneq ($(GCCVERSION),4.1.2)
ifneq ($(GCCVERSION),'4.1.2')
ifneq ("$(GCCVERSION)","4.1.2")

You need to strip $(GCCVERSION):
CPPFLAGS := -O0 -g
CXXFLAGS := -fPIC
GCCVERSION = $(shell gcc --version | grep ^gcc |cut -b11-16)
ifneq ($(strip $(GCCVERSION)),4.1.2)
CPPFLAGS += -std=c++0x
CXXFLAGS += -m64
endif

Related

Makefile: ignore file in automatically generated dependencies

I have the following makefile, (mostly) generated by STM32CubeMX and slightly modified:
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Mon Jun 06 11:00:27 SGT 2022]
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2017-02-10 - Several enhancements + project update mode
# 2015-07-22 - first version
# ------------------------------------------------
######################################
# target
######################################
TARGET := mytarget
######################################
# building variables
######################################
# debug build?
DEBUG := 1
# optimization
OPT := -Og
#######################################
# paths
#######################################
# Build path
BUILD_DIR := build
######################################
# source
######################################
# Generated directories
CORE_SOURCES := $(filter-out Core/Src/main.c,$(wildcard Core/**/*.c))
DRIVER_SOURCES := $(wildcard Drivers/STM32WBxx_HAL_Driver/**/*.c)
C_SOURCES := $(CORE_SOURCES) $(DRIVER_SOURCES)
# ASM sources
ASM_SOURCES := startup_stm32wb55xx_cm4.s
# C++ sources
CXX_SOURCES := $(wildcard App/**/*.cpp App/*.cpp)
#######################################
# binaries
#######################################
PREFIX := arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC := $(GCC_PATH)/$(PREFIX)gcc
CXX := $(GCC_PATH)/$(PREFIX)g++
AS := $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP := $(GCC_PATH)/$(PREFIX)objcopy
SZ := $(GCC_PATH)/$(PREFIX)size
else
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)gcc -x assembler-with-cpp
CP := $(PREFIX)objcopy
SZ := $(PREFIX)size
endif
HEX := $(CP) -O ihex
BIN := $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU := -mcpu=cortex-m4
# fpu
FPU := -mfpu=fpv4-sp-d16
# float-abi
FLOAT-ABI := -mfloat-abi=hard
# mcu
MCU := $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS :=
# C defines
C_DEFS := \
-DUSE_HAL_DRIVER \
-DSTM32WB55xx
# AS includes
AS_INCLUDES :=
# C includes
C_INCLUDES := \
-isystem Core/Inc \
-isystem Drivers/STM32WBxx_HAL_Driver/Inc \
-isystem Drivers/STM32WBxx_HAL_Driver/Inc/Legacy \
-isystem Drivers/CMSIS/Device/ST/STM32WBxx/Include \
-isystem Drivers/CMSIS/Include
# compile gcc flags
ASFLAGS := $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CXXFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -fdata-sections -ffunction-sections -std=c++2a -Wall -Wextra -Wpedantic -Werror
MAKEFLAGS += --jobs=12
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
CXXFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(#:%.o=%.d)"
CXXFLAGS += -MMD -MP -MF"$(#:%.o=%.d)"
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT := stm32wb55xx_flash_cm4.ld
# libraries
LIBS := -lc -lm -lnosys
LIBDIR :=
LDFLAGS := $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
info: $(info $(VPATH))
#######################################
# build the application
#######################################
# list of C objects
OBJECTS := $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of C++ objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CXX_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CXX_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $#
$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
$(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cpp=.lst)) $< -o $#
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $#
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CXX) $(OBJECTS) $(LDFLAGS) $(CXXFLAGS) -o $#
$(SZ) $#
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $#
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $#
$(BUILD_DIR):
mkdir $#
#######################################
# clean up
#######################################
clean:
-rm -rf $(BUILD_DIR)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
# *** EOF ***
Now, the C_SOURCES directory (Core/Src/, etc) contains main.c that I want to ignore (which I have tried to do, with filter-out). I have reimplemented all of it in main.cpp in CXX_SOURCES, i.e. App/Src/, which I want to compile instead.
However, it looks like the automatic dependency generation still finds, compiles and links Core/Src/main.c instead of App/Src/main.cpp. I am very new to makefiles as a whole and am not sure how to handle this. What can I do?

GNU make linker input file unused because linking not done

I have some troubles with my make file. All the output files are generated, but linking is not possible. Therefore, I don't get the output executable. Where is my mistake?
Here is my recipe for the output file:
gcc main.o memory.o startup_msp432p401r_gcc.o system_msp432p401r.o interrupts_msp432p401r_gcc.o -Wall -Werror -g -O0 -std=c99 -DHOST -MM -Wl,-Map=c1m2.map -T msp432p401r.lds -o c1m2.out
And here is the whole makefile:
ifeq ($(PLATFORM),HOST)
CC = gcc
else
CC = arm-none-eabi-gcc
endif
# Architectures Specific Flags
LINKER_FILE = msp432p401r.lds
CPU = cortex-m4
ARCH = mthumb
SPECS = nosys.specs
# Compiler Flags and Defines
LD = arm-none-eabi-ld
ifeq ($(PLATFORM),MSP432)
CFLAGS = -Wall -Werror -g -O0 -std=c99 -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nosys.specs
LDFLAGS = -T msp432p401r.lds
else
CFLAGS = -Wall -Werror -g -O0 -std=c99 -DHOST
LDFLAGS = -Wl,-Map=$(TARGET).map -T msp432p401r.lds
endif
TARGET = c1m2
CPPFLAGS = -MM
OBJS = $(SOURCES:.c=.o)
%.o: %.c
$(CC) $< $(CFLAGS) $(CPPFLAGS) -o $#
.PHONY: build
build: all
.PHONY: all
all: $(TARGET).out
$(TARGET).out: $(OBJS)
$(CC) $(OBJS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $#
.PHONY: clean
clean:
rm -f $(OBJS) $(TARGET).out $(TARGET).map
Thank you very much!

What does “linker input file unused because linking not done” mean?

This is weird. The compiler throws this warning though everything works as expected.
This is the makefile that throws the warning:
TARGET = $(notdir $(shell pwd))
LIBS = -lm -lev3dev-c
D_BIN = Build-Assets
ifeq ($(OS),Windows_NT)
LIBS := $(LIBS) -lws2_32
D_BIN := $(D_BIN)/mingw
endif
D_H = ../../source/ev3
CFLAGS = $(addprefix -I, $(D_H)) -O2 -std=gnu99 -W -Wall -Wno-comment
ifeq ($(OS),Windows_NT)
CC = gcc
else
CC = arm-linux-gnueabi-gcc
endif
ifeq ($(OS),Windows_NT)
E_BIN = .exe
else
E_BIN =
endif
F_BIN = $(TARGET)$(E_BIN)
OBJECTS = $(addprefix $(D_BIN)/, $(patsubst %.c, %.o, $(wildcard MotorControl/*.c)))
.PHONY: default all clean
default: $(F_BIN)
all: default
$(OBJECTS): $(D_BIN)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $#
.PRECIOUS: $(F_BIN) $(OBJECTS)
$(F_BIN): $(OBJECTS)
$(CC) $(OBJECTS) -c -Wall $(LIBS) -o $#
clean:
-rm -f $(D_BIN)/*.o
-rm -f $(F_BIN)
I should add that I have no idea what I'm doing... I am just starting out with C and those damn makefiles are very overwhelming.
The -c option skips the final link and produces a relocatable object file:
$(F_BIN): $(OBJECTS)
$(CC) $(OBJECTS) -c -Wall $(LIBS) -o $#
This is why linker input files are not used at this stage. You should be able to remove the -c option, and the command will produce an executable as a result.

Makefile crash on providing multiple dependencies

This is a simple Makefile I had written. To get it working on mingw32-make I had to replace the #if [ ! -d $(OUTDIR) ]; then mkdir -p $(notdir $(OUTDIR)); fi calls with ifneq constructs. This is the file as now:
# This Makefile will build an application using the DLL.
SRCTREE := ./
CXX ?= g++
AR ?= ar
SRCDIR := $(SRCTREE)src
OUTDIR := $(SRCTREE)bin
OBJDIR := $(SRCTREE)obj
LIBDIR := $(SRCTREE)lib
INCDIR := $(SRCTREE)include
CFLAGS := -O3 -std=c++11 -Wall -pedantic
CFLAGS_EXTRA := -coverage
LFLAGS := -lgcov --coverage
dirs:
ifeq ("$(wildcard $(OBJDIR)/.)", "")
-mkdir $(notdir $(OBJDIR))
endif
ifeq ("$(wildcard $(LIBDIR)/.)", "")
-mkdir $(notdir $(LIBDIR))
endif
ifeq ("$(wildcard $(OUTDIR)/.)", "")
-mkdir $(notdir $(OUTDIR))
endif
all: dirs use-static
use-shared: CFLAGS_EXTRA += -pthread -DMATRIX_USE_DLL -DDLL_IMPORTS
use-shared: LFLAGS := -L$(SRCTREE) -l:$(OUTDIR)/Matrix.so
use-shared: main
use-static: CFLAGS_EXTRA += -pthread
use-static: LFLAGS := $(LIBDIR)/Matrix.a
use-static: main
%.o: $(SRCDIR)/%.cpp
$(CXX) -c $(CFLAGS) -I $(INCDIR) $(CFLAGS_EXTRA) -o $(OBJDIR)/$# $<
main: main.o
$(CXX) -o $(OUTDIR)/$# $(patsubst %,$(OBJDIR)/%,$^) $(LFLAGS) -s -pthread
clean:
-rm -f $(OBJDIR)/main.o
-rm -f $(OUTDIR)/main
-rm -f $(LIBDIR)/Matrix.a
-rm -f $(OUTDIR)/Matrix.so
When I run it like mingw32-make all -n, if the directories are not present, I get crash like: mingw32-make: Interrupt/Exception caught (code = 0xc0000005, addr = 0x00007FFE854CF15C). I cannot find what the problem could be. Could someone suggest what might be wrong?

Unable to change compiler in Crypto++ GNUmakefile

I'm trying to compile cryptopp with gcc49 on FreeBSD 10.x, however no matter how I instruct the Makefile to compile with g++49/gcc49, my attempts are ignored and it always compiles with c++.
I can't see at the moment where the compiler is defined in Makefile.
What I tried:
ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
CXX = g++49
endif
So I'd like the almighty of someone here to instruct it to compile with gcc49 (or g++49?) instead. Thanks!
Makefile:
CXXFLAGS = -DNDEBUG -g -O2
#CXXFLAGS = -g
# -fPIC is supported. Please report any breakage of -fPIC as a bug.
# CXXFLAGS += -fPIC
# the following options reduce code size, but breaks link or makes link very slow on some systems
# CXXFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += -Wl,--gc-sections
ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib
CP = cp
MKDIR = mkdir
EGREP = egrep
UNAME = $(shell uname)
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
# Default prefix for make install
ifeq ($(PREFIX),)
PREFIX = ..
endif
ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
CXX = g++49
endif
ifeq ($(ISX86),1)
GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
GAS219_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])")
ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
ifneq ($(GCC42_OR_LATER),0)
ifeq ($(UNAME),Darwin)
CXXFLAGS += -arch x86_64 -arch i386
else
CXXFLAGS += -march=native
endif
endif
ifneq ($(INTEL_COMPILER),0)
CXXFLAGS += -wd68 -wd186 -wd279 -wd327
ifeq ($(ICC111_OR_LATER),0)
# "internal error: backend signals" occurs on some x86 inline assembly with ICC 9 and some x64 inline assembly with ICC 11.0
# if you want to use Crypto++'s assembly code with ICC, try enabling it on individual files
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
endif
endif
ifeq ($(GAS210_OR_LATER),0) # .intel_syntax wasn't supported until GNU assembler 2.10
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
else
ifeq ($(GAS217_OR_LATER),0)
CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
else
ifeq ($(GAS219_OR_LATER),0)
CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
endif
endif
ifeq ($(UNAME),SunOS)
CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif
endif
ifeq ($(ISMINGW),1)
LDLIBS += -lws2_32
endif
endif # ISX86
ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210
else
CXXFLAGS += -pipe
endif
ifeq ($(UNAME),Linux)
LDFLAGS += -pthread
ifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0)
M32OR64 = -m64
endif
endif
ifeq ($(UNAME),Darwin)
AR = libtool
ARFLAGS = -static -o
CXX = c++
IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
ifeq ($(IS_GCC2),1)
CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
LDLIBS += -lstdc++
LDFLAGS += -flat_namespace -undefined suppress -m
endif
endif
ifeq ($(UNAME),SunOS)
LDLIBS += -lnsl -lsocket
M32OR64 = -m$(shell isainfo -b)
endif
ifneq ($(IS_SUN_CC),0) # override flags for CC Sun C++ compiler
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)
LDFLAGS =
AR = $(CXX)
ARFLAGS = -xar -o
RANLIB = true
SUN_CC10_BUGGY = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun .* 5\.10 .* (2009|2010/0[1-4])")
ifneq ($(SUN_CC10_BUGGY),0)
# -DCRYPTOPP_INCLUDE_VECTOR_CC is needed for Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21 and was fixed in May 2010
# remove it if you get "already had a body defined" errors in vector.cc
CXXFLAGS += -DCRYPTOPP_INCLUDE_VECTOR_CC
endif
endif
SRCS = $(wildcard *.cpp)
ifeq ($(SRCS),) # workaround wildcard function bug in GNU Make 3.77
SRCS = $(shell echo *.cpp)
endif
OBJS = $(SRCS:.cpp=.o)
# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
DLLSRCS = algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.cpp cryptlib.cpp des.cpp dessp.cpp dh.cpp dll.cpp dsa.cpp ec2n.cpp eccrypto.cpp ecp.cpp eprecomp.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gf2n.cpp gfpcrypt.cpp hex.cpp hmac.cpp integer.cpp iterhash.cpp misc.cpp modes.cpp modexppc.cpp mqueue.cpp nbtheory.cpp oaep.cpp osrng.cpp pch.cpp pkcspad.cpp pubkey.cpp queue.cpp randpool.cpp rdtables.cpp rijndael.cpp rng.cpp rsa.cpp sha.cpp simple.cpp skipjack.cpp strciphr.cpp trdlocal.cpp
DLLOBJS = $(DLLSRCS:.cpp=.export.o)
LIBIMPORTOBJS = $(LIBOBJS:.o=.import.o)
TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
DLLTESTOBJS = dlltest.dllonly.o
all: cryptest.exe
test: cryptest.exe
./cryptest.exe v
clean:
$(RM) cryptest.exe libcryptopp.a $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
install:
$(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
$(CP) *.h $(PREFIX)/include/cryptopp
$(CP) *.a $(PREFIX)/lib
$(CP) *.so $(PREFIX)/lib
$(CP) *.exe $(PREFIX)/bin
libcryptopp.a: $(LIBOBJS)
$(AR) $(ARFLAGS) $# $(LIBOBJS)
$(RANLIB) $#
libcryptopp.so: $(LIBOBJS)
$(CXX) -shared -o $# $(LIBOBJS)
cryptest.exe: libcryptopp.a $(TESTOBJS)
$(CXX) -o $# $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)
nolib: $(OBJS) # makes it faster to test changes
$(CXX) -o ct $(CXXFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
dll: cryptest.import.exe dlltest.exe
cryptopp.dll: $(DLLOBJS)
$(CXX) -shared -o $# $(CXXFLAGS) $(DLLOBJS) $(LDFLAGS) $(LDLIBS) -Wl,--out-implib=libcryptopp.dll.a
libcryptopp.import.a: $(LIBIMPORTOBJS)
$(AR) $(ARFLAGS) $# $(LIBIMPORTOBJS)
$(RANLIB) $#
cryptest.import.exe: cryptopp.dll libcryptopp.import.a $(TESTIMPORTOBJS)
$(CXX) -o $# $(CXXFLAGS) $(TESTIMPORTOBJS) -L. -lcryptopp.dll -lcryptopp.import $(LDFLAGS) $(LDLIBS)
dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
$(CXX) -o $# $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
adhoc.cpp: adhoc.cpp.proto
ifeq ($(wildcard adhoc.cpp),)
cp adhoc.cpp.proto adhoc.cpp
else
touch adhoc.cpp
endif
%.dllonly.o : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_DLL_ONLY -c $< -o $#
%.import.o : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_IMPORTS -c $< -o $#
%.export.o : %.cpp
$(CXX) $(CXXFLAGS) -DCRYPTOPP_EXPORTS -c $< -o $#
%.o : %.cpp
$(CXX) $(CXXFLAGS) -c $<
ifeq ($(CXX),gcc) # for some reason CXX is gcc on cygwin 1.1.4
CXX = g++49
endif
If I recall correctly, CXX is g++ or c++ on the BSDs, so you will never enter the ifeq block.
The easiest thing to do would probably be:
# GNUmakefile
CXXFLAGS = -DNDEBUG -g -O2 -fPIC
CXX=g++49
...
It looks like you are using Crypto++ 5.6.2 or less because of this line:
CXXFLAGS = -DNDEBUG -g -O2
5.6.3 and above works harder at honoring user's preferences. For example, in 5.6.3 GNUmakefile (which is being tested for release):
# Base CXXFLAGS used if the user did not specify them
CXXFLAGS ?= -DNDEBUG -g2 -O2
The next-easiest thing to do would be to grab the 5.6.3 GNUmakefile, and then peform the following (g++49 must be on-path):
export CXX=g++49
make
I can assure you that works on 5.6.3 because I made the changes to facilitate testing under different compilers. You can also tweak CXXFLAGS:
export CXX=/opt/intel/bin/icpc
export CXXFLAGS="-DNDEBUG -g2 -O3 -wd68 -wd186"
make
5.6.3 should be available in a couple of weeks. We are finishing up the mitigations for a Coverity scan/analysis. Once they are mitigated, we have to perform a final round or Release Testing.

Resources