From 831daba9c01b0c0ef94b5bce1217f94876789441 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Tue, 3 Aug 2004 18:07:34 +0000
Subject: [PATCH] port to icc v8.1 with EM64T (AMD64) support. To compile with
 this new compiler use the platform: linuxx8664icc.

git-svn-id: http://root.cern.ch/svn/root/trunk@9668 27541ba8-7e3a-0410-8455-c3a389f83636
---
 cint/Module.mk                     |  8 ++++
 cint/iosenum/iosenum.linuxx8664icc | 69 ++++++++++++++++++++++++++++++
 cint/src/Api.cxx                   |  4 +-
 cint/src/init.c                    |  2 +-
 cint/src/v6_init.cxx               |  2 +-
 config/ARCHS                       |  3 +-
 config/Makefile.linuxicc           |  3 +-
 config/Makefile.linuxx8664gcc      |  2 +-
 config/Makefile.linuxx8664icc      | 69 ++++++++++++++++++++++++++++++
 config/root-config.in              |  7 ++-
 configure                          | 13 +++---
 test/Makefile.arch                 | 12 +++++-
 utils/Module.mk                    |  2 +-
 13 files changed, 179 insertions(+), 17 deletions(-)
 create mode 100644 cint/iosenum/iosenum.linuxx8664icc
 create mode 100644 config/Makefile.linuxx8664icc

diff --git a/cint/Module.mk b/cint/Module.mk
index 5c7b11437f6..bd4693cd498 100644
--- a/cint/Module.mk
+++ b/cint/Module.mk
@@ -136,7 +136,15 @@ endif
 ifeq ($(CXXCMD),icc)
 CINTS2       := $(filter-out $(MODDIRS)/libstrm.%,$(CINTS2))
 CINTS2       := $(filter-out $(MODDIRS)/longif.%,$(CINTS2))
+ifeq ($(ICC_MAJOR),8)
+ifeq ($(ICC_MINOR),1)
+CINTS2       += $(MODDIRS)/gcc3strm.cxx
+else
+CINTS2       += $(MODDIRS)/iccstrm.cxx
+endif
+else
 CINTS2       += $(MODDIRS)/iccstrm.cxx
+endif
 CINTS2       += $(MODDIRS)/longif3.cxx
 endif
 ifeq ($(CXXCMD),ecc)
diff --git a/cint/iosenum/iosenum.linuxx8664icc b/cint/iosenum/iosenum.linuxx8664icc
new file mode 100644
index 00000000000..ee97bc7feb0
--- /dev/null
+++ b/cint/iosenum/iosenum.linuxx8664icc
@@ -0,0 +1,69 @@
+/* include/platform/iosenum.h
+ *  This file contains platform dependent ios enum value.
+ *  Run 'cint iosenum.cxx' to create this file. It is done
+ *  only once at installation. */
+#pragma ifndef G__TMPLTIOS
+static int ios::goodbit=0;
+static int ios::eofbit=2;
+static int ios::failbit=4;
+static int ios::badbit=1;
+static int ios::in=8;
+static int ios::out=16;
+static int ios::ate=2;
+static int ios::app=1;
+static int ios::trunc=32;
+static int ios::binary=4;
+static int ios::beg=0;
+static int ios::cur=1;
+static int ios::end=2;
+static int ios::boolalpha=1;
+static int ios::adjustfield=176;
+static int ios::basefield=74;
+static int ios::floatfield=260;
+static int ios::skipws=4096;
+static int ios::left=32;
+static int ios::right=128;
+static int ios::internal=16;
+static int ios::dec=2;
+static int ios::oct=64;
+static int ios::hex=8;
+static int ios::showbase=512;
+static int ios::showpoint=1024;
+static int ios::uppercase=16384;
+static int ios::showpos=2048;
+static int ios::scientific=256;
+static int ios::fixed=4;
+static int ios::unitbuf=8192;
+#pragma else
+static ios_base::fmtflags ios_base::boolalpha=1;
+static ios_base::fmtflags ios_base::dec=2;
+static ios_base::fmtflags ios_base::fixed=4;
+static ios_base::fmtflags ios_base::hex=8;
+static ios_base::fmtflags ios_base::internal=16;
+static ios_base::fmtflags ios_base::left=32;
+static ios_base::fmtflags ios_base::oct=64;
+static ios_base::fmtflags ios_base::right=128;
+static ios_base::fmtflags ios_base::scientific=256;
+static ios_base::fmtflags ios_base::showbase=512;
+static ios_base::fmtflags ios_base::showpoint=1024;
+static ios_base::fmtflags ios_base::showpos=2048;
+static ios_base::fmtflags ios_base::skipws=4096;
+static ios_base::fmtflags ios_base::unitbuf=8192;
+static ios_base::fmtflags ios_base::uppercase=16384;
+static ios_base::fmtflags ios_base::adjustfield=176;
+static ios_base::fmtflags ios_base::basefield=74;
+static ios_base::fmtflags ios_base::floatfield=260;
+static ios_base::fmtflags ios_base::badbit=1;
+static ios_base::fmtflags ios_base::eofbit=2;
+static ios_base::fmtflags ios_base::failbit=4;
+static ios_base::fmtflags ios_base::goodbit=0;
+static ios_base::fmtflags ios_base::app=1;
+static ios_base::fmtflags ios_base::ate=2;
+static ios_base::fmtflags ios_base::binary=4;
+static ios_base::fmtflags ios_base::in=8;
+static ios_base::fmtflags ios_base::out=16;
+static ios_base::fmtflags ios_base::trunc=32;
+static ios_base::fmtflags ios_base::beg=0;
+static ios_base::fmtflags ios_base::cur=1;
+static ios_base::fmtflags ios_base::end=2;
+#pragma endif
diff --git a/cint/src/Api.cxx b/cint/src/Api.cxx
index 65f8bfd593e..e5e03637212 100644
--- a/cint/src/Api.cxx
+++ b/cint/src/Api.cxx
@@ -583,7 +583,7 @@ extern "C" const char* G__saveconststring(const char* s)
 #ifndef G__OLDIMPLEMENTATION1689
 extern "C" void G__initcxx() 
 {
-#if defined(__HP_aCC)||defined(__SUNPRO_CC)||defined(__BCPLUSPLUS__)||defined(__KCC)||defined(__INTEL_COMPILER)
+#if defined(__HP_aCC)||defined(__SUNPRO_CC)||defined(__BCPLUSPLUS__)||defined(__KCC)|| (defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 810))
   char temp[G__ONELINE];
 #endif
 #ifdef __HP_aCC     /* HP aCC C++ compiler */
@@ -598,7 +598,7 @@ extern "C" void G__initcxx()
 #ifdef __KCC        /* KCC  C++ compiler */
   sprintf(temp,"G__KCC=%ld",(long)__KCC); G__add_macro(temp);
 #endif
-#ifdef __INTEL_COMPILER /* icc and ecc C++ compilers */
+#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 810 /* icc and ecc C++ compilers */
   sprintf(temp,"G__INTEL_COMPILER=%ld",(long)__INTEL_COMPILER); G__add_macro(temp);
 #endif
   /*
diff --git a/cint/src/init.c b/cint/src/init.c
index 85c47e7e240..9148e2b3058 100644
--- a/cint/src/init.c
+++ b/cint/src/init.c
@@ -2246,7 +2246,7 @@ void G__platformMacro()
 #ifdef __KCC        /* KCC  C++ compiler */
   sprintf(temp,"G__KCC=%ld",(long)__KCC); G__add_macro(temp);
 #endif
-#ifdef __INTEL_COMPILER /* icc and ecc C++ compilers */
+#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 810 /* icc and ecc C++ compilers */
   sprintf(temp,"G__INTEL_COMPILER=%ld",(long)__INTEL_COMPILER); G__add_macro(temp);
 #endif
 #ifndef _AIX
diff --git a/cint/src/v6_init.cxx b/cint/src/v6_init.cxx
index 85c47e7e240..9148e2b3058 100644
--- a/cint/src/v6_init.cxx
+++ b/cint/src/v6_init.cxx
@@ -2246,7 +2246,7 @@ void G__platformMacro()
 #ifdef __KCC        /* KCC  C++ compiler */
   sprintf(temp,"G__KCC=%ld",(long)__KCC); G__add_macro(temp);
 #endif
-#ifdef __INTEL_COMPILER /* icc and ecc C++ compilers */
+#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 810 /* icc and ecc C++ compilers */
   sprintf(temp,"G__INTEL_COMPILER=%ld",(long)__INTEL_COMPILER); G__add_macro(temp);
 #endif
 #ifndef _AIX
diff --git a/config/ARCHS b/config/ARCHS
index d2281ec9324..dc5b4c999f9 100644
--- a/config/ARCHS
+++ b/config/ARCHS
@@ -27,7 +27,8 @@ linuxppcegcs         for PPC Linux egcs and glibc
 linuxrh42            for Linux gcc 2.7.x.x and libc5
 linuxrh51            for Linux gcc 2.7.x.x and glibc
 linuxsuse6           for Linux (SuSE v6.0) egcs and glibc
-linuxx8664gcc        for AMD Opteron (64 bit mode) Linux gcc 3.x and glibc
+linuxx8664gcc        for AMD Opteron and Intel EM64T Linux gcc 3.x and glibc
+linuxx8664icc        for AMD Opteron and Intel EM64T Linux gcc 3.x and glibc
 lynxos               for LynxOS with gcc
 macosx               for MacOS X with cc
 macosxxlc            for MacOS X with IBM xl compilers
diff --git a/config/Makefile.linuxicc b/config/Makefile.linuxicc
index b3a5392530b..f48c0cc5068 100644
--- a/config/Makefile.linuxicc
+++ b/config/Makefile.linuxicc
@@ -1,3 +1,5 @@
+# -*- mode: makefile -*-
+#
 # Makefile of ROOT for Linux with glibc and Intel icc compiler
 
 PLATFORM      = linux
@@ -65,4 +67,3 @@ F77LIBS       = $(LIBFRTBEGIN) $(LIBG2C) \
 endif
 
 # Extras
-
diff --git a/config/Makefile.linuxx8664gcc b/config/Makefile.linuxx8664gcc
index a74925acf46..df8eb92be7b 100644
--- a/config/Makefile.linuxx8664gcc
+++ b/config/Makefile.linuxx8664gcc
@@ -1,6 +1,6 @@
 # -*- mode: makefile -*-
 #
-# Makefile of ROOT for AMD Opteron (64 bit mode) Linux with gcc
+# Makefile of ROOT for AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc
 
 PLATFORM      = linux
 
diff --git a/config/Makefile.linuxx8664icc b/config/Makefile.linuxx8664icc
new file mode 100644
index 00000000000..106232f9af4
--- /dev/null
+++ b/config/Makefile.linuxx8664icc
@@ -0,0 +1,69 @@
+# -*- mode: makefile -*-
+#
+# Makefile of ROOT for AMD Opteron and Intel EM64T (64 bit mode) Linux with icc
+
+PLATFORM      = linux
+
+DEBUGFLAGS    = -g
+OPTFLAGS      = -O
+ifeq (debug,$(findstring debug,$(ROOTBUILD)))
+OPT           = $(DEBUGFLAGS)
+NOOPT         = -O0
+else
+OPT           = $(OPTFLAGS)
+NOOPT         = -O0
+endif
+
+# Compiler:
+CXX           = icc
+CC            = icc
+CXXFLAGS      = -fPIC -wd1476 -wd1572 $(EXTRA_CXXFLAGS)
+CFLAGS        = -fPIC -wd1572 $(EXTRA_CFLAGS) -restrict
+CINTCXXFLAGS  = -fPIC -wd1572 $(EXTRA_CXXFLAGS) \
+                -DG__REGEXP -DG__UNIX -DG__SHAREDLIB \
+                -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__64BIT
+CINTCFLAGS    = -fPIC -wd1572 $(EXTRA_CFLAGS) -restrict \
+                -DG__REGEXP -DG__UNIX -DG__SHAREDLIB \
+                -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__64BIT
+
+# Compiler version:
+ICC_MAJOR    := $(shell $(CXX) -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \
+                cut -d'.' -f1)
+ICC_MINOR    := $(shell $(CXX) -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \
+                cut -d'.' -f2)
+
+# Linker:
+LD            = icc
+LDFLAGS       = $(OPT) $(EXTRA_LDFLAGS)
+SOFLAGS       = -shared -Wl,-soname,
+SOEXT         = so
+
+# System libraries:
+SYSLIBS       = -lstdc++ -lm -ldl $(OSTHREADLIBDIR) $(OSTHREADLIB) -rdynamic
+XLIBS         = -lstdc++ $(XPMLIBDIR) $(XPMLIB) $(X11LIBDIR) -lX11
+CILIBS        = -lstdc++ -lm -ldl -rdynamic
+CRYPTLIBS     = -lcrypt
+
+# Fortran:
+ifeq ($(ICC_MAJOR),8)
+F77           = ifort
+else
+F77           = ifc
+endif
+F77FLAGS      =
+# check path for libg2c and libfrtbegin
+LIBG2C       := $(shell gcc -print-file-name=libg2c.a | \
+                  awk '{ if ($$1 != "libg2c.a") print $$1}')
+LIBFRTBEGIN  := $(shell gcc -print-file-name=libfrtbegin.a | \
+                  awk '{ if ($$1 != "libfrtbegin.a") print $$1}')
+ifeq ($(ICC_MAJOR),8)
+F77LIBS       = $(LIBFRTBEGIN) $(LIBG2C) \
+                -L$(shell which ifort | sed -e 's|bin/ifort|lib|') \
+                -lifcore
+else
+F77LIBS       = $(LIBFRTBEGIN) $(LIBG2C) \
+                -L$(shell which ifc | sed -e 's|bin/ifc|lib|') \
+                -lF90 -lCEPCF90 -lintrins
+endif
+
+# Extras
diff --git a/config/root-config.in b/config/root-config.in
index c006f87f3c4..974e2c7988e 100755
--- a/config/root-config.in
+++ b/config/root-config.in
@@ -217,10 +217,15 @@ linuxia64ecc)
    auxlibs="-lm -ldl"
    ;;
 linuxx8664gcc)
-   # AMD Opteron (64 bit mode) Linux with gcc 3.x
+   # AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x
    auxcflags=
    auxlibs="-lm -ldl -rdynamic"
    ;;
+linuxx8664icc)
+   # AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc
+   auxcflags=
+   auxlibs="-lm -ldl"
+   ;;
 linuxalphaegcs)
    # Alpha Linux with egcs
    auxcflags=
diff --git a/configure b/configure
index c50aff7d957..bed5366f641 100755
--- a/configure
+++ b/configure
@@ -677,12 +677,13 @@ fi
 
 platform=`grep "^PLATFORM *=" config/Makefile.$arch | awk '{ print $3 }'`
 
-if test "x$arch" = "xsgicc" ; then
-   checklib32="yes"
-fi
-if test "x$arch" = "xlinuxx8664gcc" || test "x$arch" = "xsgicc64" ; then
-   checklib64="yes"
-fi
+case $arch in
+sgicc)
+   checklib32="yes" ;;
+linuxx8664*|sgicc64)
+   checklib64="yes" ;;
+esac
+
 if test "x$platform" = "xmacosx" ; then
    finkdir=`which fink 2>&1 | sed -ne "s/\/bin\/fink//p"`
 fi
diff --git a/test/Makefile.arch b/test/Makefile.arch
index a6e508ff7d2..5d3894cb64e 100644
--- a/test/Makefile.arch
+++ b/test/Makefile.arch
@@ -325,7 +325,6 @@ else
 ICC           = ecc
 IFORT         = efc
 endif
-
 CXX           = $(ICC)
 CXXFLAGS      = -O -fPIC -wd1476
 LD            = $(ICC)
@@ -334,7 +333,7 @@ SOFLAGS       = -shared
 endif
 
 ifeq ($(ARCH),linuxx8664gcc)
-# AMD Opteron (64 bit mode) Linux with gcc 3.x
+# AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x
 CXX           = g++
 CXXFLAGS      = -O2 -Wall -fPIC
 LD            = g++
@@ -342,6 +341,15 @@ LDFLAGS       = -O2
 SOFLAGS       = -shared
 endif
 
+ifeq ($(ARCH),linuxx8664icc)
+# AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc compiler
+CXX           = icc
+CXXFLAGS      = -O -fPIC -wd1476 -wd1572
+LD            = icc
+LDFLAGS       = -O -lstdc++
+SOFLAGS       = -shared
+endif
+
 ifeq ($(ARCH),linuxalphaegcs)
 # Alpha Linux with egcs
 CXX           = g++
diff --git a/utils/Module.mk b/utils/Module.mk
index 4c9225a5a80..475ac3518d3 100644
--- a/utils/Module.mk
+++ b/utils/Module.mk
@@ -39,7 +39,7 @@ $(ROOTCINTTMP): $(CINTTMPO) $(ROOTCINTTMPO) $(METAUTILSO) $(MAKEINFO) $(IOSENUM)
 
 $(RLIBMAP):     $(RLIBMAPO)
 ifneq ($(PLATFORM),win32)
-		$(LD) $(LDFLAGS) -o $@ $<
+		$(LD) $(LDFLAGS) -o $@ $< $(CILIBS)
 else
 		$(LD) $(LDFLAGS) -o $@ $< imagehlp.lib
 endif
-- 
GitLab