Automatically generate libbsd.pc from libbsd.pc.in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/.gitignore b/.gitignore
index b6d5193..29dbeb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
ChangeLog
+libbsd.pc
*.lo
*.o
*.so*
diff --git a/Makefile b/Makefile
index e37873e..31a9b07 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ LIB_SHARED := $(LIB_SONAME).$(LIB_VERSION_MINOR)
TAR_NAME := $(LIB_NAME)-$(LIB_VERSION)
TAR_FILE := $(TAR_NAME).tar.gz
-LIB_DIST := Makefile ChangeLog Versions $(LIB_PKGCONFIG)
+LIB_DIST := Makefile ChangeLog Versions $(LIB_PKGCONFIG).in
LIB_SRCS := arc4random.c bsd_getopt.c err.c fgetln.c heapsort.c \
humanize_number.c inet_net_pton.c \
@@ -64,6 +64,15 @@ man/md5.3: man/mdX.3
src/hash/md5hl.c: src/hash/helper.c
sed -e 's:hashinc:bsd/md5.h:g' -e 's:HASH:MD5:g' $< > $@
+# FIXME: the variables should be preserved unexpanded in the .pc file
+$(LIB_PKGCONFIG): $(LIB_PKGCONFIG).in
+ sed -e 's:@VERSION@:$(LIB_VERSION):' \
+ -e 's:@prefix@:$(prefix):' \
+ -e 's:@exec_prefix@:$(exec_prefix):' \
+ -e 's:@libdir@:$(libdir):' \
+ -e 's:@includedir@:$(includedir):' \
+ $< > $@
+
$(LIB_STATIC): $(LIB_STATIC_OBJS)
ar rcs $@ $^
@@ -91,7 +100,7 @@ dist: ChangeLog
rm -rf $(TAR_NAME)
gpg -a -b $(TAR_FILE)
-install: libs man
+install: libs man $(LIB_PKGCONFIG)
mkdir -p $(DESTDIR)/$(libdir)
mkdir -p $(DESTDIR)/$(usrlibdir)
mkdir -p $(DESTDIR)/$(includedir)/bsd/
@@ -108,6 +117,7 @@ install: libs man
ln -sf $(LIB_SHARED) $(DESTDIR)/$(libdir)/$(LIB_SONAME)
clean:
+ rm -f $(LIB_PKGCONFIG)
rm -f $(LIB_GEN_SRCS)
rm -f $(LIB_STATIC_OBJS)
rm -f $(LIB_STATIC)
diff --git a/libbsd.pc b/libbsd.pc
deleted file mode 100644
index 9b6b43c..0000000
--- a/libbsd.pc
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=/usr
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: libbsd
-Description: BSD compatibility library
-Version: 0.0
-URL: http://libbsd.freedesktop.org/
-Libs: -L${libdir} -lbsd
-Cflags: -I${includedir}
diff --git a/libbsd.pc.in b/libbsd.pc.in
new file mode 100644
index 0000000..a3b1471
--- /dev/null
+++ b/libbsd.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libbsd
+Description: BSD compatibility library
+Version: @VERSION@
+URL: http://libbsd.freedesktop.org/
+Libs: -L${libdir} -lbsd
+Cflags: -I${includedir}