From 081b07836bb13de4cfa6c2cc2599b446b1222002 Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Wed, 17 Sep 2014 13:40:01 +0000
Subject: [PATCH] * additional updates for the OAI build script

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

diff --git a/targets/Makefile b/targets/Makefile
index 54a16257aa..b604898d2a 100644
--- a/targets/Makefile
+++ b/targets/Makefile
@@ -7,7 +7,7 @@ build_rtai:
 	./build_oai.bash -c -b -eRTAI -tSOFTMODEM  -m
 
 build_usrp_rtai:
-	./build_oai.bash -c -b -eRTAI -tSOFTMODEM -hUSRP -m
+	./build_oai.bash -c -b -eRTAI -tSOFTMODEM -wUSRP -m
 
 
 help:
diff --git a/targets/build_helper.bash b/targets/build_helper.bash
index cb21f6fdd6..8cad33de9b 100755
--- a/targets/build_helper.bash
+++ b/targets/build_helper.bash
@@ -72,7 +72,7 @@ test_install_package() {
       } || {
           echo "$1 is not installed." 
 	  OAI_INSTALLED=0
-          $SUDO apt-get install --assume-yes $1  
+          $SUDO apt-get install --force-yes $1  
       }
   fi
 }
@@ -668,13 +668,13 @@ install_ltesoftmodem() {
     if [ $1 = "RTAI" ]; then 
 	if [ ! -f /tmp/init_rt_done.tmp ]; then
             echo_info "  8.1 Insert RTAI modules"
-            insmod /usr/realtime/modules/rtai_hal.ko     > /dev/null 2>&1
-            insmod /usr/realtime/modules/rtai_sched.ko   > /dev/null 2>&1
-            insmod /usr/realtime/modules/rtai_sem.ko     > /dev/null 2>&1
-            insmod /usr/realtime/modules/rtai_fifos.ko   > /dev/null 2>&1
-            insmod /usr/realtime/modules/rtai_mbx.ko     > /dev/null 2>&1
-            touch /tmp/init_rt_done.tmp
-            chmod 666 /tmp/init_rt_done.tmp
+            $SUDO$ insmod /usr/realtime/modules/rtai_hal.ko     > /dev/null 2>&1
+            $SUDO$ insmod /usr/realtime/modules/rtai_sched.ko   > /dev/null 2>&1
+            $SUDO$ insmod /usr/realtime/modules/rtai_sem.ko     > /dev/null 2>&1
+            $SUDO$ insmod /usr/realtime/modules/rtai_fifos.ko   > /dev/null 2>&1
+            $SUDO$ insmod /usr/realtime/modules/rtai_mbx.ko     > /dev/null 2>&1
+            $SUDO$ touch /tmp/init_rt_done.tmp
+            $SUDO$ chmod 666 /tmp/init_rt_done.tmp
         else
             echo_warning "  8.1 RTAI modules already inserted"
         fi
@@ -689,7 +689,7 @@ install_ltesoftmodem() {
 	for i in `seq 0 64`; do 
 	    have_rtfX=`ls /dev/ |grep -c rtf$i`;
 	    if [ "$have_rtfX" -eq 0 ] ; then 
-		mknod -m 666 /dev/rtf$i c 150 $i; 
+		$SUDO$ mknod -m 666 /dev/rtf$i c 150 $i; 
 	    fi;
 	done
 	echo_info "  8.3 [EXMIMO] Build lte-softmodemdrivers"
@@ -741,6 +741,26 @@ set_openair_env(){
     fi
 
 }
+
+########################################
+### print help
+######################################
+
+print_help(){
+    echo_success "Name : build_oai  - install and build OAI"
+    echo_success "Usage: build_oai.bash -b -c -d -eRTAI -m -rREL8 -s -tOAISIM -wEXMIMO -x"
+    echo_success "-b   : enables S1 interface for eNB (default enabled)"
+    echo_success "-c   : enables clean OAI build (default disabled)"
+    echo_success "-d   : enables debug mode (default disabled)"
+    echo_success "-e   : sets realtime mode: RTAI, RT_PREEMPT, RT_DISABLED (default RTAI)"
+    echo_success "-m   : enables build from the makefile (default disabled)"
+    echo_success "-r   : sets the release: REL8, REL10 (default REL8)"
+    echo_success "-s   : enables OAI sanity check (default disabled)"
+    echo_success "-t   : sets the build target: ALL, SOFTMODEM,OAISIM,UNISIM (default ALL)"
+    echo_success "-w   : sets the hardware platform: EXMIMO, USRP, NONE, (default EXMIMO)"
+    echo_success "-x   : enables xforms (default disabled)"
+    echo_success "-z   : sets the default build options"
+}
 ###############################
 ## echo and  family 
 ###############################
diff --git a/targets/build_oai.bash b/targets/build_oai.bash
index 6e3ddc0574..3759918856 100755
--- a/targets/build_oai.bash
+++ b/targets/build_oai.bash
@@ -53,7 +53,6 @@ REL="REL8" # REL8, REL10
 RT="RTAI" # RTAI, RT_PREMPT or RT_DISABLED
 DEBUG=0
 
-ENB_CONFIG_FILE=$OPENAIR_TARGETS/"PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.conf"
 OAI_TEST=0
 XFORMS=0
 
@@ -83,7 +82,7 @@ fi
 #    echo "i is : $i"
 #    case $i in
 
-while getopts "bcdmsxze:f:h:r:t:" OPTION; do
+while getopts "bcdmsxzhe:w:r:t:" OPTION; do
    case "$OPTION" in
        b)
 	   ENB_S1=1
@@ -102,18 +101,14 @@ while getopts "bcdmsxze:f:h:r:t:" OPTION; do
 	   RT="$OPTARG"
 	   echo "setting realtime flag to: $RT"
 	   ;;
-       f)
-	   ENB_CONFIG_FILE="$OPTARG" 
-	   echo "setting enb config file path to: $ENB_CONFIG_FILE"
-	   ;;
        h)
-	   HW="$OPTARG" #"${i#*=}"
-	   echo "setting hardware to: $HW"
+	   print_help
+	   exit -1
 	   ;;
        m)
 	   BUILD_FROM_MAKEFILE=1
 	   set_build_from_makefile $BUILD_FROM_MAKEFILE
-	   echo "setting build from make to: $BUILD_FROM_MAKEFILE"
+	   echo "setting a flag to build from makefile to: $BUILD_FROM_MAKEFILE"
 	   ;;
        r)
 	   REL="$OPTARG" 
@@ -127,6 +122,10 @@ while getopts "bcdmsxze:f:h:r:t:" OPTION; do
 	   TARGET="$OPTARG" 
 	   echo "setting target to: $TARGET"
 	   ;;
+       w)
+	   HW="$OPTARG" #"${i#*=}"
+	   echo "setting hardware to: $HW"
+	   ;;
        x)
 	   XFORMS=1
 	   echo "setting xforms to: $XFORMS"
@@ -178,10 +177,8 @@ touch bin/${oai_build_date}
 echo_info "2. Process the parameters"
 
 echo_info "User-defined Parameters :  HW=$HW, TARGET=$TARGET, ENB_S1=$ENB_S1, REL=$REL, RT=$RT, DEBUG=$DEBUG XFORMS=$XFORMS"
-echo_info "ENB_CONFIG_FILE: $ENB_CONFIG_FILE"
 
 echo "User-defined Parameters :  HW=$HW, TARGET=$TARGET, ENB_S1=$ENB_S1, REL=$REL, RT=$RT, DEBUG=$DEBUG XFORMS=$XFORMS" >> bin/${oai_build_date}
-echo "ENB_CONFIG_FILE: $ENB_CONFIG_FILE" >>  bin/${oai_build_date}
 
  
 ############################################
@@ -211,12 +208,12 @@ else
     OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel10=1 "
 fi
 if [ $RT = "RTAI" ]; then 
-    if [ -f /usr/realtime/modules ];   then
-	SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES HARD_RT=1 "
-    else 
+    if [ ! -f /usr/realtime/modules/rtai_hal.ko ];   then
 	echo_warning "RTAI doesn't seem to be installed"
 	RT="RT_PREMPT"
 	SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 "
+    else 
+	SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES HARD_RT=1 "
     fi
 fi
 
-- 
GitLab