[libubootenv,v2] libubootenv: add pkg-config support
diff mbox series

Message ID 1578415105-11322-1-git-send-email-pjtexier@koncepto.io
State Accepted
Headers show
Series
  • [libubootenv,v2] libubootenv: add pkg-config support
Related show

Commit Message

'Pierre-Jean Texier' via swupdate Jan. 7, 2020, 4:38 p.m. UTC
Create a libubootenv.pc file for pkg-config. Allows to use
PKG_CHECK_MODULE in autoconf-based projects or :

ubootenv_dep = dependency('libubootenv', version : '>= 0.2')

for meson build system.

Fixes:

$: meson build
The Meson build system
Cross C compiler: arm-poky-linux-gnueabi-gcc ...
[...]
Cross dependency libubootenv found: NO (tried pkgconfig)

With this commit:

$: meson builld
The Meson build system
Cross C compiler: arm-poky-linux-gnueabi-gcc ...
[...]
Cross dependency libubootenv found: YES 0.2
Build targets in project: 1

Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
---
Changes v1 -> v2
	- Remove PROJECT_NAME variable (after review of Stefano)

 src/CMakeLists.txt    | 12 ++++++++++++
 src/libubootenv.pc.in | 10 ++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 src/libubootenv.pc.in

Patch
diff mbox series

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 051732b..ad05ecc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,3 +23,15 @@  install (TARGETS ubootenv DESTINATION lib)
 install (FILES libuboot.h DESTINATION include)
 install (TARGETS fw_printenv DESTINATION bin)
 install (TARGETS fw_setenv DESTINATION bin)
+
+# Handle pkg-config files
+set(prefix      ${CMAKE_INSTALL_PREFIX})
+set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
+set(includedir  ${CMAKE_INSTALL_PREFIX}/include)
+set(libdir      ${CMAKE_INSTALL_PREFIX}/lib)
+
+configure_file(${CMAKE_SOURCE_DIR}/src/libubootenv.pc.in ${CMAKE_BINARY_DIR}/libubootenv.pc @ONLY)
+set(LIBUBOOTENV_PKG_CONFIG_FILES ${CMAKE_BINARY_DIR}/libubootenv.pc)
+message(STATUS "Generate ${LIBUBOOTENV_PKG_CONFIG_FILES}")
+# Install pkg-config files
+install(FILES ${LIBUBOOTENV_PKG_CONFIG_FILES} DESTINATION lib/pkgconfig)
diff --git a/src/libubootenv.pc.in b/src/libubootenv.pc.in
new file mode 100644
index 0000000..31806a9
--- /dev/null
+++ b/src/libubootenv.pc.in
@@ -0,0 +1,10 @@ 
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libubootenv
+Description: Library to access U-Boot environment
+Version: @VERSION@
+Libs: -L${libdir} -lubootenv -lz
+Cflags: -I${includedir}