Some notes:

* This depends on 'androgenizer', a tool to generate Android-style
  Android.mk files from an autotools build system.

* This assumes that PA is run as the system daemon and configures
  accordingly.

* In the Android build, libltdl is likely not available when configure
  is being run, and we know it will be so the check is manually
  overridden.

* NEON support needs to be communicated from an upper-level Android.mk.

* rpaths don't work on Android - you need LD_LIBRARY_PATH set.

* Configuration files for /etc/pulse are shipped out of tree, since they
  vary from device to device.

* The original patch was massive and ugly, but thanks Pekka Paalanen's
  work on Weston to break out common androgenizer snippets, we could
  greatly decrease the size of the Android-specific elements.

* Since we don't use libtool for linking, we need to work around some
  symbol definition problems that turn up. This is done in a separate
  file (pulseaudio-android-symdef.c). More information about this at:
  http://www.sourceware.org/autobook/autobook/autobook_173.html (the
  example snippet needs some fixing to work with current libtool).
---
 Android.mk                             |  94 +++++++++++++++++++++++
 src/Makefile.am                        | 135 +++++++++++++++++++++++++++++++++
 src/daemon/pulseaudio-android.symdef.c |   6 ++
 3 files changed, 235 insertions(+)
 create mode 100644 Android.mk
 create mode 100644 src/daemon/pulseaudio-android.symdef.c

diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..cf05c63
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,94 @@
+# Top-level Makefile for Android
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+pulseaudio_TOP := $(LOCAL_PATH)
+
+PA_BUILT_SOURCES := src/Android.mk
+
+PA_BUILT_SOURCES := $(patsubst %, $(abspath $(pulseaudio_TOP))/%, 
$(PA_BUILT_SOURCES))
+
+CONFIGURE_CFLAGS += -I$(PULSEAUDIO_TOP)/libtool/libltdl
+
+SPEEX_CFLAGS := -Iexternal/speex/include
+SPEEX_LIBS := -lspeexresampler
+
+# We have to explicitly enable or disable NEON support
+ifeq ($(PA_ENABLE_NEON),yes)
+CONFIGURE_NEON := enable
+else
+CONFIGURE_NEON := disable
+endif
+
+.PHONY: pulseaudio-configure
+
+pulseaudio-configure:
+       echo $(PA_BUILT_SOURCES)
+       cd $(pulseaudio_TOP) ; \
+       CC="$(CONFIGURE_CC)" \
+       CFLAGS="$(CONFIGURE_CFLAGS)" \
+       CXX="$(CONFIGURE_CXX)" \
+       CXXFLAGS="$(CONFIGURE_CXXFLAGS)" \
+       LD="$(TARGET_LD)" \
+       LDFLAGS="$(CONFIGURE_LDFLAGS)" \
+       CPP="$(CONFIGURE_CPP)" \
+       CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \
+       CXXCPP="$(CONFIGURE_CXXCPP)" \
+       CXXCPPFLAGS="$(CONFIGURE_CXXCPPFLAGS)" \
+       PKG_CONFIG_LIBDIR="$(CONFIGURE_PKG_CONFIG_LIBDIR)" \
+       PKG_CONFIG_TOP_BUILD_DIR="/" \
+       LIBSPEEX_CFLAGS="$(SPEEX_CFLAGS)" LIBSPEEX_LIBS="$(SPEEX_LIBS)" \
+       ac_cv_header_sys_un_h=yes \
+       ac_cv_lib_ltdl_lt_dladvise_init=yes \
+       $(abspath $(pulseaudio_TOP))/$(CONFIGURE) --host=$(CONFIGURE_HOST) \
+       --prefix=/system \
+       --localstatedir=/data/pulse \
+       --disable-nls \
+       --$(CONFIGURE_NEON)-neon-opt \
+       --disable-largefile \
+       --disable-rpath \
+       --disable-x11 \
+       --disable-samplerate \
+       --disable-oss-output \
+       --disable-oss-wrapper \
+       --disable-coreaudio-output \
+       --enable-alsa \
+       --disable-esound \
+       --disable-solaris \
+       --disable-waveout \
+       --disable-glib2 \
+       --disable-gconf \
+       --disable-avahi \
+       --disable-jack \
+       --disable-asyncns \
+       --disable-tcpwrap \
+       --disable-lirc \
+       --disable-dbus \
+       --disable-bluez \
+       --disable-udev \
+       --disable-hal-compat \
+       --disable-ipv6 \
+       --disable-openssl \
+       --disable-orc \
+       --disable-manpages \
+       --enable-per-user-esound-socket \
+       --disable-webrtc-aec \
+       --disable-default-build-tests \
+       --disable-legacy-database-entry-format \
+       --disable-static-bins \
+       --disable-force-preopen \
+       --without-caps \
+       --with-database=simple \
+       --without-fftw \
+       --with-system-user=root \
+       --with-system-group=root \
+       && \
+       for file in $(PA_BUILT_SOURCES); do \
+               rm -f $$file && \
+               make -C $$(dirname $$file) $$(basename $$file) ; \
+       done
+
+PA_CONFIGURE_TARGETS += pulseaudio-configure
+
+-include $(pulseaudio_TOP)/src/Android.mk
diff --git a/src/Makefile.am b/src/Makefile.am
index 9d96a9b..c9ca042 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2167,3 +2167,138 @@ coverage:
 endif
 
 .PHONY: massif update-all update-ffmpeg update-map-file coverage
+
+# Android build targets
+
+ANDROID_CFLAGS = -std=c99 -I$(top_srcdir) -DHAVE_CONFIG_H
+
+myvalue = $($(subst .,_,$(subst -,_,$(1)))_$(2))
+myvalue_p = $($(1)_$(subst .,_,$(subst -,_,$(2)))_$(3))
+empty :=
+slash := $(empty)\$(empty)
+
+define executables
+$(foreach myexec,$(1), $(slash)
+       -:EXECUTABLE $(myexec) $(slash)
+       -:TAGS eng debug $(slash)
+       -:SOURCES $(call myvalue,$(myexec),SOURCES) $(call 
myvalue_p,nodist,$(myexec),SOURCES) $(slash)
+       -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) $(call myvalue,$(myexec),CFLAGS) 
$(slash)
+       -:LDFLAGS $(call myvalue,$(myexec),LDFLAGS) $(call 
myvalue,$(myexec),LDADD) $(slash)
+       -:PASSTHROUGH 'LOCAL_ARM_MODE := arm' $(slash)
+       $(slash)
+)
+endef
+
+define modlibs
+$(foreach mymod,$(1),  $(slash)
+       -:SHARED $(mymod:%.la=%) $(slash)
+       -:TAGS eng debug $(slash)
+       -:SOURCES $(call myvalue,$(mymod),SOURCES) $(call 
myvalue_p,nodist,$(mymod),SOURCES) $(slash)
+       -:CFLAGS $(DEFS) $(AM_CPPFLAGS) $(ANDROID_CFLAGS) $(call 
myvalue,$(mymod),CFLAGS) $(slash)
+       -:LDFLAGS $(call myvalue,$(mymod),LDFLAGS) $(call 
myvalue,$(mymod),LIBADD) $(slash)
+       -:PASSTHROUGH 'LOCAL_ARM_MODE := arm' $(slash)
+       -:PASSTHROUGH 'LOCAL_MODULE_PATH := $$(PRODUCT_OUT)$(modlibexecdir)' 
$(slash)
+)
+endef
+
+if HAVE_NEON
+neon_libs := pulsecore_sconv_neon pulsecore_mix_neon
+androgenizer_neon = \
+               -:STATIC libpulsecore_sconv_neon \
+               -:TAGS eng debug \
+               -:SOURCES $(libpulsecore_sconv_neon_la_SOURCES) 
$(nodist_libpulsecore_sconv_neon_la_SOURCES) \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) 
$(libpulsecore_sconv_neon_la_CFLAGS) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+               \
+               -:STATIC libpulsecore_mix_neon \
+               -:TAGS eng debug \
+               -:SOURCES $(libpulsecore_mix_neon_la_SOURCES) 
$(nodist_libpulsecore_mix_neon_la_SOURCES) \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) 
$(libpulsecore_mix_neon_la_CFLAGS) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm
+else
+neon_libs :=
+androgenizer_neon :=
+endif
+
+ANDROID_MODLIBS :=             \
+    libcli.la                  \
+    libprotocol-cli.la         \
+    libprotocol-simple.la      \
+    libprotocol-http.la                \
+    libprotocol-native.la      \
+    librtp.la                  \
+    libalsa-util.la
+
+ANDROID_MODULES :=                     \
+    module-alsa-card.la                        \
+    module-alsa-sink.la                        \
+    module-alsa-source.la              \
+    module-null-sink.la                        \
+    module-null-source.la              \
+    module-cli.la                      \
+    module-native-protocol-unix.la     \
+    module-native-protocol-tcp.la      \
+    module-http-protocol-tcp.la                \
+    module-intended-roles.la           \
+    module-default-device-restore.la   \
+    module-rescue-streams.la           \
+    module-always-sink.la              \
+    module-suspend-on-idle.la          \
+    module-tunnel-sink.la              \
+    module-tunnel-source.la
+
+ANDROID_EXECUTABLES := \
+    pactl              \
+    pacmd              \
+    pacat              \
+    pasuspender
+
+# We make all the modules, libs and executables a dependency of the pulseaudio
+# executable to provide 'pulseaudio' as a quick rebuild target for everything
+# in this source tree.
+Android.mk: Makefile.am $(BUILT_SOURCES)
+       androgenizer -:PROJECT pulseaudio \
+               -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+               -:SHARED libpulsecore-@PA_MAJORMINOR@ \
+               -:TAGS eng debug \
+               -:SOURCES $(libpulsecore_@PA_MAJORMINOR@_la_SOURCES) 
$(nodist_libpulsecore_@PA_MAJORMINOR@_la_SOURCES) \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) 
$(libpulsecore_@PA_MAJORMINOR@_la_CFLAGS) \
+               -:LDFLAGS $(libpulsecore_@PA_MAJORMINOR@_la_LDFLAGS) 
$(libpulsecore_@PA_MAJORMINOR@_la_LIBADD) \
+               -:LIBFILTER_STATIC pulsecore-foreign $(neon_libs) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+               \
+               -:SHARED libpulsecommon-@PA_MAJORMINOR@ \
+               -:TAGS eng debug \
+               -:SOURCES $(libpulsecommon_@PA_MAJORMINOR@_la_SOURCES) 
$(nodist_libpulsecommon_@PA_MAJORMINOR@_la_SOURCES) \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) 
$(libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS) \
+               -:LDFLAGS $(libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS) 
$(libpulsecommon_@PA_MAJORMINOR@_la_LIBADD) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+               \
+               -:STATIC libpulsecore-foreign \
+               -:TAGS eng debug \
+               -:SOURCES $(libpulsecore_foreign_la_SOURCES) 
$(nodist_libpulsecore_foreign_la_SOURCES) \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) 
$(libpulsecore_foreign_la_CFLAGS) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+               \
+               $(androgenizer_neon) \
+               \
+               -:SHARED libpulse \
+               -:TAGS eng debug \
+               -:SOURCES $(libpulse_la_SOURCES) $(nodist_libpulse_la_SOURCES) \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) $(libpulse_la_CFLAGS) \
+               -:LDFLAGS $(libpulse_la_LDFLAGS) $(libpulse_la_LIBADD) \
+               -:HEADER_TARGET pulse \
+               -:HEADERS $(pulseinclude_HEADERS) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+               \
+               -:EXECUTABLE pulseaudio \
+               -:TAGS eng debug \
+               -:SOURCES $(pulseaudio_SOURCES) $(nodist_libpulseaudio_SOURCES) 
\
+                         daemon/pulseaudio-android.symdef.c \
+               -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) $(pulseaudio_CFLAGS) \
+               -:LDFLAGS $(pulseaudio_LDFLAGS) $(pulseaudio_LDADD) \
+               -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+               -:PASSTHROUGH LOCAL_REQUIRED_MODULES:='$(foreach 
m,$(ANDROID_MODLIBS) $(ANDROID_MODULES),$(subst .la,,$(m))) 
$(ANDROID_EXECUTABLES)' \
+               $(call executables,$(ANDROID_EXECUTABLES)) \
+               $(call modlibs,$(ANDROID_MODLIBS) $(ANDROID_MODULES)) \
+       > $@
diff --git a/src/daemon/pulseaudio-android.symdef.c 
b/src/daemon/pulseaudio-android.symdef.c
new file mode 100644
index 0000000..643de5c
--- /dev/null
+++ b/src/daemon/pulseaudio-android.symdef.c
@@ -0,0 +1,6 @@
+#include <ltdl.h>
+
+const lt_dlsymlist lt_preloaded_symbols[] = {
+    { "@PROGRAM@", 0 },
+    { 0, 0 }
+};
-- 
1.8.3.1

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to