The $(CXXFLAGS) are almost redundant here. However, the linker does need access to $(PROFILE_FLAG) and so that should be added to the $(LDFLAGS).



ifeq ($(STATIC),yes)
LDFLAGS=-static -lm...