Commit c3bde8bb authored by Lionel Gauthier's avatar Lionel Gauthier

changed getopt that do not take long arguments in bash.

May have a look at https://code.google.com/p/shflags/downloads/list

#!/bin/sh

# source shflags from current directory
. ./shflags

# define a 'name' command-line string flag
DEFINE_string 'name' 'world' 'name to say hello to' 'n'

# parse the command-line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"

# say hello
echo "Hello, ${FLAGS_name}!"

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6212 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 61feb989
...@@ -984,19 +984,23 @@ set_openair_env(){ ...@@ -984,19 +984,23 @@ set_openair_env(){
print_help(){ print_help(){
echo_success "Name : build_oai - install and build OAI" echo_success "Name : build_oai - install and build OAI"
echo_success "Usage: build_oai.bash -a -b -c -d -eRTAI -m -rREL8 -s -tOAISIM -wEXMIMO -x" echo_success "Usage: build_oai.bash -a -b -c -d -eRTAI -m -rREL8 -s -tOAISIM -wEXMIMO -x"
echo_success "-a : enable doxygen for documentation (default disabled)" echo_success "-a | --doxygen : Enable doxygen for documentation (default disabled)"
echo_success "-b : disables S1 interface for eNB (default enabled)" echo_success "-b | --disable-s1 : Disables S1 interface for eNB (default enabled)"
echo_success "-c : enables clean OAI build (default disabled)" echo_success "-c | --clean : Enables clean OAI build (default disabled)"
echo_success "-d : enables debug mode (default disabled)" echo_success "-C | --config-file : Set the config file local path"
echo_success "-e : sets realtime mode: RTAI, NONE (default NONE)" echo_success "-d | --debug : Enables debug mode (default disabled)"
echo_success "-l : sets the LTE build target: ENB,EPC,HSS,NONE (default ENB)" echo_success "-e | --realtime : Sets realtime mode: RTAI, NONE (default NONE)"
echo_success "-m : enables build from the makefile (default disabled)" echo_success "-g | --run-with-gdb : Run with gdb"
echo_success "-r : sets the release: REL8, REL10 (default REL8)" echo_success "-K | --itti-dump-file : Set the execution events trace file"
echo_success "-s : enables OAI testing and sanity check (default disabled)" echo_success "-l | --build-target : Sets the LTE build target: ENB,EPC,HSS,NONE (default ENB)"
echo_success "-t : sets the eNB build target: ALL, SOFTMODEM,OAISIM,UNISIM (default ALL)" echo_success "-m | --build-from-makefile : Enables build from the makefile (default disabled)"
echo_success "-w : sets the hardware platform: EXMIMO, USRP (also installs UHD driver), ETHERNET, NONE, (default EXMIMO)" echo_success "-r | --3gpp-release : Sets the release: REL8, REL10 (default REL8)"
echo_success "-x : enables xforms (default disabled)" echo_success "-s | --check : Enables OAI testing and sanity check (default disabled)"
echo_success "-z : sets the default build options" echo_success "-t | --enb-build-target : Sets the eNB build target: ALL, SOFTMODEM,OAISIM,UNISIM (default ALL)"
echo_success "-V | --vcd : Log vcd events"
echo_success "-w | --hardware : sets the hardware platform: EXMIMO, USRP (also installs UHD driver), ETHERNET, NONE, (default EXMIMO)"
echo_success "-x | --xforms : enables xforms (default disabled)"
echo_success "-z | --defaults : sets the default build options"
} }
############################### ###############################
## echo and family ## echo and family
......
...@@ -47,28 +47,31 @@ check_for_root_rights ...@@ -47,28 +47,31 @@ check_for_root_rights
###################################### ######################################
#only one could be set at the time #only one could be set at the time
BUILD_LTE="ENB" # ENB, EPC, HSS, NONE declare BUILD_LTE="ENB" # ENB, EPC, HSS, NONE
HW="EXMIMO" # EXMIMO, USRP, ETHERNET, NONE declare HW="EXMIMO" # EXMIMO, USRP, ETHERNET, NONE
TARGET="ALL" # ALL, SOFTMODEM, OAISIM, UNISIM, NONE declare TARGET="ALL" # ALL, SOFTMODEM, OAISIM, UNISIM, NONE
ENB_S1=1 declare ENB_S1=1
REL="REL8" # REL8, REL10 declare REL="REL8" # REL8, REL10
RT="NONE" # RTAI, RT_PREMPT or RT_DISABLED, NONE declare RT="NONE" # RTAI, RT_PREMPT or RT_DISABLED, NONE
DEBUG=0 declare DEBUG=0
declare CONFIG_FILE=""
declare EXE_ARGUMENTS=""
OAI_TEST=0 declare RUN_GDB=0
XFORMS=0 declare DISABLE_CHECK_INSTALLED_SOFTWARE=0
declare OAI_TEST=0
declare XFORMS=0
# script is not currently handling these params # script is not currently handling these params
EPC=0 # flag to build EPC declare EPC=0 # flag to build EPC
ITTI_ANALYZER=0 declare ITTI_ANALYZER=0
VCD_TIMING=0 declare VCD_TIMING=0
WIRESHARK=0 declare WIRESHARK=0
TIME_MEAS=0 declare TIME_MEAS=0
DOXYGEN=0 declare DOXYGEN=0
DEV=0 declare DEV=0
EMULATION_DEV_INTERFACE="eth0" EMULATION_DEV_INTERFACE="eth0"
EMULATION_MULTICAST_GROUP=1 EMULATION_MULTICAST_GROUP=1
...@@ -87,64 +90,107 @@ fi ...@@ -87,64 +90,107 @@ fi
# echo "i is : $i" # echo "i is : $i"
# case $i in # case $i in
while getopts "abcdmsxzhe:l:w:r:t:" OPTION; do
case "$OPTION" in
a) while true; do
case "$1" in
-a | --doxygen)
DOXYGEN=1 DOXYGEN=1
echo "setting doxygen flag to: $DOXYGEN" echo "setting doxygen flag to: $DOXYGEN"
shift;
;; ;;
b) -b | --disable-s1)
ENB_S1=0 ENB_S1=0
echo "disable eNB S1 flag" echo "disable eNB S1 flag"
shift;
;; ;;
c) -c | --clean)
rm -rf ./.lock_oaibuild rm -rf ./.lock_oaibuild
OAI_CLEAN=1 OAI_CLEAN=1
echo "setting clean flag to: $OAI_CLEAN" echo "setting clean flag to: $OAI_CLEAN"
echo "check package installation, and recompile OAI" echo "may check package installation, and recompile OAI"
shift;
;; ;;
d) -C | --config-file)
CONFIG_FILE=$2
echo "setting config file to: $CONFIG_FILE"
EXE_ARGUMENTS ="$EXE_ARGUMENTS -O $CONFIG_FILE"
shift 2;
;;
-d | --debug)
DEBUG=1 DEBUG=1
echo "setting debug flag to: $DEBUG" echo "setting debug flag to: $DEBUG"
shift;
;;
-D | --disable-check-installed-software)
DISABLE_CHECK_INSTALLED_SOFTWARE=1
echo "disable check installed software"
shift;
;; ;;
e) -e | --realtime)
RT="$OPTARG" RT="$2"
echo "setting realtime flag to: $RT" echo "setting realtime flag to: $RT"
shift 2 ;
;;
-g | --run-with-gdb)
RUN_GDB=1
echo "Running with gdb"
shift 2 ;
;; ;;
l) -K | --itti-dump-file)
BUILD_LTE="$OPTARG" ITTI_ANALYZER=1
echo "setting top-level build target to: $OPTARG" ITTI_DUMP_FILE=$2
echo "setting ITTI dump file to: $ITTI_DUMP_FILE"
EXE_ARGUMENTS="$EXE_ARGUMENTS -K $ITTI_DUMP_FILE"
shift 2;
;; ;;
h) -l | --build-target)
BUILD_LTE="$2"
echo "setting top-level build target to: $2"
shift 2;
;;
-h | --help)
print_help print_help
exit -1 exit -1
;; ;;
m) -m | --build-from-makefile)
BUILD_FROM_MAKEFILE=1 BUILD_FROM_MAKEFILE=1
set_build_from_makefile $BUILD_FROM_MAKEFILE set_build_from_makefile $BUILD_FROM_MAKEFILE
echo "setting a flag to build from makefile to: $BUILD_FROM_MAKEFILE" echo "setting a flag to build from makefile to: $BUILD_FROM_MAKEFILE"
shift;
;; ;;
r) -r | --3gpp-release)
REL="$OPTARG" REL="$2"
echo "setting release to: $REL" echo "setting release to: $REL"
shift 2 ;
;; ;;
s) -s | --check)
OAI_TEST=1 OAI_TEST=1
echo "setting sanity check to: $OAI_TEST" echo "setting sanity check to: $OAI_TEST"
shift;
;; ;;
t) -t | --enb-build-target)
TARGET="$OPTARG" TARGET="$2"
echo "setting target to: $TARGET" echo "setting target to: $TARGET"
shift 2;
;;
-V | --vcd)
echo "setting gtk-wave output"
VCD_TIMING=1
EXE_ARGUMENTS="$EXE_ARGUMENTS -V"
shift ;
;; ;;
w) -w | --hardware)
HW="$OPTARG" #"${i#*=}" HW="$2" #"${i#*=}"
echo "setting hardware to: $HW" echo "setting hardware to: $HW"
shift 2 ;
;; ;;
x) -x | --xforms)
XFORMS=1 XFORMS=1
echo "setting xforms to: $XFORMS" echo "setting xforms to: $XFORMS"
shift;
;; ;;
z) -z | --defaults)
echo "setting all parameters to: default" echo "setting all parameters to: default"
rm -rf ./.lock_oaibuild rm -rf ./.lock_oaibuild
OAI_CLEAN=1 OAI_CLEAN=1
...@@ -156,8 +202,14 @@ while getopts "abcdmsxzhe:l:w:r:t:" OPTION; do ...@@ -156,8 +202,14 @@ while getopts "abcdmsxzhe:l:w:r:t:" OPTION; do
DEBUG=0 DEBUG=0
ENB_CONFIG_FILE=$OPENAIR_TARGETS/"PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.conf" ENB_CONFIG_FILE=$OPENAIR_TARGETS/"PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.conf"
OAI_TEST=0 OAI_TEST=0
shift ;
;;
' ')
shift ;
;; ;;
*) *)
echo "Unknown option $1"
break ;
# unknown option # unknown option
;; ;;
esac esac
...@@ -304,8 +356,8 @@ build_enb(){ ...@@ -304,8 +356,8 @@ build_enb(){
############################################ ############################################
# check the installation # check the installation
############################################ ############################################
if [ $DISABLE_CHECK_INSTALLED_SOFTWARE -eq 0 ]; then
echo_info "6. Checking the installation ..." echo_info "6. Checking the the required softwares/packages ..."
check_install_oai_software check_install_oai_software
if [ $HW = "USRP" ]; then if [ $HW = "USRP" ]; then
...@@ -313,6 +365,9 @@ build_enb(){ ...@@ -313,6 +365,9 @@ build_enb(){
fi fi
check_install_asn1c check_install_asn1c
check_install_nettle check_install_nettle
else
echo_info "6. Not checking the required softwares/packages ..."
fi
############################################ ############################################
# compile # compile
...@@ -416,7 +471,6 @@ build_epc(){ ...@@ -416,7 +471,6 @@ build_epc(){
epc_compiled=1 epc_compiled=1
echo_info "Note: this scripts works only for Ubuntu 12.04" echo_info "Note: this scripts works only for Ubuntu 12.04"
###################################### ######################################
...@@ -595,3 +649,18 @@ esac ...@@ -595,3 +649,18 @@ esac
# run # run
############################################ ############################################
echo_info "11. Running ... To be done" echo_info "11. Running ... To be done"
if [ $TARGET = "SOFTMODEM" ]; then
echo_info "############# running ltesoftmodem #############"
$OPENAIR_TARGETS/RT/USER/lte-softmodem
cd $OPENAIR_TARGETS/RT/USER;bash ./init_exmimo2.sh;
if [ $RUN_GDB -eq 0 ]; then
$OPENAIR_TARGETS/RT/USER/lte-softmodem "$EXE_ARGUMENTS"
else
touch ~/.gdb_lte_softmodem
echo "file $OPENAIR_TARGETS/RT/USER/lte-softmodem" > ~/.gdb_lte_softmodem
echo "set args $EXE_ARGUMENTS" >> ~/.gdb_lte_softmodem
echo "run" >> ~/.gdb_lte_softmodem
gdb -nh -x ~/.gdb_lte_softmodem 2>&1
fi
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment