diff --git a/build_and_install.sh b/build_and_install.sh index 591744b2581c73f380588531f515f8bde8f5a49b..44b24f845784d1dd2b4d8952212fdfdcdbcf681c 100755 --- a/build_and_install.sh +++ b/build_and_install.sh @@ -35,7 +35,7 @@ fi # make install # List of silecs packages which can be released -PACKAGES="silecs-codegen silecs-model snap7 silecs-communication-cpp silecs-diagnostic-cpp silecs_cli silecs-cli-client" +PACKAGES="silecs-codegen silecs-model modbus snap7 silecs-communication-cpp silecs-diagnostic-cpp silecs_cli silecs-cli-client" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in diff --git a/modbus/.gitignore b/modbus/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..07bbcf868a13b4f78b1d9cfcb5497e5fe47b97a7 --- /dev/null +++ b/modbus/.gitignore @@ -0,0 +1 @@ +/libmodbus-*/ diff --git a/modbus/build.sh b/modbus/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..707014e0923a499ad7722dbaa92bd1dc9f8b01e9 --- /dev/null +++ b/modbus/build.sh @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +# First argument has to be the desired modbus version +MODBUS_VERSION=$1 + +# Second argument is the install location +RELEASE_DIR=$2 + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in +MODBUS_FOLDER=libmodbus-${MODBUS_VERSION} +MODBUS_PATH=${SCRIPTPATH}/${MODBUS_FOLDER} + +echo ${MODBUS_PATH} +# If there is no modbus folder yet, we download the required version and build it +if [ -d ${MODBUS_PATH} ]; then + echo "Some modbus version is already available. No need to download/build it" + #TODO Check if the version matches +else + + archiveFile=${MODBUS_FOLDER}.tar.gz + archiveFilePath=${SCRIPTPATH}/${archiveFile} + + if [ ! -f "$archiveFilePath" ] + then + echo "Downloading modbus" + cd ${SCRIPTPATH} + wget https://github.com/stephane/libmodbus/releases/download/v${MODBUS_VERSION}/libmodbus-${MODBUS_VERSION}.tar.gz + fi + + if [ ! -d ${MODBUS_PATH} ] + then + echo "Extracting modbus" + tar -vxzf ${archiveFilePath} + rm ${archiveFilePath} + fi + + echo "Building and installing modbus" + + cd ${MODBUS_FOLDER} + ./configure --enable-static --prefix=${RELEASE_DIR} + make + make install +fi + + diff --git a/modbus/install.sh b/modbus/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..f105c6ddea27bcd4f72416d4e3c42c0b0d897236 --- /dev/null +++ b/modbus/install.sh @@ -0,0 +1,52 @@ +#!/bin/sh +set -e + +RELEASE_DIR_BASE=$1 +SILECS_VERSION=$2 + +MODBUS_VERSION_FULL=3.1.10 +MODBUS_VERSION_MAJOR=`echo ${MODBUS_VERSION_FULL} | cut -d. -f1` +MODBUS_VERSION_MINOR=`echo ${MODBUS_VERSION_FULL} | cut -d. -f2` + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in + +RELEASE_DIR=${RELEASE_DIR_BASE}/modbus/${MODBUS_VERSION_FULL} +if [ -d ${RELEASE_DIR} ]; then + echo "Error: ${RELEASE_DIR} already exists ...skipping" + exit 1 +fi + +# Download and build modbus if required +${SCRIPTPATH}/build.sh ${MODBUS_VERSION_FULL} ${RELEASE_DIR} + +# Make sure everybody can read all installed files +chmod a+r -R ${RELEASE_DIR} +chmod a+x -R ${RELEASE_DIR} + +# Make all files write-protected to prevent overwriting an old version by accident +chmod a-w -R ${RELEASE_DIR} + +# Update link to latest version +LATEST_LINK=${RELEASE_DIR_BASE}/modbus/latest +if [ -L ${LATEST_LINK} ]; then + rm ${LATEST_LINK} +fi +ln -fvs ${RELEASE_DIR_BASE}/modbus/${MODBUS_VERSION_FULL} ${LATEST_LINK} + +# Update links to major version +MAJOR_LINK=${RELEASE_DIR_BASE}/modbus/${MODBUS_VERSION_MAJOR} +if [ -L ${MAJOR_LINK} ]; then + rm ${MAJOR_LINK} +fi +ln -fvs ${RELEASE_DIR_BASE}/modbus/${MODBUS_VERSION_FULL} ${MAJOR_LINK} + +# Update links to major.minor version +MAJOR_MINOR_LINK=${RELEASE_DIR_BASE}/modbus/${MODBUS_VERSION_MAJOR}.${MODBUS_VERSION_MINOR} +if [ -L ${MAJOR_MINOR_LINK} ]; then + rm ${MAJOR_MINOR_LINK} +fi +ln -fvs ${RELEASE_DIR_BASE}/modbus/${MODBUS_VERSION_FULL} ${MAJOR_MINOR_LINK} + + + diff --git a/silecs-communication-cpp/Makefile.dep b/silecs-communication-cpp/Makefile.dep index 17163129e9ffae9aaf6b42f919f16ff4df373327..f8eca7b897b3d4b94e8d103d68353bf7cfe9b016 100644 --- a/silecs-communication-cpp/Makefile.dep +++ b/silecs-communication-cpp/Makefile.dep @@ -5,7 +5,7 @@ SNAP7_BASE ?= ../snap7/snap7-full BOOST_HOME ?= /opt/gsi/3rdparty/boost/$(BOOST_VERSION) ifdef MODBUS_SUPPORT_ENABLED - MODBUS_VERSION = 3.1.7 + MODBUS_VERSION = latest MODBUS_BASE=/common/usr/cscofe/silecs/modbus/$(MODBUS_VERSION) DEPENDENT_COMPILER_OPTIONS += -I$(MODBUS_BASE)/include endif diff --git a/silecs-communication-cpp/squash_modbus_lib.mri b/silecs-communication-cpp/squash_modbus_lib.mri index 145b3152f4805139b195f8a2699e12eb5ff1fb42..68d0d6dff21cc74a0a9f538dbf66cd9f8cec53bb 100644 --- a/silecs-communication-cpp/squash_modbus_lib.mri +++ b/silecs-communication-cpp/squash_modbus_lib.mri @@ -1,5 +1,5 @@ create build/lib/x86_64/libsquashed.a addlib build/lib/x86_64/libsilecs-comm.a -addlib /common/usr/cscofe/silecs/modbus/3.1.7/lib/libmodbus.a +addlib /common/usr/cscofe/silecs/modbus/latest/lib/libmodbus.a save end