From 12eb73732abdcf3c195a04072376d314e125045e Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Wed, 28 Sep 2005 15:08:33 +0000
Subject: [PATCH] From Gerri: This small patch allows to use a XROOTD version
 different from the one shipped with ROOT to build the client
 (--with-xrootd=<alternative_dist>). This is a first step to be more flexible
 with XROOTD ...

git-svn-id: http://root.cern.ch/svn/root/trunk@12863 27541ba8-7e3a-0410-8455-c3a389f83636
---
 Makefile           |  4 +++
 config/Makefile.in |  1 +
 configure          | 81 +++++++++++++++++++++++++++-------------------
 netx/Module.mk     |  6 ++++
 4 files changed, 59 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 4351705bf56..e358a2b512b 100644
--- a/Makefile
+++ b/Makefile
@@ -155,8 +155,12 @@ ifeq ($(BUILDHBOOK),yes)
 MODULES      += hbook
 endif
 ifeq ($(BUILDXRD),yes)
+ifneq ($(XROOTDDIR),)
+MODULES      += netx
+else
 MODULES      += xrootd netx
 endif
+endif
 ifeq ($(BUILDCLARENS),yes)
 MODULES      += clarens
 endif
diff --git a/config/Makefile.in b/config/Makefile.in
index 9e820733a05..20877097ff8 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -149,6 +149,7 @@ XMLCLILIB      := @xmllib@
 XMLINCDIR      := $(filter-out /usr/include, @xmlincdir@)
 
 BUILDXRD       := @buildxrd@
+XROOTDDIR      := @xrootddir@
 
 SRPLIBDIR      := @srplibdir@
 SRPLIB         := @srplib@
diff --git a/configure b/configure
index e8456d22086..f79b4a2cb39 100755
--- a/configure
+++ b/configure
@@ -755,6 +755,7 @@ with options, prefix with --with-, enables corresponding support
   xml-libdir         XML support, location of libxml2
   x11-libdir         X11 support, path to libX11
   xpm-libdir         XPM support, path to libXpm
+  xrootd             XROOTD support, path to alternative XROOTD distribution
 
 Supported Architectures:
 
@@ -903,6 +904,7 @@ if test $# -gt 0 ; then
       --with-xml-libdir=*)     xmllibdir=$optarg     ; enable_xml="yes"     ;;
       --with-x11-libdir=*)     x11libdir=$optarg     ;;
       --with-xpm-libdir=*)     xpmlibdir=$optarg     ;;
+      --with-xrootd=*)         xrootddir=$optarg     ; enable_xrootd="yes"  ;;
       ################################################################
       #
       # Enable/disable to turn on/off third party software linkage and
@@ -1960,45 +1962,57 @@ fi
 message "Checking whether to build xrootd"
 xrdcomm=""
 
-# Xrootd and its client need thread support
-if test "x$enable_thread" = "xyes"; then
-    # Ok, now check the architecture
-    case $arch in
-    # The server builds on Linux and Solaris only (for the time being)
-    linux*)
-        if test "x$enable_xrootd" = "x"; then
-            enable_xrootd="yes"
-        fi
-        ;;
-    macos*)
-        if test "x$enable_xrootd" = "x"; then
-            enable_xrootd="yes"
-        fi
-        ;;
-    solaris*)
+# If we are required to use an external XROOTD distribution
+# we just define the pointers
+if test ! "x$xrootddir" = "x"; then
+
+   # We do not need to build, just the paths for includes and libs
+   xrdcomm="no, using xrootd at $xrootddir"
+
+else
+
+   # Xrootd and its client need thread support
+   if test "x$enable_thread" = "xyes"; then
+       # Ok, now check the architecture
+       case $arch in
+       # The server builds on Linux and Solaris only (for the time being)
+       linux*)
            if test "x$enable_xrootd" = "x"; then
-              enable_xrootd="yes"
+               enable_xrootd="yes"
            fi
-        ;;
-    *)
-        if test "x$enable_xrootd" = "xyes"; then
-            enable_xrootd="yes"
-            xrdcomm=", but not officially supported"
-        else
-            enable_xrootd="no"
-        fi
-        ;;
-    esac
-else
-   if test "x$enable_xrootd" = "xyes"; then
-      enable_xrootd="no"
-      xrdcomm=", needs thread support (rerun with --enable-thread)"
+           ;;
+       macos*)
+           if test "x$enable_xrootd" = "x"; then
+               enable_xrootd="yes"
+           fi
+           ;;
+       solaris*)
+              if test "x$enable_xrootd" = "x"; then
+                 enable_xrootd="yes"
+              fi
+           ;;
+       *)
+           if test "x$enable_xrootd" = "xyes"; then
+               enable_xrootd="yes"
+               xrdcomm=", but not officially supported"
+           else
+               enable_xrootd="no"
+           fi
+           ;;
+       esac
    else
-      enable_xrootd="no"
+      if test "x$enable_xrootd" = "xyes"; then
+         enable_xrootd="no"
+         xrdcomm=", needs thread support (rerun with --enable-thread)"
+      else
+         enable_xrootd="no"
+      fi
    fi
+
+   xrdcomm="$enable_xrootd$xrdcomm"
 fi
 
-echo $enable_xrootd$xrdcomm
+echo $xrdcomm
 
 if test "x$enable_xrootd" = "xyes"; then
     buildxrd="yes"
@@ -3271,6 +3285,7 @@ sed -e "s|@ldflags@||"                          \
     -e "s|@x11libdir@|$x11libdir|"              \
     -e "s|@xpmlib@|$xpmlib|"                    \
     -e "s|@xpmlibdir@|$xpmlibdir|"              \
+    -e "s|@xrootddir@|$xrootddir|"              \
     -e "s|@buildgl@|$enable_opengl|"            \
     -e "s|@buildhbook@|$enable_cern|"           \
     -e "s|@buildldap@|$enable_ldap|"            \
diff --git a/netx/Module.mk b/netx/Module.mk
index e12608d22d0..762786eeafe 100644
--- a/netx/Module.mk
+++ b/netx/Module.mk
@@ -32,6 +32,12 @@ ALLLIBS      += $(NETXLIB)
 # include all dependency files
 INCLUDEFILES += $(NETXDEP)
 
+# These are undefined if using an external XROOTD distribution
+ifeq ($(XROOTDDIRI),)
+XROOTDDIRI   := $(XROOTDDIR)/src
+XROOTDDIRL   := $(XROOTDDIR)/lib
+endif
+
 # Xrootd includes
 NETXINCEXTRA := $(XROOTDDIRI:%=-I%)
 
-- 
GitLab