Hi,
I'm trying to write an package for the metric collector telegraf. So far my PKG_SOURCE
code is downloaded correctly. Because it is written in GO, I need to set an environment variable GO_ARCH
to compile the source code correctly.
I'm doing it by overwriting the Build/Compile function:
define Build/Compile
GOARCH=$(KERNEL_ARCH) $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
endef
The problem I am now faced, is that the openwrt arch is eg. aarch64
instead of arm64
. I found the following wireguard patch where such a translation is done:
+ifeq ($(ARCH),aarch64)
160 +QEMU_ARCH := aarch64
161 +KERNEL_ARCH := arm64
But I am unable to set any variable in the Build/Compile
function. I tried many variation. But the variable is not set.
I also do not why code inside this function is now called as bash -c
and not in Makefile syntax anymore..
define Build/Compile
KERNEL_ARCH=ERROR
@echo "ARCH: $(KERNEL_ARCH)"
if [ "$(ARCH)" == "aarch64" ]; then \
KERNEL_ARCH="arm64"; \
elif [ "$(ARCH)" == "aarch64_be" ]; then \
KERNEL_ARCH=arm64; \
elif [ "$(ARCH)" == "arm" ]; then \
KERNEL_ARCH=arm; \
elif [ "$(ARCH)" == "armeb" ]; then \
KERNEL_ARCH=arm; \
elif [ "$(ARCH)" == "x86_64" ]; then \
KERNEL_ARCH=x86_64; \
elif [ "$(ARCH)" == "i686" ]; then \
KERNEL_ARCH=x86; \
elif [ "$(ARCH)" == "mips64" ]; then \
KERNEL_ARCH=mips; \
elif [ "$(ARCH)" == "mips64el" ]; then \
KERNEL_ARCH=mips; \
elif [ "$(ARCH)" == "mips" ]; then \
KERNEL_ARCH=mips; \
elif [ "$(ARCH)" == "mipsel" ]; then \
KERNEL_ARCH=mips; \
elif [ "$(ARCH)" == "powerpc64le" ]; then \
KERNEL_ARCH=powerpc; \
elif [ "$(ARCH)" == "powerpc" ]; then \
KERNEL_ARCH=powerpc; \
elif [ "$(ARCH)" == "m68k" ]; then \
KERNEL_ARCH=m68k; \
fi
@echo "ARCH: $(KERNEL_ARCH)"
GOARCH=$(KERNEL_ARCH) $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
endef
Can you help me ? What am I doing wrong ? Or this there already an variable with "correct" archicture name ?
Thanks in advance!
Edit: My current way is to define it outside a function like this. It is working but not really pretty.
KERNEL_ARCH= `\
if [ "$(ARCH)" == "aarch64" ]; then \
echo arm64; \
elif [ "$(ARCH)" == "aarch64_be" ]; then \
echo arm64; \
elif [ "$(ARCH)" == "arm" ]; then \
echo arm; \
elif [ "$(ARCH)" == "armeb" ]; then \
echo arm; \
elif [ "$(ARCH)" == "x86_64" ]; then \
echo x86_64; \
elif [ "$(ARCH)" == "i686" ]; then \
echo x86; \
elif [ "$(ARCH)" == "mips64" ]; then \
echo mips; \
elif [ "$(ARCH)" == "mips64el" ]; then \
echo mips; \
elif [ "$(ARCH)" == "mips" ]; then \
echo mips; \
elif [ "$(ARCH)" == "mipsel" ]; then \
echo mips; \
elif [ "$(ARCH)" == "powerpc64le" ]; then \
echo powerpc; \
elif [ "$(ARCH)" == "powerpc" ]; then \
echo powerpc; \
elif [ "$(ARCH)" == "m68k" ]; then \
echo m68k; \
fi`