forked from ptp-sim/PTP_Simulations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateMakefile.sh
executable file
·74 lines (57 loc) · 1.78 KB
/
GenerateMakefile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Create makefile for simulation
# Functions
function verbose () {
[[ ${VERBOSE} -eq 1 ]] && return 0 || return 1
}
# Parameter evaluation
RELATIVE_CONFIG_FILE_DIR=$1
CONFIG_FILE_NAME=$2
CONFIG=$3
# Path configurations
OMNET_STUFF_PATH=/main/TU/act/OMNeT_Stuff
LIBPTP_PATH=${OMNET_STUFF_PATH}/libPTP
PTPSIM_PATH=${OMNET_STUFF_PATH}/PTP_Simulations
INET_PATH=/main/Software/OMNeT++/inet
UTILS_PATH=${OMNET_STUFF_PATH}/OMNeT_Utils
# Library paths
UTILS_LIBPATH=${UTILS_PATH}/src/OMNeT_Utils
INET_LIBPATH=${INET_PATH}/src/inet
LIBPTP_LIBPATH=${LIBPTP_PATH}/src/libPTP
# NED paths
NED_PATH=""
NED_PATH=${NED_PATH}:${UTILS_PATH}/src
NED_PATH=${NED_PATH}:${INET_PATH}/src
NED_PATH=${NED_PATH}:${LIBPTP_PATH}/src
NED_PATH=${NED_PATH}:${PTPSIM_PATH}/simulations
# Simulation binary
SIM_BIN=${PTPSIM_PATH}/src/PTP_Simulations
# Config file stuff
CONFIG_FILE_DIR=${PTPSIM_PATH}/${RELATIVE_CONFIG_FILE_DIR}
CONFIG_FILE_PATH=${CONFIG_FILE_DIR}/${CONFIG_FILE_NAME}
# Makefile config
MAKEFILE_NAME=Makefile_${CONFIG}
MAKEFILE_PATH=${CONFIG_FILE_DIR}/${MAKEFILE_NAME}
# Command config
CONFIG_LIST_CMD="${SIM_BIN} -g -x ${CONFIG} ${CONFIG_FILE_PATH}"
# Get number of runs
MAX_CONFIG_ID=`${CONFIG_LIST_CMD} | grep Run | cut -d ' ' -f 2 | cut -d ':' -f 1 | tail -n1`
RUNS=0..${MAX_CONFIG_ID}
#RUNS=2
# Verbose output
verbose && ${CONFIG_LIST_CMD}
# Construct simulation command
CMD=${SIM_BIN}
CMD="${CMD} -r ${RUNS}"
CMD="${CMD} -u Cmdenv"
CMD="${CMD} -c ${CONFIG}"
CMD="${CMD} -n ${NED_PATH}"
CMD="${CMD} -l ${UTILS_LIBPATH}"
CMD="${CMD} -l ${INET_LIBPATH}"
CMD="${CMD} -l ${LIBPTP_LIBPATH}"
CMD="${CMD} ${CONFIG_FILE_PATH}"
#CMD="${CMD} --sim-time-limit=10s"
# Generate Makefile
opp_runall --export ${MAKEFILE_PATH} ${CMD}
# Info
echo ${CONFIG_FILE_NAME}, ${CONFIG}, "Highest config ID: " ${MAX_CONFIG_ID}