Skip to content

Commit

Permalink
media-sound/apulse: add SDK mode
Browse files Browse the repository at this point in the history
Add SDK mode where apulse acts as drop-in replacement for
pulseaudio: headers and pkg-config files are provided, libraries
are installed in standard path.

Signed-off-by: Andrew Savchenko <[email protected]>
Package-Manager: Portage-2.3.49, Repoman-2.3.10
  • Loading branch information
bircoph committed Sep 22, 2018
1 parent 10f5acd commit b152b81
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
57 changes: 57 additions & 0 deletions media-sound/apulse/apulse-0.1.12-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit multilib cmake-multilib

DESCRIPTION="PulseAudio emulation for ALSA"
HOMEPAGE="https://github.com/i-rinat/apulse"
SRC_URI="https://github.com/i-rinat/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64 ~x86"

IUSE="debug sdk test"

DEPEND="dev-libs/glib:2[${MULTILIB_USEDEP}]
media-libs/alsa-lib[${MULTILIB_USEDEP}]
sdk? ( !media-sound/pulseaudio ) "
RDEPEND="${DEPEND}
!!media-plugins/alsa-plugins[pulseaudio]"

MULTILIB_CHOST_TOOLS=( /usr/bin/apulse )

PATCHES=( "${FILESDIR}/sdk.patch" )

src_prepare() {
cmake-utils_src_prepare

if ! use sdk; then
# Ensure all relevant libdirs are added, to support all ABIs
DIRS=
_add_dir() { DIRS="${EPREFIX}/usr/$(get_libdir)/apulse${DIRS:+:${DIRS}}"; }
multilib_foreach_abi _add_dir
sed -e "s#@@DIRS@@#${DIRS}#g" "${FILESDIR}"/apulse > "${T}"/apulse || die
fi
}

multilib_src_configure() {
local mycmakeargs=(
"-DINSTALL_SDK=$(usex sdk)"
"-DLOG_TO_STDERR=$(usex debug)"
"-DWITH_TRACE=$(usex debug)"
)
cmake-utils_src_configure
}

multilib_src_test() {
emake check
}

multilib_src_install_all() {
cmake-utils_src_install
einstalldocs
use sdk || dobin "${T}"/apulse
}
90 changes: 90 additions & 0 deletions media-sound/apulse/files/sdk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 072f3b1..eff028d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,8 @@ else()
include_directories(${PA_INCLUDE_DIRECTORIES})
endif()

+set(INSTALL_SDK 0 CACHE BOOLEAN "Install SDK files to build applications with apulse (Pulse Audio headers and pkg-config files) instead of system ones")
+
link_directories(${REQ_LIBRARY_DIRS})

add_library(trace-helper STATIC
@@ -72,12 +74,30 @@ target_link_libraries(pulse-simple ${SYMBOLMAP} trace-helper ${REQ_LIBRARIES})

add_subdirectory(tests)

-set(APULSEPATH "${CMAKE_INSTALL_PREFIX}/lib/apulse" CACHE PATH "library installation directory")
+if (${INSTALL_SDK})
+ set(APULSEPATH "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "library installation directory")
+else()
+ set(APULSEPATH "${CMAKE_INSTALL_LIBDIR}/apulse" CACHE PATH "library installation directory")
+endif()
+
set(APULSE_SEARCH_PATHS "${APULSEPATH}" CACHE PATH "directory list for LD_LIBRARY_PATH")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/apulse.template"
"${CMAKE_CURRENT_BINARY_DIR}/apulse" @ONLY)
+if (${INSTALL_SDK})
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/libpulse.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libpulse.pc" @ONLY)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/libpulse-simple.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libpulse-simple.pc" @ONLY)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/libpulse-mainloop-glib.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libpulse-mainloop-glib.pc" @ONLY)
+endif()

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/apulse" DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(TARGETS pulse-simple pulse pulse-mainloop-glib DESTINATION "${APULSEPATH}")
install(FILES "${CMAKE_SOURCE_DIR}/man/apulse.1" DESTINATION share/man/man1)
+
+if (${INSTALL_SDK})
+ install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty/pulseaudio-headers/pulse" DESTINATION include)
+ install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+endif()
diff --git a/pkgconfig/libpulse-mainloop-glib.pc.in b/pkgconfig/libpulse-mainloop-glib.pc.in
new file mode 100644
index 0000000..957e3b2
--- /dev/null
+++ b/pkgconfig/libpulse-mainloop-glib.pc.in
@@ -0,0 +1,9 @@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: libpulse-mainloop-glib
+Description: PulseAudio GLib 2.0 Main Loop Wrapper (apulse)
+Version: 5.0
+Libs: -L${libdir} -lpulse-mainloop-glib -pthread
+Cflags: -I${includedir}
+Requires: glib-2.0
diff --git a/pkgconfig/libpulse-simple.pc.in b/pkgconfig/libpulse-simple.pc.in
new file mode 100644
index 0000000..3809d50
--- /dev/null
+++ b/pkgconfig/libpulse-simple.pc.in
@@ -0,0 +1,9 @@
+libdir=@CMAKE_INSTALL_FULL__LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: libpulse-simple
+Description: PulseAudio Simplified Synchronous Client Interface (apulse)
+Version: 5.0
+Libs: -L${libdir} -lpulse-simple -pthread
+Cflags: -I${includedir}
+Requires: glib-2.0
diff --git a/pkgconfig/libpulse.pc.in b/pkgconfig/libpulse.pc.in
new file mode 100644
index 0000000..edcbbd8
--- /dev/null
+++ b/pkgconfig/libpulse.pc.in
@@ -0,0 +1,9 @@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: libpulse
+Description: PulseAudio Client Interface (apulse)
+Version: 5.0
+Libs: -L${libdir} -lpulse -pthread
+Cflags: -I${includedir}
+Requires: glib-2.0 alsa
2 changes: 2 additions & 0 deletions media-sound/apulse/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</maintainer>
<use>
<flag name="pa-headers">Install PulseAudio headers</flag>
<flag name="sdk">Install PulseAudio headers and pkg-config files. Be aware apulse is not
a full PulseAudio replacement by design and some functionality may be missing.</flag>
</use>
<upstream>
<remote-id type="github">i-rinat/apulse</remote-id>
Expand Down

0 comments on commit b152b81

Please sign in to comment.