How to add and build libmbim-1.18.0 in Hikey960 android AOSP source?

I have a Hikey960 embedded board.

I would like to using MBIM(mbimcli) I/F on Hikey960 board for data connection with Modem module.
I need to add and build “mbimcli” execution program for control MBIM I/F.

libmbim-1.18.0 is released as below link.

For build libmbim-1.18.0.tar.xz in AOSP android-9.0.0 source,
it provides “Makefile.am” and “Makefile.in” audomake script.

But Android AOSP Hikey960(android-9.0.0) is using Android.bp for soong build.

<Question?>
How to add and build “libmbim-1.18.0.tar.xz” in android AOSP android-9.0.0 source?
I would like to use the mbimcli command in the adb shell on Hikey960 device.

Please, help and share a way to build Makefile.am on AOSP android-9.0.0 source.

Thank you.

You really have two options;

  1. Write an android makefile for it,
  2. Cross compile it statically and copy in the compiled binaries.

Both may not be trivial.

Thank you for your response.

According to the second way your recommends…

Q1. Is there a way to modify configure for Linux open source build hikey960?
How do I modify Linux open source configure to compile executable shell program on Hikey960 ARM device?
How to compile Linux open source(Makefile.am) for specific ARM targets in ubuntu?

Q2. What is the arm cross compiler used for building hikey960?
If I build an AOSP source from ubuntu 14.04, it is built for arm64/armv8-a/cortex-a73 as shown below.
I am not sure what arm compiler is built when building the hikey960 AOSP.
Can I find out what arm compiler is used when building hikey960 AOSP?

Link : Using Reference Boards  |  Android Open Source Project

// Download AOSP source for Hikey960 in ubuntu environment.
$ repo init -u https://android.googlesource.com/platform/manifest -b master
$ repo sync -j8

// Build AOSP source for Hikey960 in ubuntu environment.
$. ./build/envsetup.sh
$ lunch hikey960-userdebug
$ make -j8

// Hikey960 AOSP build logs.
device/linaro/hikey/hikey960/device-hikey960.mk:138: warning: TARGET_HISI_CODEC_VERSION () does not match exiting the build (1).
device/linaro/hikey/hikey960/device-hikey960.mk:139: warning: Please download new binaries here:
device/linaro/hikey/hikey960/device-hikey960.mk:140: warning: <a href="https://dl.google.com/dl/android/aosp/hisilicon-hikey960-OPR-3c243263.tgz" rel="nofollow">https://dl.google.com/dl/android/aosp/hisilicon-hikey960-OPR-3c243263.tgz</a> 
device/linaro/hikey/hikey960/device-hikey960.mk:141: warning: And extract in the ANDROID_TOP_DIR
============================================
PLATFORM_VERSION_CODENAME=Q
PLATFORM_VERSION=Q
TARGET_PRODUCT=hikey960
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=cortex-a73
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=cortex-a73
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-31-generic-x86_64-Ubuntu-14.04.5-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PI
OUT_DIR=out
============================================
...(skip)

We have not been able to resolve it for more than a week. Please help me.

Thank you.

FYI, I snipped libmbim-1.18.0.tar.xz build logs in ubuntu system.

If I try to build a Linux open source libmbim(libmbim-1.18.0.tar.xz) in ubuntu,
it seems that make will be created as an executable shell program that for ubuntu system using gcc compiler.
It just run .configure and make in ubuntu 14.04, it does not cross-compiling for Hikey960.

// run configure for libmbim source make in ubuntu
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
checking whether GID '1000' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for more warnings... yes
checking whether gcc understands -Wmissing-declarations... yes
checking whether gcc understands -Wmissing-prototypes... yes
checking whether gcc understands -Wdeclaration-after-statement... yes
checking whether gcc understands -Wstrict-prototypes... yes
checking whether gcc understands -fno-strict-aliasing... yes
checking whether gcc understands -Wno-deprecated-declarations... yes
checking whether gcc understands -Wint-to-pointer-cast... yes
checking whether gcc understands -Wfloat-equal... yes
checking whether gcc understands -Wno-unused-parameter... yes
checking whether gcc understands -Wno-sign-compare... yes
checking whether gcc understands -Wunused-but-set-variable... yes
checking whether gcc understands -Wundef... yes
checking whether gcc understands -Wimplicit-function-declaration... yes
checking whether gcc understands -Wpointer-arith... yes
checking whether gcc understands -Winit-self... yes
checking whether gcc understands -Wshadow... yes
checking whether gcc understands -Wmissing-include-dirs... yes
checking whether gcc understands -Waggregate-return... yes
checking whether gcc understands -Wformat-security... yes
checking whether gcc understands -Wtype-limits... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for MBIM_COMMON... yes
checking for LIBMBIM_GLIB... yes
checking for MBIMCLI... yes
checking for MBIMPROXY... yes
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.7/dist-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.7/dist-packages
checking for gtk-doc... no
configure: WARNING:
  You will not be able to create source packages with 'make dist'
  because gtk-doc >= 1.0 is not found.
checking for gtkdoc-check... no
checking for gtkdoc-check... no
checking for gtkdoc-rebase... no
checking for gtkdoc-mkpdf... no
checking whether to build gtk-doc documentation... no
checking for GTKDOC_DEPS... yes
checking for GUDEV... no
checking for help2man... false
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating build-aux/Makefile
config.status: creating build-aux/templates/Makefile
config.status: creating build-aux/mbim-codegen/Makefile
config.status: creating data/Makefile
config.status: creating data/pkg-config/Makefile
config.status: creating data/pkg-config/mbim-glib.pc
config.status: creating src/Makefile
config.status: creating src/common/Makefile
config.status: creating src/common/test/Makefile
config.status: creating src/libmbim-glib/Makefile
config.status: creating src/libmbim-glib/mbim-version.h
config.status: creating src/libmbim-glib/generated/Makefile
config.status: creating src/libmbim-glib/test/Makefile
config.status: creating src/mbimcli/Makefile
config.status: creating src/mbim-proxy/Makefile
config.status: creating utils/Makefile
config.status: creating docs/Makefile
config.status: creating docs/reference/Makefile
config.status: creating docs/reference/libmbim-glib/Makefile
config.status: creating docs/reference/libmbim-glib/version.xml
config.status: creating docs/man/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
 
    libmbim 1.18.0
    ==============================================
 
    Build:
      compiler:             gcc
      cflags:               -Wall -std=gnu89 -g -O2 -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after                                                                                                                          -statement -Wstrict-prototypes -fno-strict-aliasing -Wno-deprecated-declarations -Wint-to-pointer-cast -Wfloat-equa                                                                                                                          l -Wno-unused-parameter -Wno-sign-compare -Wunused-but-set-variable -Wundef -Wimplicit-function-declaration -Wpoint                                                                                                                          er-arith -Winit-self -Wshadow -Wmissing-include-dirs -Waggregate-return -Wformat-security -Wtype-limits -Werror
      ldflags:
      Maintainer mode:      yes
      Documentation:        no
 
    System paths:
      prefix:               /usr/local
      udev base directory:  /lib/udev
 
    Features:
      udev support:         no
      MBIM username:        no (root)
 
$


// Run libmbim source make on ubuntu
$ make
make  all-recursive
make[1]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build'
Making all in .
make[2]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build'
make[2]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build'
Making all in build-aux
make[2]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux'
Making all in templates
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux/templates'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux/templates'
Making all in mbim-codegen
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux/mbim-codegen'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux/mbim-codegen'
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux'
make[2]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/build-aux'
Making all in data
make[2]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/data'
Making all in .
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/data'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/data'
Making all in pkg-config
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/data/pkg-config'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/data/pkg-config'
make[2]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/data'
Making all in src
make[2]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src'
Making all in common
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/common'
Making all in .
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/common'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/common'
Making all in test
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/common/test'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/common/test'
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/common'
Making all in libmbim-glib
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib'
Making all in generated
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib/generated'
make  all-am
make[5]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib/generated'
make[5]: Nothing to be done for `all-am'.
make[5]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib/generated'
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib/generated'
Making all in .
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib'
Making all in test
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib/test'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib/test'
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/libmbim-glib'
Making all in mbimcli
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/mbimcli'
  CC       mbimcli-mbimcli.o
  CC       mbimcli-mbimcli-helpers.o
  CC       mbimcli-mbimcli-basic-connect.o
  CC       mbimcli-mbimcli-phonebook.o
  CC       mbimcli-mbimcli-dss.o
  CC       mbimcli-mbimcli-ms-firmware-id.o
  CC       mbimcli-mbimcli-ms-host-shutdown.o
  CC       mbimcli-mbimcli-atds.o
  CC       mbimcli-mbimcli-intel-firmware-update.o
  CC       mbimcli-mbimcli-ms-basic-connect-extensions.o
  CCLD     mbimcli
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/mbimcli'
Making all in mbim-proxy
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/mbim-proxy'
  CC       mbim_proxy-mbim-proxy.o
  CCLD     mbim-proxy
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src/mbim-proxy'
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src'
make[2]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/src'
Making all in utils
make[2]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/utils'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/utils'
Making all in docs
make[2]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs'
Making all in reference
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference'
Making all in libmbim-glib
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference/libmbim-glib'
make  all-am
make[5]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference/libmbim-glib'
make[5]: Nothing to be done for `all-am'.
make[5]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference/libmbim-glib'
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference/libmbim-glib'
make[4]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference'
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/reference'
Making all in man
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/man'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs/man'
make[3]: Entering directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs'
make[2]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build/docs'
make[1]: Leaving directory `/home/wiz/temp/mbim/libmbim-1.18.0_build'
$