From 4500bb8543e3245bfb32460ab0462df764656325 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Mon, 29 Oct 2012 17:43:13 +0000
Subject: [PATCH] Fix static linking of roota and libRoot.a in  the cases of
 OSX Cocoa backend and in case of Cling. In Cling case there is still a
 startup issuse, to be fixed next.

git-svn-id: http://root.cern.ch/svn/root/trunk@46879 27541ba8-7e3a-0410-8455-c3a389f83636
---
 Makefile                       |  5 +++--
 build/unix/makestatic.sh       | 19 +++++++------------
 build/unix/staticobjectlist.sh |  5 +++++
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index aa90698da3f..f5762cae58e 100644
--- a/Makefile
+++ b/Makefile
@@ -501,7 +501,8 @@ ROOTMAP       = etc/system.rootmap
 
 ##### Extra libs needed for "static" target #####
 
-STATICEXTRALIBS = $(PCRELDFLAGS) $(PCRELIB) \
+STATICEXTRALIBS = $(CLINGLIBEXTRA) \
+                  $(PCRELDFLAGS) $(PCRELIB) \
                   $(FREETYPELDFLAGS) $(FREETYPELIB)
 ifneq ($(SSLLIB),)
 STATICEXTRALIBS += $(SSLLIB)
@@ -510,7 +511,7 @@ ifeq ($(XFTLIB),yes)
 STATICEXTRALIBS += -lXft
 endif
 ifeq ($(BUILDCOCOA),yes)
-STATICEXTRALIBS += -framework Cocoa
+STATICEXTRALIBS += -framework Cocoa -framework OpenGL
 endif
 
 ##### libCore #####
diff --git a/build/unix/makestatic.sh b/build/unix/makestatic.sh
index 7dfe79cb0e7..894821c98fd 100755
--- a/build/unix/makestatic.sh
+++ b/build/unix/makestatic.sh
@@ -23,18 +23,15 @@ rm -f $ROOTAEXE $PROOFAEXE
 
 gobjs=`$STATICOBJECTLIST -d`
 
-dummyc=R__dummy.c
-dummyo=""
-if [ $PLATFORM = "alpha" ] && [ $CXX = "cxx" ]; then
-   echo 'void dnet_conn() {}' > $dummyc
-   $CC -c $dummyc
-   dummyo=R__dummy.o
+# If linking with Cocoa framework, then don't use XLIBS
+if echo $EXTRALIBS | grep ' Cocoa' > /dev/null 2>& 1 ; then
+    XLIBS=
 fi
 
 echo "Making $ROOTAEXE..."
-echo $LD $LDFLAGS -o $ROOTAEXE main/src/rmain.o $dummyo $gobjs $ROOTALIB \
+echo $LD $LDFLAGS -o $ROOTAEXE main/src/rmain.o $gobjs $ROOTALIB \
    $XLIBS $SYSLIBS $EXTRALIBS
-$LD $LDFLAGS -o $ROOTAEXE main/src/rmain.o $dummyo $gobjs $ROOTALIB \
+$LD $LDFLAGS -o $ROOTAEXE main/src/rmain.o $gobjs $ROOTALIB \
    $XLIBS $SYSLIBS $EXTRALIBS
 
 linkstat=$?
@@ -43,9 +40,9 @@ if [ $linkstat -ne 0 ]; then
 fi
 
 echo "Making $PROOFAEXE..."
-echo $LD $LDFLAGS -o $PROOFAEXE main/src/pmain.o $dummyo $gobjs $ROOTALIB \
+echo $LD $LDFLAGS -o $PROOFAEXE main/src/pmain.o $gobjs $ROOTALIB \
    $XLIBS $SYSLIBS $EXTRALIBS
-$LD $LDFLAGS -o $PROOFAEXE main/src/pmain.o $dummyo $gobjs $ROOTALIB \
+$LD $LDFLAGS -o $PROOFAEXE main/src/pmain.o $gobjs $ROOTALIB \
    $XLIBS $SYSLIBS $EXTRALIBS
 
 linkstat=$?
@@ -53,6 +50,4 @@ if [ $linkstat -ne 0 ]; then
    exit $linkstat
 fi
 
-rm -f $dummyc $dummyo
-
 exit 0
diff --git a/build/unix/staticobjectlist.sh b/build/unix/staticobjectlist.sh
index 0b2e8448937..9553b6fe6a6 100755
--- a/build/unix/staticobjectlist.sh
+++ b/build/unix/staticobjectlist.sh
@@ -50,6 +50,11 @@ for i in * ; do
    fi
 done
 
+# add Cling objects
+for i in Interpreter MetaProcessor Utils ; do
+   ls interpreter/cling/lib/$i/*.o > /dev/null 2>&1 && objs="$objs `ls interpreter/cling/lib/$i/*.o`"
+done
+
 if [ "x$dictonly" = "xyes" ]; then
    echo $gobjs
 else
-- 
GitLab