From c5e9695d1cf35ea0ca3c6e41d7784dbb7935f3b8 Mon Sep 17 00:00:00 2001 From: Joakim Roubert Date: Fri, 25 Oct 2024 11:00:41 +0200 Subject: [PATCH] Move to ACAP 4 Native SDK and libmodbus version 3.1.11 This patchset moves to the ACAP 4 Native SDK. This means we drop support for (really) old devices. If you need to build with the ACAP 3 SDK for old devices, please use the previous commit as your base since that will work fine for that. With the move to ACAP 4 Native SDK, we can drop the support for this repo to be built with locally installed SDKs (that nobody uses these days anyway) and then move the build of libmodbus from Makefile into the Dockerfile instead. This patchset also bumps libmodbus from version 3.1.7 to 3.1.11. Change-Id: I9cfef8b6608c4c8ab897034799b54f8e2aae6fab Signed-off-by: Joakim Roubert --- Dockerfile | 43 ++++++++++++++++++++++++++++++++++--------- Makefile | 32 +++++--------------------------- manifest.json | 6 +++--- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index b907ecb..0ed1958 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,45 @@ -ARG ARCH=armv7hf -ARG ACAP_SDK_VERSION=3.5 -ARG SDK_IMAGE=axisecp/acap-sdk -ARG BUILD_DIR=/usr/local/src/server-acap +ARG ARCH=aarch64 +ARG ACAP_SDK_VERSION=1.15 +ARG SDK_IMAGE=axisecp/acap-native-sdk +ARG LIBMODBUS_VERSION=3.1.11 +ARG BUILD_DIR=/usr/local/src +ARG ACAP_BUILD_DIR="$BUILD_DIR"/app +ARG LIBMODBUS_BUILD_DIR="$BUILD_DIR"/libmodbus -FROM $SDK_IMAGE:$ACAP_SDK_VERSION-$ARCH-ubuntu20.04 AS builder -ARG BUILD_DIR -WORKDIR "$BUILD_DIR" +FROM $SDK_IMAGE:$ACAP_SDK_VERSION-$ARCH AS builder +ARG ACAP_BUILD_DIR +ARG LIBMODBUS_BUILD_DIR +ARG LIBMODBUS_VERSION +ENV DEBIAN_FRONTEND=noninteractive + +# Install additional build dependencies +RUN apt-get update && apt-get install -y -f --no-install-recommends \ + autoconf \ + automake \ + libtool + +# Build libmodbus +WORKDIR "$LIBMODBUS_BUILD_DIR" +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN curl -L https://github.com/stephane/libmodbus/archive/refs/tags/v$LIBMODBUS_VERSION.tar.gz | tar --strip-components=1 -xz +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN . /opt/axis/acapsdk/environment-setup* && \ + ./autogen.sh && \ + ./configure --host=$ARCH --prefix=/usr --enable-static=yes --enable-shared=no && \ + make -j $(nproc) install prefix=$SDKTARGETSYSROOT/usr + +# Build ACAP package +WORKDIR "$ACAP_BUILD_DIR" COPY LICENSE \ Makefile \ manifest.json \ *.c \ *.h \ ./ +SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN . /opt/axis/acapsdk/environment-setup* && \ acap-build . FROM scratch -ARG BUILD_DIR -COPY --from=builder "$BUILD_DIR"/*eap "$BUILD_DIR"/*LICENSE.txt / +ARG ACAP_BUILD_DIR +COPY --from=builder "$ACAP_BUILD_DIR"/*eap "$ACAP_BUILD_DIR"/*LICENSE.txt / diff --git a/Makefile b/Makefile index 0ce9704..97f959c 100644 --- a/Makefile +++ b/Makefile @@ -4,40 +4,21 @@ PROG = modbusacap SRCS = $(wildcard *.c) OBJS = $(SRCS:.c=.o) STRIP ?= strip +RM ?= rm -f -PKGS = gio-2.0 glib-2.0 axevent axparameter +PKGS = gio-2.0 glib-2.0 axevent axparameter libmodbus CFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags $(PKGS)) LDLIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs $(PKGS)) -# libmodbus -LIBMODBUS_VERSION = 3.1.7 -LIBMODBUS_DIR = $(CURDIR)/libmodbus-$(LIBMODBUS_VERSION) -LIBMODBUS = $(LIBMODBUS_DIR)/lib/libmodbus.a -CFLAGS += -I $(LIBMODBUS_DIR)/include/modbus -LDLIBS += $(LIBMODBUS) - CFLAGS += -Wformat=2 -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wdisabled-optimization -Wall -Werror # main targets all: $(PROG) $(STRIP) $(PROG) -$(OBJS): $(LIBMODBUS) - $(PROG): $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(LDLIBS) -o $@ -# libmodbus targets -$(LIBMODBUS_DIR): - curl -L https://libmodbus.org/releases/libmodbus-$(LIBMODBUS_VERSION).tar.gz | tar xz - -$(LIBMODBUS_DIR)/Makefile: | $(LIBMODBUS_DIR) - cd $(LIBMODBUS_DIR) && \ - ./configure --host=$(ARCH) --prefix=$(LIBMODBUS_DIR) - -$(LIBMODBUS): $(LIBMODBUS_DIR)/Makefile - make -C $(LIBMODBUS_DIR) -j install - # docker build container targets %.eap: DOCKER_BUILDKIT=1 docker build --build-arg ARCH=$(basename $@) -o type=local,dest=. "$(CURDIR)" @@ -45,11 +26,8 @@ $(LIBMODBUS): $(LIBMODBUS_DIR)/Makefile dockerbuild: armv7hf.eap aarch64.eap # clean targets -3rd-party-clean: - make -C $(LIBMODBUS_DIR) clean - clean: - rm -f $(PROG) *.o *.eap *LICENSE.txt pa*conf* + $(RM) $(PROG) *.o *.eap *LICENSE.txt pa*conf* -very-clean: clean 3rd-party-clean - rm -rf *.eap *.eap.old eap $(LIBMODBUS_DIR) +very-clean: clean + $(RM) *.old diff --git a/manifest.json b/manifest.json index d4da60c..dac7e1c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,13 @@ { - "schemaVersion": "1.3", + "schemaVersion": "1.7.0", "acapPackageConf": { "setup": { "appName": "modbusacap", "friendlyName": "Modbus Prototype", "vendor": "Axis Communications AB", - "embeddedSdkVersion": "2.0", + "embeddedSdkVersion": "3.0", "runMode": "respawn", - "version": "1.1.2" + "version": "1.2.0" }, "configuration": { "paramConfig": [