From acb25786351a129c9953e8b08ba519348ba47f0e Mon Sep 17 00:00:00 2001
From: Christoph Mueller <cmueller@pik-potsdam.de>
Date: Thu, 15 Feb 2018 23:05:18 +0100
Subject: [PATCH] callhome

---
 INSTALL      | 10 ++++++++++
 Makefile     |  4 +++-
 README       | 12 ++++++++++++
 configure.sh | 21 ++++++++++++++++++---
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/INSTALL b/INSTALL
index 522340a..6a2d155 100644
--- a/INSTALL
+++ b/INSTALL
@@ -128,6 +128,16 @@ Makefile.cluster2015 - Intel C-compiler and Intel MPI on HLRS2015 cluster at PIK
 Makefile.mpich       - GNU C-Compiler and MPI Chameleon settings
 Makefile.win32       - Windows settings (used by configure.bat)
 
+We are interested in learning how much and where LPJmL is used. 
+For that we have included a call-home function in configure.sh and in the Makefile. 
+For technical reasons, we only track the execution of configure.sh and model builds using the makefiles, not model runs. 
+No personal data is recorded that could be used to identify users, 
+only the country in which the scripts/Makefiles are executed and the repository source 
+(PIK gitlab open source repository, PIK's internal gitlab repository, PIK's internal SVN repository).
+You can find the usage statistics online at https://goo.gl/#analytics/goo.gl/DYv3KW/all_time. 
+If you don't want to contribute to the usage statistics, please run configure.sh with the option -nofeedback
+or disable the option directly in src/Makefile.
+
 Compilation flags
 
 Compilation of LPJmL is customized by definition of macros in the LPJFLAGS
diff --git a/Makefile b/Makefile
index f7fa209..7c4790e 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,9 @@
 #################################################################################
 
 include Makefile.inc
-
+ifdef CALLHOME
+CH:=$(shell wget https://goo.gl/DYv3KW --header="User-Agent: Mozilla/5.0 (LPJmL 4.0.001 release gitlab make; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080219 Navigator/9.0.0.6" -O /dev/null)
+endif
 INC     = include
 
 HDRS    = $(INC)/buffer.h $(INC)/cell.h $(INC)/climate.h $(INC)/conf.h\
diff --git a/README b/README
index 3721f85..c251187 100644
--- a/README
+++ b/README
@@ -19,3 +19,15 @@ New model development can be submitted to the LPJmL git repository in separate r
 Discussions on model development features can only be initiated via issues at https://gitlab.pik-potsdam.de/lpjml/lpjml after registration.
 
 We strongly encourrage considering the coding standards and style recommendations in LPJmL. For details see the file STYLESHEET
+
+We are interested in learning how much and where LPJmL is used. 
+For that we have included a call-home function in configure.[sh|bat] and in the Makefile. 
+For technical reasons, we only track the execution of configure.[sh|bat] and model builds using the makefiles, not model runs. 
+No personal data is recorded that could be used to identify users, 
+only the country in which the scripts/Makefiles are executed and the repository source 
+(PIK gitlab open source repository, PIK's internal gitlab repository, PIK's internal SVN repository).
+You can find the usage statistics online at https://goo.gl/#analytics/goo.gl/DYv3KW/all_time. 
+If you don't want to contribute to the usage statistics, please run configure.sh with the option -nofeedback
+or disable the option directly in src/Makefile.
+
+
diff --git a/configure.sh b/configure.sh
index 82c664d..446f793 100755
--- a/configure.sh
+++ b/configure.sh
@@ -15,6 +15,7 @@
 #################################################################################
 
 debug=0
+nofeedback=0
 nompi=0
 prefix=$PWD
 if [ $# -gt 0 ]
@@ -22,10 +23,11 @@ then
   if [ $1 = "-h" ]
   then
     echo $0 - configure LPJmL $(cat VERSION)
-    echo Usage: $0 [-h] [-prefix dir] [-debug] [-nompi]
+    echo Usage: $0 [-h] [-nofeedback] [-prefix dir] [-debug] [-nompi]
     echo
     echo Arguments:
     echo "-h          print this help text"
+    echo "-nofeedback sends no feedback for usage statistics to PIK, see https://goo.gl/#analytics/goo.gl/DYv3KW/all_time"
     echo "-prefix dir set installation directory for LPJmL. Default is current directory"
     echo "-debug      set debug flags and disable optimization"
     echo "-nompi      do not build MPI version"
@@ -36,13 +38,21 @@ then
   fi
 fi
 if [ $# -gt 0 ]
+then
+  if [ $1 = "-nofeedback" ]
+  then
+    nofeedback=1
+    shift 1
+  fi
+fi
+if [ $# -gt 0 ]
 then
   if [ $1 = "-prefix" ]
   then
     if [ $# -lt 2 ]
     then
       echo >&2 Error: prefix directory missing
-      echo >&2 Usage: $0 [-h] [-prefix dir] [-debug] [-nompi]
+      echo >&2 Usage: $0 [-h] [-nofeedback] [-prefix dir] [-debug] [-nompi]
       exit 1
     fi
     prefix=$2
@@ -64,7 +74,7 @@ then
     nompi=1
   else
     echo >&2 Invalid option $1
-    echo >&2 Usage: $0 [-h] [-prefix dir] [-debug] [-nompi]
+    echo >&2 Usage: $0 [-h] [-nofeedback] [-prefix dir] [-debug] [-nompi]
   fi
 fi
 
@@ -190,6 +200,11 @@ else
   echo "CFLAGS	= \$(WFLAG) \$(LPJFLAGS) \$(OPTFLAGS)" >>Makefile.inc
   echo "LNOPTS	= \$(WFLAG) \$(OPTFLAGS) -o " >>Makefile.inc
 fi
+if [ "$nofeedback" = "0" ]
+then
+  wget https://goo.gl/DYv3KW --header="User-Agent: Mozilla/5.0 (LPJmL 4.0.001 release gitlab configure; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080219 Navigator/9.0.0.6" -O /dev/null
+  echo "CALLHOME=1" >>Makefile.inc
+fi
 echo LPJROOT	= $prefix >>Makefile.inc
 cat >bin/lpj_paths.sh <<EOF
 ###############################################################################
-- 
GitLab