Skip to content

Commit

Permalink
Move to ACAP 4 Native SDK and libmodbus version 3.1.11
Browse files Browse the repository at this point in the history
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 <joakimr@axis.com>
  • Loading branch information
joakimr-axis committed Oct 25, 2024
1 parent c3de675 commit c5e9695
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
43 changes: 34 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 /
32 changes: 5 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,30 @@ 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)"

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
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit c5e9695

Please sign in to comment.