[Bio] / SoftRelTools / compiler_check.mk Repository:
ViewVC logotype

View of /SoftRelTools/compiler_check.mk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (download) (annotate) (vendor branch)
Fri Dec 20 20:20:56 2002 UTC (15 years, 11 months ago) by efrank
Branch: BobJacobsen, MAIN
CVS Tags: Head-20-Dec-2002, HEAD
Changes since 1.1: +0 -0 lines

Import from SLAC.  Not sure this is going to serve us, but there is a ton
of experience in this package.

# Check compiler version
#
#       $Id: compiler_check.mk,v 1.1.1.1 2002/12/20 20:20:56 efrank Exp $
#
# Format:
#     COMNAM := compiler to be checked.	  [e.g. COMNAM := CC]
#     COMCMD := <command to get version>  [e.g. COMCMD := $(CXX) -V]
#     COMVER := <keyword> <rel> <ver>     [e.g. COMVER := C++ >= 5.2
#
# Example:
#     For Linux2, 'gcc -c' generates:
#	 "gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)"
#     set keyword to "gcc version" and add relational operator to it:
#     COMVER := gcc version >= 2.95.2
#
########################################################################
#++ Set COMVER for different BFARCH

#-----------------------------------------------------------------------
#++ SunOS5

ifneq (,$(findstring SunOS5,$(BFARCH)))          # [SunOS5xx]
    COMNAM := CC
    COMCMD := $(CXX) -V

#-----------------------------------------------------------------------
#++ SunOS58

    ifneq (,$(findstring SunOS58,$(BFARCH)))          # [SunOS58]
      COMVER := C++ = 5.2
    endif # SunOS58
endif     # SunOS5

#-----------------------------------------------------------------------
#++ Linux2

ifneq (,$(findstring Linux2,$(BFARCH)))           # [Linux2]
    COMNAM := g++
    COMCMD := $(CXX) -v
    COMVER := gcc version = 2.95.2

#-----------------------------------------------------------------------
#++ Linux24

    ifneq (,$(findstring Linux24,$(BFARCH)))      # [Linux24]
      COMVER := gcc version = 2.95.3
    endif
endif

########################################################################
#++ Parse COMVER and COMCMD

#-----------------------------------------------------------------------
#++ Parse COMVER into "<key> <rel> <version>". e.g. "C++ > 5.2"

ifdef DEBUG24
    ERROR := $(shell echo "COMVER='$(COMVER)' COMCMD='$(COMCMD)' COMNAM='$(COMNAM)' CXX=$'$(CXX)'   [ck-1]" >&2)
endif

ifneq (,$(COMVER))
    ifneq (,$(findstring $(COMNAM),$(CXX)))
      comKEY := $(shell expr "$(COMVER)" : '\(.*\) [<=>]* .*')
      comVER := $(shell expr "$(COMVER)" : '.* [<=>]* \(.*\)')
      comREL := $(shell expr "$(COMVER)" : '$(comKEY) \(.*\) $(comVER)')
      ifeq (1,$(DEBUG24))
        ERROR := $(shell echo "comKEY='$(comKEY)' comVER='$(comVER)' comREL='$(comREL)'  [ck-2]" >&2)
      endif

#-----------------------------------------------------------------------
#++ Parse version from output of $COMCMD 
#   e.g. "C++ 5.2" -> set comver to 5.2

      comver := $(shell $(COMCMD) 2>&1)
      comver := $(comver::=-)
      comver := $(shell comv=`$(COMCMD) 2>&1`; expr "$(comver)" : '.*$(comKEY) [^0-9]*\([^ ]*\).*')

########################################################################
#++ Check compiler's version

#-----------------------------------------------------------------------
# Warning for wrong compiler version

      ifneq (1,$(shell if [ "$(DEBUG24)" ]; then set -x; fi; expr $(comver) "$(comREL)" $(comVER)))
        ERROR := $(shell echo '*' >&2; echo '* Warning: Recommended C++ compiler for $(BFARCH) is $(COMVER),' >&2; echo '*          but you are using $(comKEY) $(comver)    [$(COMCMD)]' >& 2; echo '*' >& 2)
      endif

#-----------------------------------------------------------------------
# Warning for wrong compiler

    else
      ERROR := $(shell echo '*' >&2; echo '* Warning: Recommended C++ compiler for $(BFARCH) is $(COMNAM),' >&2; echo '*          but you are using $(CXX)' >& 2; echo '*' >& 2)

    endif   # COMNAM
endif   # COMVER

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3