Is aubio cross-compilable for iPhone/Android/ARM? [closed] - iphone

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Anyone know of:
A build of the Aubio library for iPhone/ARM processor?
An intro-to-cross-compiling resource so I can try it myself?

Try using the latest git:
$ git clone git://git.aubio.org/git/aubio
$ cd aubio/
$ ./waf configure build --with-target-platform ios

I've succeeded in cross-compiling it without errors. I haven't tested the library itself, but the example executables seem to work, so that's a good sign!
The script I've put together (largely thanks to the invaluable information in this link) should work for a lot of other projects using Autotools (like Aubio's dependencies).
Note that both libsndfile and libsamplerate need a patch to cross-compile successfully, which I'm sure is ugly, but it works.
To use it, modify the script according to your system (should be pretty straightforward, I hope), download all the dependencies (listed in the build xxxxx lines at the end, your versions may vary) in the same directory as the script and run the script without arguments. At the end, everything should be inside the $SYS_ROOT directory.
Okay, the main dish is below :
#!/bin/bash
# Taken and improved from :
# http://cmumobileapps.com/2011/08/31/compiling-open-source-libraries-with-android-ndk-part-2
# The designation for the host, usually "linux-x86" for standard linuxes, and
# "darwin-x86" for OSX.
HOST="linux-x86"
# The target architecture. Here we're compiling for ARM using GCC 4.7 and
# platform version 14.
TARGET_ARCH="arm"
TARGET_HOST="arm-eabi"
TARGET_TOOLCHAIN="arm-linux-androideabi"
TARGET_GCC_VERSION="4.7"
TARGET_NDK_VERSION="14"
# Add the toolchain to the path to be able to use the ARM compiler.
export PATH="$ANDROID_NDK/toolchains/$TARGET_TOOLCHAIN-$TARGET_GCC_VERSION/prebuilt/$HOST/bin:$PATH"
# Where to find the platform-specific files?
export PLATFORM="$ANDROID_NDK/platforms/android-$TARGET_NDK_VERSION/arch-$TARGET_ARCH/"
# Where to copy the platform-specific files?
# Will be used later as the target system root for cross-compilation.
export SYS_ROOT="`pwd`/sysroot/"
# Executable names for the compilation toolchain
export CC="$TARGET_TOOLCHAIN-gcc --sysroot=$SYS_ROOT"
export CXX="$TARGET_TOOLCHAIN-g++ --sysroot=$SYS_ROOT"
export CPP="$TARGET_TOOLCHAIN-cpp --sysroot=$SYS_ROOT"
export LD="$TARGET_TOOLCHAIN-ld"
export AR="$TARGET_TOOLCHAIN-ar"
export RANLIB="$TARGET_TOOLCHAIN-ranlib"
export STRIP="$TARGET_TOOLCHAIN-strip"
# Add the STLPort library to the search path (needed for C++ files)
export CXXFLAGS="-I$ANDROID_NDK/sources/cxx-stl/stlport/stlport/"
export LDFLAGS="-L$ANDROID_NDK/sources/cxx-stl/stlport/libs/armeabi/ -lstlport_static"
# Where to install the cross-compiled packages?
# When running `make install`, all the files (executables, libraries,
# documentation,...) will be in this directory.
export INSTALL_DIR="$SYS_ROOT/usr/"
# Where will pkg-config look for information about installed packages?
export PKG_CONFIG_LIBDIR="$SYS_ROOT/usr/lib/pkgconfig/"
#################
# Configuration #
#################
# If the sysroot doesn't exist, create it and copy all the files from the NDK
# distribution.
if [[ ! -e "$SYS_ROOT" ]]; then
echo "Creating sysroot [$SYS_ROOT]"
cp -Rf "$PLATFORM" "$SYS_ROOT" || exit 2
fi
# If it doesn't exist, create the installation directory.
if [[ ! -e "$INSTALL_DIR" ]]; then
echo "Creating installation directory [$INSTALL_DIR]"
mkdir -p $INSTALL_DIR || exit 3
fi
###############
# Compilation #
###############
build() {
# Change directory to the package directory (in argument)
echo "Building $1"
pushd $1
# Clean things up (optional)
make clean 1>/dev/null 2>&1
# Configure the package
./configure --host=$TARGET_HOST LIBS="-lc -lgcc" --prefix=$INSTALL_DIR || exit 1
# Compile
make || exit 1
# Install in $INSTALL_DIR
make install || exit 1
# Return to the original directory
popd
}
# Build all things
build libogg-1.3.0
build libvorbis-1.3.3
build flac-1.2.1
build libsndfile-1.0.25-patch
build libsamplerate-0.1.8-patch
build fftw-3.3.3
build aubio-0.3.2
libsndfile patch
--- libsndfile-1.0.25/programs/sndfile-play.c 2012-12-31 17:03:34.289908113 +0100
+++ libsndfile-1.0.25-patch/programs/sndfile-play.c 2012-12-31 17:04:05.326412364 +0100
## -55,7 +55,7 ##
#if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__FreeBSD__)
#include <fcntl.h>
#include <sys/ioctl.h>
- #include <sys/soundcard.h>
+ #include <linux/soundcard.h>
#elif (defined (__MACH__) && defined (__APPLE__))
#include <Carbon.h>
--- libsndfile-1.0.25/src/sndfile.c 2012-12-31 17:03:34.343241171 +0100
+++ libsndfile-1.0.25-patch/src/sndfile.c 2013-01-01 18:53:37.436544846 +0100
## -309,7 +309,7 ##
{ SF_PRIVATE *psf ;
/* Ultimate sanity check. */
- assert (sizeof (sf_count_t) == 8) ;
+ /* assert (sizeof (sf_count_t) == 8) ; */
if ((psf = calloc (1, sizeof (SF_PRIVATE))) == NULL)
{ sf_errno = SFE_MALLOC_FAILED ;
libsamplerate patch
--- libsamplerate-0.1.8/examples/audio_out.c 2011-07-13 01:57:31.000000000 +0200
+++ libsamplerate-0.1.8-patch/examples/audio_out.c 2013-01-01 17:24:58.257526888 +0100
## -44,7 +44,7 ##
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <sys/soundcard.h>
+#include <linux/soundcard.h>
#define LINUX_MAGIC MAKE_MAGIC ('L', 'i', 'n', 'u', 'x', 'O', 'S', 'S')

Here is a build script that worked for me:
#! /bin/sh
"""
build the toold chain home with:
build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=../android-9-toolchain
"""
NDK_HOME=~/dev/SDKs/android-9-toolchain
set -x
set -e
export CC=$NDK_HOME/bin/arm-linux-androideabi-gcc
export CFLAGS=-I$NDK_HOME/include
export LDFLAGS="-L$NDK_HOME/lib"
export AR=$NDK_HOME/bin/arm-linux-androideabi-ar
./waf distclean
./waf configure --with-target-platform android --disable-jack
./waf build --verbose
./waf install --destdir dist-android
it will default to toolchain / gcc version 4.6, I changed this to 4.9 as that is the latest I have.
it should pull down the libraries it needs to finish compiling
the main part of the script was kindly provided by Paul Brossier author of Aubio

Related

How to update modules.conf for SELINUX in BUILDROOT?

looking to disable some SELinux modules (set to off) and create others in modules.conf. I don't see an obvious way of updating modules.conf as I tried adding my changes as a modules.conf patch but it failed given that the modules.conf file gets built and is not just downloaded by BR so it is not available for patching like other things under the refpolicy directory:
Build window output:
refpolicy 2.20190609 PatchingApplying 0001-refpolicy-update-modules-conf.patch using patch:
can't find file to patch at input line 3
I did see in the log that there is a support/sedoctool.py that autogenerates the policy/modules.conf file so that the file is NOT patchable like most other things in the ref policy.
The relevant section of the buildroot/output/build/refpolicy-2.20190609/Makefile:
# policy building support tools
support := support
genxml := $(PYTHON) $(support)/segenxml.py
gendoc := $(PYTHON) $(support)/sedoctool.py
<...snip...>
########################################
#
# Create config files
#
conf: $(mod_conf) $(booleans) generate$(booleans) $(mod_conf): conf.intermediate.INTERMEDIATE: conf.intermediate
conf.intermediate: $(polxml)
#echo "Updating $(booleans) and $(mod_conf)"
$(verbose) $(gendoc) -b $(booleans) -m $(mod_conf) -x $(polxml)
Part of the hsmlinux build.log showing the sedoctool.py (gendoc) being run:
Updating policy/booleans.conf and policy/modules.conf
.../build-buildroot-sawshark/buildroot/output/host/usr/bin/python3 support/sedoctool.py -b policy/booleans.conf -m policy/modules.conf -x doc/policy.xml
I'm sure there is a standard way of doing this, just doesn't seem to be documented anywhere I can find.
Thanks.
Turns out that the sedoctool.py script is reading the doc/policy.xml. Looking at sedoctool.py:
#modules enabled and disabled values
MOD_BASE = "base"
MOD_ENABLED = "module"
MOD_DISABLED = "off"
<...snip...>
def gen_module_conf(doc, file_name, namevalue_list):
"""
Generates the module configuration file using the XML provided and the
previous module configuration.
"""
# If file exists, preserve settings and modify if needed.
# Otherwise, create it.
<...snip...>
mod_name = node.getAttribute("name")
mod_layer = node.parentNode.getAttribute("name")
<...snip...>
if mod_name and mod_layer:
file_name.write("# Layer: %s\n# Module: %s\n" % (mod_layer,mod_name))
if required:
file_name.write("# Required in base\n")
file_name.write("#\n")
if [mod_name, MOD_DISABLED] in namevalue_list:
file_name.write("%s = %s\n\n" % (mod_name, MOD_DISABLED))
# If the module is set as enabled.
elif [mod_name, MOD_ENABLED] in namevalue_list:
file_name.write("%s = %s\n\n" % (mod_name, MOD_ENABLED))
# If the module is set as base.
elif [mod_name, MOD_BASE] in namevalue_list:
file_name.write("%s = %s\n\n" % (mod_name, MOD_BASE))
So sedoctool.py has the nice feature of: "# If file exists, preserve settings and modify if needed." and modules.conf can just be added whole here via a complete file patch and the modules that are not desired set as "off" : refpolicy-2.20190609/policy/modules.conf and the script will update as needed based on desired policy.
One more detail is that in the next stage of the refpolicy Makefile (Building) the modules.conf with the updates is deleted in the beginning which kind of clashes with the ability of sedoctool to preserve the patched version of modules.conf...so patched the removal in the Building stage of the Makefile.
[7m>>> refpolicy 2.20190609 Building^[
<...snip...>
rm -f policy/modules.conf
The Makefile in refpolicy-2.20190609 has this line that I patched out because we are patching in our own modules.conf:
bare: clean
<...snip...>
$(verbose) rm -f $(mod_conf)
That patch looks like:
--- BUILDROOT/Makefile 2020-08-17 13:25:06.963804709 -0400
+++ FIX/Makefile 2020-08-17 19:25:29.540607763 -0400
## -636,7 +636,6 ##
$(verbose) rm -f $(modxml)
$(verbose) rm -f $(tunxml)
$(verbose) rm -f $(boolxml)
- $(verbose) rm -f $(mod_conf)
$(verbose) rm -f $(booleans)
$(verbose) rm -fR $(htmldir)
$(verbose) rm -f $(tags)
BTW,
Creating a patch with a complete new file in pp1:q!:
diff -crB --new-file pp0 pp1 > pp0.patch

How do I make Alien use an existing tarball instead of downloading?

My distro does not offer any gsl <2.6 any more.
Given:
Alien::GSL 1.01
/tmp/gsl-2.5.tar.gz
How do I force it to compile that gsl instead of downloading from GNU FTP version 2.6, which I already have on the system anyway but is not delectable to Math::GSL 0.40?
I unsuccessfully tried:
copying the tarball into the unpacked Alien::GSL base directory
messing with alien_repository
This is for a throw-away project. I'm okay with manual installation instructions and patching toolchain code.
ikegami found the decisive hint:
It looks like you can set protocol of local to use a local file
Tested step-by-step instructions, plus some additional work-arounds; to me it looks like the build systems of the two modules are buggy/insufficiently tested:
cpanm --look Alien::GSL
patch Build.PL
diff --git a/Build.PL b/Build.PL
index 32f3057..6537138 100644
--- a/Build.PL
+++ b/Build.PL
## -20,10 +20,9 ## my $builder = Alien::Base::ModuleBuild->new(
alien_name => 'gsl',
alien_repository => [
{
- protocol => 'ftp',
- host => 'ftp.gnu.org',
- location => '/gnu/gsl',
- pattern => qr/^gsl-([\d\.]+)\.tar\.gz$/,
+ protocol => 'local',
+ location => '/tmp',
+ pattern => 'gsl-2.5.tar.gz',
},
],
meta_merge => {
--
2.23.0
perl Build.PL
./Build
Pay attention to the generated configure/libtool commands here, they match the Perl configuration. A manual installation without those various options is not guaranteed to be compatible or usable. (This is not superstition: a similar problem historically shows up when installing mod_perl2 and libapreq2 from source on a system httpd; perl needs to be compiled first, then httpd to match, then the other packages, otherwise it won't work.) This shows the value of installing through Alien, since it delegates to M::B, the correct options will be figured out. It's above my level of knowledge to accurately create them from scratch.
./Build test
gsl-config in blib now erroneously contains build paths, not install paths, fix:
perl -MConfig -i -lpe'
s|/.*(/auto/share/dist/Alien-GSL)|$Config{installsitelib}$1|
' blib/lib/auto/share/dist/Alien-GSL/bin/gsl-config
./Build install
exit # cpanm
cpanm --look Math::GSL
# let it pick up gsl-config on PATH
export PATH=$PATH:$(perl -mAlien::GSL -e'print Alien::GSL->bin_dir')
perl Build.PL
./Build
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(gsl-config --libs | perl -lne'/-L(\S+) / && print $1')
./Build test
./Build install
exit # cpanm
Finally rëexport the variables whenever you want to use Math::GSL.

config.site for vendor libs on Fedora x86_64

I'm having trouble building a few Autotool-based libraries on Fedora 26, x86_64. The 64-bit Fedora puts third party and vendor libraries in /usr/local/lib64. Ubuntu 17 uses /usr/local/lib so the same projects build OK.
I've been using --libdir=/usr/local/lib64 but three libraries resist it. I lack a config.site for /usr/local so I am trying to add one. The Autoconf manual on Site Defaults is a tad bit confusing to me when it discusses usr/local's config.site. It says:
[discussion of /usr version of confg.site] ...
Likewise, on platforms where 64-bit libraries are built by default,
then installed in /usr/local/lib64 instead of /usr/local/lib, it is
appropriate to install /usr/local/share/config.site:
# /usr/local/share/config.site for platforms that prefer
# the directory /usr/local/lib64 over /usr/local/lib.
test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
The problem I am having is, is the modification above appended to the /usr/local version of config.site? Or does it replace an existing block of code? Or can I just copy it where it belongs without modification?
Or maybe, what does a cat of /usr/local/share/config.site look like?
Here is the config.site for /usr. Its not clear to me if it needs modification or how to modify it.
$ cat /usr/share/config.site
# This is the config.site file to satisfy FHS defaults when installing below
# /usr.
#
# You may override this file by your config.site using the CONFIG_SITE env
# variable.
#
# Note: This file includes also RHEL/Fedora fix for installing libraries into
# "/lib/lib64" on 64bit systems.
if test -n "$host"; then
# skip when cross-compiling
return 0
fi
if test "$prefix" = /usr \
|| { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; }
then
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
test "$localstatedir" = '${prefix}/var' && localstatedir=/var
ARCH=`uname -m`
for i in x86_64 ppc64 s390x aarch64; do
if test $ARCH = $i; then
test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
break
fi
done
fi
config.site for vendor libs on Fedora x86_64
This answers the question of what config.site looks like for /usr/local/share/config.site. It does not answer the question of why --libdir=/usr/local/lib64 fails to set the directory, as #John Bollinger pointed out in the comments.
The /usr/local/share/config.site is wrong. Though it was copied from Fedora's config.site and placed in /usr/local/share, the prefix directories are wrong. The prefix test should use /usr/local and not /usr.
Below is the corrected one.
$ cat /usr/local/share/config.site
...
if test -n "$host"; then
# skip when cross-compiling
return 0
fi
if test "$prefix" = /usr/local \
|| { test "$prefix" = NONE && test "$ac_default_prefix" = /usr/local ; }
then
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
test "$localstatedir" = '${prefix}/var' && localstatedir=/var
ARCH=`uname -m`
for i in x86_64 ppc64 s390x aarch64; do
if test $ARCH = $i; then
test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
break
fi
done
fi
I'm not sure if these are correct, however. They were not modified.
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
test "$localstatedir" = '${prefix}/var' && localstatedir=/var
Now, the next question is, why Fedora's /usr/share/config.site is not handling prefix=/usr/local properly. That's an open question at Issue 1510073 : Autoconf does not honor libdir in config.site for "libdir=#libdir#" in *.pc file, which has been closed as NOT A BUG.

Buildroot Config Option for applying custom patch

I am new to buildroot and working to build Linaro with buildroot ..I have multiple fragment kernel config files and specified that in buildroot defconfig.
I have specified a custom kernel patches directory with BR2_LINUX_PATCH_DIR .
I dont have some of the config flags not set which are supposed to be there in the .config files..so i suspect that the Patches are applied successfully..so i tried giving a non existing location as Linux Patch dir and it does not give any error..
Is there anything other than giving value to BR2_LINUX_PATCH_DIR and what should be the format of the dir structure...in buildroot manual it says it should be
Package_name/patch name..For linux what should be the package name? It should be the same with which linux dir is created.for example for me it is linux-custom
Plz suggest and guide me in this.
Thanks in Advance
The option is named BR2_LINUX_KERNEL_PATCH, there is nothing named BR2_LINUX_PATCH_DIR. It applies all patches listed in this option (if those are files), or all files named *.patch if what's given in this option is a directory. See the code in linux/linux.mk:
define LINUX_APPLY_LOCAL_PATCHES
for p in $(filter-out ftp://% http://% https://%,$(LINUX_PATCHES)) ; do \
if test -d $$p ; then \
$(APPLY_PATCHES) $(#D) $$p \*.patch || exit 1 ; \
else \
$(APPLY_PATCHES) $(#D) `dirname $$p` `basename $$p` || exit 1; \
fi \
done
endef
Also, I would recommend that you watch the output of Buildroot: it shows everything it is doing, especially it lists the patches it applied. Look at the line >>> linux .... Patching, which is the marker for the beginning of the patching step of the linux package.

RTEMS libbsd compilation issue

I followed the steps mentioned in the link
https://github.com/RTEMS/rtems-libbsd
for sparc and 4.12 version.
# cd /opt
# mkdir RTEMS
# cd RTEMS
# sandbox="$PWD/sandbox"
# mkdir sandbox
# cd "$sandbox"
# git clone git://git.rtems.org/rtems-source-builder.git
# git clone git://git.rtems.org/rtems.git
# git clone git://git.rtems.org/rtems-libbsd.git
Build and install the tools.
# cd rtems-source-builder/rtems
# ../source-builder/sb-set-builder --prefix="$sandbox/rtems-4.12" 4.12/rtems-sparc
Bootstrap the RTEMS sources:
-----------------------------
# cd "$sandbox"
# cd rtems
# PATH="$sandbox/rtems-4.12/bin:$PATH"
# ./bootstrap
# cd "$sandbox" or cd ..
# mkdir b-sis
# cd b-sis
# "$sandbox/rtems/configure" --target=sparc-rtems4.12 --prefix="$sandbox/rtems-4.12" --disable-networking --enable-tests=samples --enable-rtemsbsp=sis
# make
# make install
Build and install rtems-libbsd
================================
# cd "$sandbox"
# cd rtems-libbsd
# git submodule init
# git submodule update rtems_waf
# waf configure --prefix="$sandbox/rtems-4.12" --rtems-bsps=sparc/sis
In this step I got an error
Setting top to : /home/subhilash/RTEMS/sandbox/rtems-libbsd
Setting out to : /home/subhilash/RTEMS/sandbox/rtems-libbsd/build
No valid arch/bsps found
The error means waf configure was unable to find sparc/sis installed in your prefix. Probably, configure and make failed without an obvious error due to the removal of the sis BSP from RTEMS during the 4.12 development cycle. Try using erc32 instead of sis.
You may get timelier responses about RTEMS by inquiring on the users mailing list.
You should also be aware that the sis simulator for the erc32 does not have a simulated NIC. And as I right this, the greth driver that you probably want for LEON CPUs doesn't yet have a driver in the rtems-libbsd TCP/IP stack. It is supported by the legacy IPV4 stack.
We would welcome a contribution to port this driver to the new stack.
I don't know if the greth driver is supported by qemu but the basic leon3 is supported.