From c2c68a47ac420eb0b7d2391dc824a83b6bba0995 Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Thu, 4 Dec 2014 15:30:52 +0000
Subject: [PATCH] fix few issues of the OAI build tool for ubuntu 12.04

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6170 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 targets/build_helper.bash | 58 +++++++++++++++++++++++++++++++++++++--
 targets/build_oai.bash    |  3 +-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/targets/build_helper.bash b/targets/build_helper.bash
index f10cc1d04a..4909d384ab 100755
--- a/targets/build_helper.bash
+++ b/targets/build_helper.bash
@@ -157,6 +157,55 @@ make_certs(){
 
 }
 
+check_install_nettle(){
+    if [ ! -f ./.lock_oaibuild ]; then 
+	if [ $UBUNTU_REL = "12.04" ]; then 
+	    test_uninstall_package nettle-dev
+	    test_uninstall_package nettle-bin
+	
+	    if [ ! -d /usr/local/src/ ]; then
+		echo "/usr/local/src/ doesn't exist please create one"
+		exit -1
+	    fi
+	    
+	    if [ ! -w /usr/local/src/ ];  then
+		echo "You don't have permissions to write to /usr/local/src/, installing as a sudoer"
+		#	exit -1
+	    fi
+	    
+	    cd /usr/local/src/
+	    
+	    echo "Downloading nettle archive"
+	    
+	    if [ -f nettle-2.5.tar.gz ]; then
+		$SUDO rm -f nettle-2.5.tar.gz
+	    fi
+	    if [ -f nettle-2.5.tar ]; then
+		$SUDO rm -f nettle-2.5.tar
+	    fi
+	    if [ -d nettle-2.5 ];  then
+		$SUDO rm -rf nettle-2.5/
+	    fi
+	    
+	    
+	    $SUDO wget ftp://ftp.lysator.liu.se/pub/security/lsh/nettle-2.5.tar.gz 
+	    $SUDO gunzip nettle-2.5.tar.gz 
+	    $SUDO echo "Uncompressing nettle archive"
+	    $SUDO tar -xf nettle-2.5.tar
+	    cd nettle-2.5/
+	    $SUDO ./configure --disable-openssl --enable-shared --prefix=/usr 
+	    if [ $? -ne 0 ]; then
+		exit -1
+	    fi
+	    echo "Compiling nettle"
+	    $SUDO make -j $NUM_CPU  
+	    $SUDO make check 
+	    $SUDO make install 
+	    cd ../
+	fi
+    fi
+}
+
 check_install_freediamter(){
     
     if [ $UBUNTU_REL = "12.04" ]; then 
@@ -647,8 +696,13 @@ compile_ltesoftmodem() {
 	make  $SOFTMODEM_DIRECTIVES 
 	make -j $NUM_CPU $SOFTMODEM_DIRECTIVES 
         if [ $? -ne 0 ]; then
-            echo_error "Build lte-softmodem failed, returning"
-            return 1
+            if [ ! -f ./lte-softmodem ]; then 
+		echo_error "Build lte-softmodem failed, returning"
+		return 1
+	    else 
+		cp -f ./lte-softmodem  $OPENAIR_TARGETS/bin
+		return 0	
+	    fi 
 	else
 	    cp -f ./lte-softmodem  $OPENAIR_TARGETS/bin
 	    return 0
diff --git a/targets/build_oai.bash b/targets/build_oai.bash
index a0db324e68..650f894258 100755
--- a/targets/build_oai.bash
+++ b/targets/build_oai.bash
@@ -312,7 +312,8 @@ build_enb(){
 	check_install_usrp_uhd_driver 
     fi
     check_install_asn1c
-
+    check_install_nettle
+    
 ############################################
 # compile 
 ############################################
-- 
GitLab