Skip to content

Commit 5863197

Browse files
committed
libbz2: add pkg-config file (bzip2.pc)
Add generation of a bzip2.pc file for use with pkg-config and create a basic template as bzip2.pc.in. This allows other software to easily locate and link against libbz2 using standard pkg-config mechanisms instead of manual compiler and linker flags. The version number is extracted automatically from bzlib.h to keep it consistent with the library sources. Tested: pkg-config --exists --print-errors "bzip2 >= 1.0.9" (fail, expected) pkg-config --exists --print-errors "bzip2 >= 1.0" (succeeded) pkg-config --libs bzip2 (-lbz2) pkg-config --cflags bzip2 () MFC after: 3 days
1 parent 53825af commit 5863197

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/libbz2/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,17 @@ CFLAGS+= -I${BZ2DIR}
1313

1414
WARNS?= 3
1515

16+
BZIP2_VERSION!= sed -n '/bzip2\/libbzip2 version /{s/.*version //;s/ of.*//p;q;}' ${BZ2DIR}/bzlib.h
17+
18+
bzip2.pc: bzip2.pc.in
19+
sed -e 's,@prefix@,/usr,g ; \
20+
s,@exec_prefix@,$${prefix},g ; \
21+
s,@libdir@,${LIBDIR},g ; \
22+
s,@sharedlibdir@,${SHLIBDIR},g ; \
23+
s,@includedir@,${INCLUDEDIR},g ; \
24+
s,@VERSION@,${BZIP2_VERSION},g ;' \
25+
${.ALLSRC} > ${.TARGET}
26+
27+
PCFILES= bzip2.pc
28+
1629
.include <bsd.lib.mk>

lib/libbz2/bzip2.pc.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@prefix@
2+
exec_prefix=@exec_prefix@
3+
libdir=@libdir@
4+
sharedlibdir=@sharedlibdir@
5+
includedir=@includedir@
6+
7+
Name: bzip2
8+
Description: bzip2 compression library
9+
Version: @VERSION@
10+
Libs: -L${libdir} -lbz2
11+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)