Skip to content

Commit 4a66728

Browse files
committed
Initial arm64 changes
1 parent 64e4976 commit 4a66728

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

Makefile

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
include config.env
2121
include source-branch.env
2222

23+
# arch_uname is the platform architecture according to the uname program. Can be differ by OS, e.g. `arm64` on macOS, but `aarch64` on Linux.
24+
arch_uname := $(shell uname -m)
25+
# arch_go is the platform architecture in Go-style (e.g. amd64, ppc64le, s390x or arm64).
26+
arch_go := $(if $(findstring x86_64,$(arch_uname)),amd64,$(if $(findstring aarch64,$(arch_uname)),arm64,$(arch_uname)))
27+
# ARCH is the platform architecture in Go-style (e.g. amd64, ppc64le, s390x or arm64).
28+
# Override this to build an image for a different architecture. Note that RUN instructions will not be able to succeed without the help of emulation provided by packages like qemu-user-static.
29+
ARCH ?= $(arch_go)
2330
# RELEASE shows what release of the container code has been built
2431
RELEASE ?=
2532
# MQ_ARCHIVE_REPOSITORY is a remote repository from which to pull the MQ_ARCHIVE (if required)
@@ -60,8 +67,6 @@ MQ_DELIVERY_REGISTRY_NAMESPACE ?=
6067
MQ_DELIVERY_REGISTRY_USER ?=
6168
# MQ_DELIVERY_REGISTRY_CREDENTIAL is the password/API key for the remote registry (if required)
6269
MQ_DELIVERY_REGISTRY_CREDENTIAL ?=
63-
# ARCH is the platform architecture (e.g. amd64, ppc64le or s390x)
64-
ARCH ?= $(if $(findstring x86_64,$(shell uname -m)),amd64,$(shell uname -m))
6570
# LTS is a boolean value to enable/disable LTS container build
6671
LTS ?= false
6772
# VOLUME_MOUNT_OPTIONS is used when bind-mounting files from the "downloads" directory into the container. By default, SELinux labels are automatically re-written, but this doesn't work on some filesystems with extended attributes (xattrs). You can turn off the label re-writing by setting this variable to be blank.
@@ -108,12 +113,17 @@ endif
108113

109114
# Try to figure out which archive to use from the architecture
110115
ifeq "$(ARCH)" "amd64"
111-
MQ_ARCHIVE_ARCH=X86-64
112-
MQ_ARCHIVE_DEV_ARCH=X64
116+
MQ_ARCHIVE_ARCH:=X86-64
117+
MQ_ARCHIVE_DEV_ARCH:=X64
113118
else ifeq "$(ARCH)" "ppc64le"
114-
MQ_ARCHIVE_ARCH=PPC64LE
119+
MQ_ARCHIVE_ARCH:=PPC64LE
120+
MQ_ARCHIVE_DEV_ARCH:=PPC64LE
115121
else ifeq "$(ARCH)" "s390x"
116-
MQ_ARCHIVE_ARCH=S390X
122+
MQ_ARCHIVE_ARCH:=S390X
123+
MQ_ARCHIVE_DEV_ARCH:=S390X
124+
else ifeq "$(ARCH)" "arm64"
125+
MQ_ARCHIVE_ARCH:=ARM64
126+
MQ_ARCHIVE_DEV_ARCH:=ARM64
117127
endif
118128

119129
# If this is a fake master build, push images to alternative location (pipeline wont consider these images GA candidates)
@@ -322,6 +332,7 @@ test-advancedserver-cover: test/docker/vendor coverage
322332

323333
# Command to build the image
324334
# Args: imageName, imageTag, dockerfile, extraArgs, dockerfileTarget
335+
# If the ARCH variable has been changed from the default value (arch_go variable), then the `--platform` parameter is added
325336
define build-mq-command
326337
$(COMMAND) build \
327338
--tag $1:$2 \
@@ -338,6 +349,7 @@ define build-mq-command
338349
--label vcs-ref=$(IMAGE_REVISION) \
339350
--label vcs-type=git \
340351
--label vcs-url=$(IMAGE_SOURCE) \
352+
$(if $(findstring $(arch_go),$(ARCH)),,--platform=linux/$(ARCH)) \
341353
$(EXTRA_LABELS) \
342354
--target $5 \
343355
.
@@ -439,9 +451,12 @@ build-sdk: downloads/$(MQ_ARCHIVE_DEV)
439451
.PHONY: log-build-env
440452
log-build-vars:
441453
$(info $(SPACER)$(shell printf $(TITLE)"Build environment"$(END)))
442-
@echo ARCH=$(ARCH)
443-
@echo MQ_VERSION=$(MQ_VERSION)
444-
@echo MQ_ARCHIVE=$(MQ_ARCHIVE)
454+
@echo arch_uname=$(arch_uname)
455+
@echo arch_go=$(arch_go)
456+
@echo "ARCH=$(ARCH) (origin:$(origin ARCH))"
457+
@echo MQ_VERSION="$(MQ_VERSION) (origin:$(origin MQ_VERSION))"
458+
@echo MQ_ARCHIVE="$(MQ_ARCHIVE) (origin:$(origin MQ_ARCHIVE))"
459+
@echo MQ_ARCHIVE_DEV_ARCH=$(MQ_ARCHIVE_DEV_ARCH)
445460
@echo MQ_ARCHIVE_DEV=$(MQ_ARCHIVE_DEV)
446461
@echo MQ_IMAGE_DEVSERVER=$(MQ_IMAGE_DEVSERVER)
447462
@echo MQ_IMAGE_ADVANCEDSERVER=$(MQ_IMAGE_ADVANCEDSERVER)

authservice/mqhtpass/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# © Copyright IBM Corporation 2017, 2020
1+
# © Copyright IBM Corporation 2017, 2022
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -20,9 +20,15 @@
2020

2121
SRC_DIR = src
2222
BUILD_DIR = ./build
23+
ARCH ?= $(if $(findstring x86_64,$(shell uname -m)),amd64,$(if $(findstring aarch64,$(shell uname -m)),aarch64,$(shell uname -m)))
2324

2425
# Flags passed to the C compiler. Need to use gnu11 to get POSIX functions needed for file locking.
25-
CFLAGS += -std=gnu11 -fPIC -Wall -m64
26+
CFLAGS.amd64 := -m64
27+
CFLAGS.ppc64le := -m64
28+
CFLAGS.s390x := -m64
29+
# -m64 is not a valid compiler option on aarch64/arm64 (ARM)
30+
CFLAGS.arm64 :=
31+
CFLAGS += -std=gnu11 -fPIC -Wall ${CFLAGS.${ARCH}}
2632

2733
LIB_APR = -L/usr/lib64 -lapr-1 -laprutil-1
2834
LIB_MQ = -L/opt/mqm/lib64 -lmqm_r

install-mq-server-prereqs.sh

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# -*- mode: sh -*-
3-
# © Copyright IBM Corporation 2015, 2021
3+
# © Copyright IBM Corporation 2015, 2022
44
#
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,15 +22,15 @@ test -f /usr/bin/yum && YUM=true || YUM=false
2222
test -f /usr/bin/microdnf && MICRODNF=true || MICRODNF=false
2323
test -f /usr/bin/rpm && RPM=true || RPM=false
2424
test -f /usr/bin/apt-get && UBUNTU=true || UBUNTU=false
25+
CPU_ARCH=$(uname -m)
2526

2627
if ($UBUNTU); then
2728
export DEBIAN_FRONTEND=noninteractive
2829
# Use a reduced set of apt repositories.
2930
# This ensures no unsupported code gets installed, and makes the build faster
3031
source /etc/os-release
3132
# Figure out the correct apt URL based on the CPU architecture
32-
CPU_ARCH=$(uname -p)
33-
if [ ${CPU_ARCH} == "x86_64" ]; then
33+
if [ "${CPU_ARCH}" == "x86_64" ]; then
3434
APT_URL="http://archive.ubuntu.com/ubuntu/"
3535
else
3636
APT_URL="http://ports.ubuntu.com/ubuntu-ports/"
@@ -41,29 +41,22 @@ if ($UBUNTU); then
4141
echo "deb ${APT_URL} ${UBUNTU_CODENAME}-updates main restricted" >> /etc/apt/sources.list
4242
echo "deb ${APT_URL} ${UBUNTU_CODENAME}-security main restricted" >> /etc/apt/sources.list
4343
# Install additional packages required by MQ, this install process and the runtime scripts
44+
EXTRA_DEBS="bash bc ca-certificates coreutils curl debianutils file findutils gawk grep libc-bin mount passwd procps sed tar util-linux"
45+
# On ARM CPUs, there is no IBM JRE, so install another one
46+
if [ "${CPU_ARCH}" == "aarch64" ]; then
47+
EXTRA_DEBS="${EXTRA_DEBS} openjdk-8-jre"
48+
fi
4449
apt-get update
45-
apt-get install -y --no-install-recommends \
46-
bash \
47-
bc \
48-
ca-certificates \
49-
coreutils \
50-
curl \
51-
debianutils \
52-
file \
53-
findutils \
54-
gawk \
55-
grep \
56-
libc-bin \
57-
mount \
58-
passwd \
59-
procps \
60-
sed \
61-
tar \
62-
util-linux
50+
apt-get install -y --no-install-recommends ${EXTRA_DEBS}
6351
fi
6452

6553
if ($RPM); then
6654
EXTRA_RPMS="bash bc ca-certificates file findutils gawk glibc-common grep ncurses-compat-libs passwd procps-ng sed shadow-utils tar util-linux which"
55+
# On ARM CPUs, there is no IBM JRE, so install another one
56+
if [ "${CPU_ARCH}" == "aarch64" ]; then
57+
EXTRA_RPMS="${EXTRA_RPMS} java-1.8.0-openjdk-headless"
58+
fi
59+
6760
# Install additional packages required by MQ, this install process and the runtime scripts
6861
$YUM && yum -y install --setopt install_weak_deps=false ${EXTRA_RPMS}
6962
$MICRODNF && microdnf --disableplugin=subscription-manager install ${EXTRA_RPMS}

0 commit comments

Comments
 (0)