From b2e87594059bb9f22932ae29904dc5b20a484a85 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Thu, 31 Mar 2005 23:57:40 +0000
Subject: [PATCH] Finally made port to Linux PPC 64. This is a big-endian Linux
 running on 64bit PowerPC (IBM and Apple G5).

git-svn-id: http://root.cern.ch/svn/root/trunk@11470 27541ba8-7e3a-0410-8455-c3a389f83636
---
 asimage/Module.mk                   |  3 ++
 base/inc/RConfig.h                  |  9 +++-
 cint/iosenum/iosenum.linuxppc64gcc3 | 69 +++++++++++++++++++++++++++++
 config/ARCHS                        |  1 +
 config/Makefile.linuxppc64gcc       | 50 +++++++++++++++++++++
 config/root-config.in               | 19 ++++++--
 configure                           |  3 +-
 freetype/Module.mk                  |  4 ++
 test/Makefile.arch                  | 11 +++++
 9 files changed, 163 insertions(+), 6 deletions(-)
 create mode 100644 cint/iosenum/iosenum.linuxppc64gcc3
 create mode 100644 config/Makefile.linuxppc64gcc

diff --git a/asimage/Module.mk b/asimage/Module.mk
index 2d022bb6bb4..ec93bbcab83 100644
--- a/asimage/Module.mk
+++ b/asimage/Module.mk
@@ -109,6 +109,9 @@ else
 			ACC="cc +DD64 -Ae"; \
 			ACCALT="gcc -mlp64"; \
 		fi; \
+		if [ "$(ARCH)" = "linuxppc64gcc" ]; then \
+			ACC="gcc -m64"; \
+		fi; \
 		if [ "$(ARCH)" = "linuxx8664gcc" ]; then \
 			ACC="gcc -m64"; \
 			MMX="--enable-mmx-optimization=no"; \
diff --git a/base/inc/RConfig.h b/base/inc/RConfig.h
index 588c3e3d460..97bb103a0b3 100644
--- a/base/inc/RConfig.h
+++ b/base/inc/RConfig.h
@@ -1,4 +1,4 @@
-/* @(#)root/base:$Name:  $:$Id: RConfig.h,v 1.78 2005/02/28 17:28:11 rdm Exp $ */
+/* @(#)root/base:$Name:  $:$Id: RConfig.h,v 1.79 2005/03/11 18:36:04 rdm Exp $ */
 
 /*************************************************************************
  * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
@@ -209,6 +209,13 @@
 #   define NEED_SIGJMP
 #endif
 
+#if defined(linux) && defined(R__ppc64)
+#   define R__LINUX
+#   define R__UNIX
+#   define R__B64
+#   define NEED_SIGJMP
+#endif
+
 #if defined(linux) && defined(__alpha__)
 #   define R__LINUX
 #   define R__UNIX
diff --git a/cint/iosenum/iosenum.linuxppc64gcc3 b/cint/iosenum/iosenum.linuxppc64gcc3
new file mode 100644
index 00000000000..ee97bc7feb0
--- /dev/null
+++ b/cint/iosenum/iosenum.linuxppc64gcc3
@@ -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/config/ARCHS b/config/ARCHS
index db0d98fb195..18256ec0f15 100644
--- a/config/ARCHS
+++ b/config/ARCHS
@@ -24,6 +24,7 @@ linuxicc             for Linux Intel's icc and glibc
 linuxkcc             for Linux KAI's KCC and glibc
 linuxpgcc            for Linux pgcc and glibc
 linuxppcegcs         for PPC Linux egcs and glibc
+linuxppc64gcc        for PPC 64 Linux gcc 3.x 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
diff --git a/config/Makefile.linuxppc64gcc b/config/Makefile.linuxppc64gcc
new file mode 100644
index 00000000000..5d9938a7ff7
--- /dev/null
+++ b/config/Makefile.linuxppc64gcc
@@ -0,0 +1,50 @@
+# -*- mode: makefile -*-
+#
+# Makefile of ROOT for linux ppc64 with glibc and gcc 3.x
+
+PLATFORM      = linux
+
+DEBUGFLAGS    = -g
+OPTFLAGS      = -O2
+ifeq (debug,$(findstring debug,$(ROOTBUILD)))
+OPT           = $(DEBUGFLAGS)
+NOOPT         =
+else
+OPT           = $(OPTFLAGS)
+NOOPT         =
+endif
+
+# Compiler:
+CXX           = g++
+CC            = gcc
+CXXFLAGS      = -pipe -Wall -m64 -fPIC -fsigned-char -DR__ppc64 \
+                -I/usr/X11/include $(EXTRA_CXXFLAGS)
+CFLAGS        = -pipe -Wall -m64 -fPIC -fsigned-char -DR__ppc64 \
+                -I/usr/X11/include $(EXTRA_CFLAGS)
+CINTCXXFLAGS  = -pipe -Wall -m64 -fPIC -fsigned-char -DG__REGEXP -DG__UNIX \
+                -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO \
+                -DG__64BIT $(EXTRA_CXXFLAGS)
+CINTCFLAGS    = -pipe -Wall -m64 -fPIC -fsigned-char -DG__REGEXP -DG__UNIX \
+                -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO \
+                -DG__64BIT $(EXTRA_CFLAGS)
+COMPILER      = gnu
+
+# Linker:
+LD            = g++
+LDFLAGS       = -m64 $(OPT) $(EXTRA_LDFLAGS)
+SOFLAGS       = -shared -Wl,-soname,
+SOEXT         = so
+
+# System libraries:
+SYSLIBS       = -lm -ldl
+XLIBS         = $(XPMLIBDIR) $(XPMLIB) $(X11LIBDIR) -lX11 -lSM -lICE
+CILIBS        = -lm -ldl
+CRYPTLIBS     = -lcrypt
+
+# Fortran:
+F77           = g77
+F77FLAGS      = -fPIC
+F77LIBS       = -lg2c
+
+# Extras
+
diff --git a/config/root-config.in b/config/root-config.in
index 8335aee8107..7dfecf12e29 100755
--- a/config/root-config.in
+++ b/config/root-config.in
@@ -197,10 +197,16 @@ linuxicc)
    auxlibs="-lm -ldl"
    ;;
 linuxppcegcs)
-   # Linux/ppc with gcc/glibc
+   # PPC Linux with gcc
    auxcflags="-fsigned-char -I/usr/X11/include"
    auxlibs="-lm -ldl -rdynamic"
    ;;
+linuxppc64gcc)
+   # PPC64 (64 bit mode) Linux with gcc 3.x
+   auxcflags="-m64 -fsigned-char"
+   auxldflags="-m64"
+   auxlibs="-lm -ldl -rdynamic"
+   ;;
 linuxia64gcc)
    # Itanium Linux with gcc 2.x/3.x
    auxcflags=
@@ -219,6 +225,7 @@ linuxia64ecc)
 linuxx8664gcc)
    # AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x
    auxcflags="-m64"
+   auxldflags="-m64"
    auxlibs="-lm -ldl -rdynamic"
    ;;
 linuxx8664icc)
@@ -362,13 +369,12 @@ exec_prefix=${prefix}
 exec_prefix_set=no
 new_set=no
 libsout=no
-cflags=""
 noauxlibs=no
 noauxcflags=no
 noldflags=no
 
 usage="\
-Usage: root-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--new] [--nonew] [--libs] [--glibs] [--bindir] [--libdir] [--incdir] [--noauxcflags] [--noauxlibs] [--noldflags] [--has-<feature>] [--arch] [--platform] [--help]"
+Usage: root-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--auxcflags] [--ldflags] [--new] [--nonew] [--libs] [--glibs] [--bindir] [--libdir] [--incdir] [--noauxcflags] [--noauxlibs] [--noldflags] [--has-<feature>] [--arch] [--platform] [--help]"
 
 if test $# -eq 0; then
    echo "${usage}" 1>&2
@@ -492,9 +498,13 @@ while test $# -gt 0; do
       fi
       ;;
    --auxcflags)
-      ### output auxiliary compiler flags
+      ### Output auxiliary compiler flags
       out="$out $auxcflags"
       ;;
+    --ldflags)
+      ### Output linker flags
+      out="$out $auxldflags"
+      ;;
     --libs)
       ### Output regular ROOT libraries.  If the user said --glibs --libs,
       ### We've already output the libraries, so we skip this section
@@ -598,6 +608,7 @@ while test $# -gt 0; do
       echo "  --libs                Print regular ROOT libraries"
       echo "  --glibs               Print regular + GUI ROOT libraries"
       echo "  --cflags              Print compiler flags and header path"
+      echo "  --ldflags             Print linker flags"
       echo "  --bindir              Print the executable directory"
       echo "  --libdir              Print the library directory"
       echo "  --incdir              Print the header directory"
diff --git a/configure b/configure
index 81c1933d6af..6da636fc4cb 100755
--- a/configure
+++ b/configure
@@ -471,6 +471,7 @@ guess_architecture () {
         linux:x86_64:*)        arch=linuxx8664gcc   ;;
         linux:alpha:*)         arch=linuxalphaegcs  ;;
         linux:arm*:*)          arch=linuxarm        ;;
+        linux:ppc64*:*)        arch=linuxppc64gcc   ;;
         linux:ppc*:*)          arch=linuxppcegcs    ;;
         linux:i*86:*)          arch=linux           ;;
         openbsd*:*:*)          arch=openbsd         ;;
@@ -719,7 +720,7 @@ platform=`grep "^PLATFORM *=" config/Makefile.$arch | awk '{ print $3 }'`
 case $arch in
 sgicc)
    checklib32="yes" ;;
-linuxx8664*|sgicc64)
+linuxx8664*|linuxppc64*|sgicc64)
    checklib64="yes" ;;
 hpuxia64acc)
    checkhpux64="yes" ;;
diff --git a/freetype/Module.mk b/freetype/Module.mk
index c63d810ba49..59f101e4e44 100644
--- a/freetype/Module.mk
+++ b/freetype/Module.mk
@@ -84,6 +84,10 @@ else
 			FREECC="cc"; \
 			ARCH_CFLAGS="-64"; \
 		fi; \
+		if [ $(ARCH) = "linuxppc64gcc" ]; then \
+			FREECC="gcc -m64"; \
+			ARCH_CFLAGS="-m64"; \
+		fi; \
 		if [ $(ARCH) = "hpuxia64acc" ]; then \
 			FREECC="cc"; \
 			ARCH_CFLAGS="+DD64 -Ae"; \
diff --git a/test/Makefile.arch b/test/Makefile.arch
index de9a8caec91..88703af2ceb 100644
--- a/test/Makefile.arch
+++ b/test/Makefile.arch
@@ -17,6 +17,7 @@ DllSuf        = so
 OutPutOpt     = -o # keep whitespace after "-o"
 
 ROOTCFLAGS   := $(shell root-config --cflags)
+ROOTLDFLAGS  := $(shell root-config --ldflags)
 ROOTLIBS     := $(shell root-config --libs)
 ROOTGLIBS    := $(shell root-config --glibs)
 HASTHREAD    := $(shell root-config --has-thread)
@@ -349,6 +350,15 @@ LDFLAGS       = -O2
 SOFLAGS       = -shared
 endif
 
+ifeq ($(ARCH),linuxppc64gcc)
+# PPC64 Linux with gcc 3.x
+CXX           = g++
+CXXFLAGS      = -O2 -Wall -fPIC
+LD            = g++
+LDFLAGS       = -O2
+SOFLAGS       = -shared
+endif
+
 ifeq ($(ARCH),linuxx8664icc)
 # AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc compiler
 CXX           = icc
@@ -524,5 +534,6 @@ $(error $(ARCH) invalid architecture)
 endif
 
 CXXFLAGS     += $(ROOTCFLAGS)
+LDFLAGS      += $(ROOTLDFLAGS)
 LIBS          = $(ROOTLIBS) $(SYSLIBS)
 GLIBS         = $(ROOTGLIBS) $(SYSLIBS)
-- 
GitLab