[Sheepdog] [PATCH 5/5] add pkgconfig support for libacrd

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Wed Nov 2 18:08:13 CET 2011


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 Makefile              |    4 +++-
 libacrd/Makefile      |   18 ++++++++++++++++--
 libacrd/libacrd.pc.in |   11 +++++++++++
 3 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 libacrd/libacrd.pc.in

diff --git a/Makefile b/Makefile
index f43439c..a027d6e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,8 @@
+VERSION ?= 0.0.1
+
 PREFIX ?= /usr
 
-export PREFIX
+export VERSION PREFIX
 
 .PHONY:all
 all:
diff --git a/libacrd/Makefile b/libacrd/Makefile
index 88ce65f..6338c02 100644
--- a/libacrd/Makefile
+++ b/libacrd/Makefile
@@ -8,6 +8,8 @@ LIBACRD_OBJS = libacrd.o ../lib/net.o ../lib/work.o ../lib/coroutine.o
 LIBACRD_DEP = $(LIBACRD_OBJS:.o=.d)
 LIBACRD_VERSION = libacrd.map
 
+PCFILES = libacrd.pc
+
 ARFLAGS = cru
 RANLIB = ranlib
 
@@ -21,6 +23,16 @@ libacrd.a: $(LIBACRD_OBJS)
 libacrd.so: $(LIBACRD_OBJS)
 	$(CC) -shared $^ -o $@ -Wl,-version-script=$(LIBACRD_VERSION)
 
+libacrd.pc: libacrd.pc.in Makefile
+	rm -f $@-t $@
+	sed \
+		-e 's#@''PREFIX@#$(PREFIX)#g' \
+		-e 's#@''LIBDIR@#$(libdir)#g' \
+		-e 's#@''VERSION@#$(VERSION)#g' \
+	    $< > $@-t
+	chmod a-w $@-t
+	mv $@-t $@
+
 -include $(LIBACRD_DEP)
 
 %.o: %.c
@@ -31,12 +43,14 @@ libacrd.so: $(LIBACRD_OBJS)
 clean:
 	echo $(ARFLAGS)
 	echo $(RANLIB)
-	rm -f *.[od] $(LIBRARIES)
+	rm -f *.[od] $(LIBRARIES) $(PCFILES)
 
 .PHONY:install
-install: $(LIBRARIES)
+install: $(LIBRARIES) $(PCFILES)
 	install -d -m 755 $(DESTDIR)$(libdir)
 	install -m 644 $(LIBRARIES) $(DESTDIR)$(libdir)
+	install -d -m 755 $(DESTDIR)$(libdir)/pkgconfig
+	install -m 644 $(PCFILES) $(DESTDIR)$(libdir)/pkgconfig
 
 # support for GNU Flymake
 check-syntax:
diff --git a/libacrd/libacrd.pc.in b/libacrd/libacrd.pc.in
new file mode 100644
index 0000000..4e07509
--- /dev/null
+++ b/libacrd/libacrd.pc.in
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=${prefix}
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libacrd
+Version: @VERSION@
+Description: libacrd
+Requires:
+Libs: -L${libdir} -lacrd
+Cflags: -I${includedir}
-- 
1.7.1




More information about the sheepdog mailing list