Add pkg-config support. The libgit2.pc is generated on make install and installed, to allow using the lib through the pkg-config helper. Signed-off-by: Steve Frécinaux <code@istique.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
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
diff --git a/.gitignore b/.gitignore
index 27c3c27..66ce776 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
/apidocs
/trash-*.exe
+/libgit2.pc
*.o
*.a
*.exe
diff --git a/Makefile b/Makefile
index bf2fe2a..4063e6c 100644
--- a/Makefile
+++ b/Makefile
@@ -46,16 +46,19 @@ install-headers: $(PUBLIC_HEADERS)
@mkdir -p /tmp/gitinc/git
@for i in $^; do cat .HEADER $$i > /tmp/gitinc/$${i##src/}; done
-install: $(GIT_LIB) $(PUBLIC_HEADERS)
+install: $(GIT_LIB) $(PUBLIC_HEADERS) libgit2.pc
@mkdir -p $(prefix)/include/git
@for i in $(PUBLIC_HEADERS); do \
cat .HEADER $$i > $(prefix)/include/$${i##src/}; \
done
@mkdir -p $(prefix)/lib
@cp -f $(GIT_LIB) $(prefix)/lib/libgit2.a
+ @mkdir -p $(prefix)/lib/pkgconfig
+ @cp -f libgit2.pc $(prefix)/lib/pkgconfig/libgit2.pc
uninstall:
@rm -f $(prefix)/lib/libgit2.a
+ @rm -f $(prefix)/lib/pkgconfig/libgit2.pc
@for i in $(PUBLIC_HEADERS); do \
rm -f $(prefix)/include/$${i##src/}; \
done
@@ -105,6 +108,9 @@ $(TEST_RUN): tests/%.run: tests/%.exe
else rmdir $$t; exit 1; \
fi
+libgit2.pc: libgit2.pc.in
+ sed 's#@prefix@#$(prefix)#' $< > $@
+
.PHONY: all
.PHONY: clean
.PHONY: test $(TEST_RUN)
diff --git a/libgit2.pc.in b/libgit2.pc.in
new file mode 100644
index 0000000..9e2cd50
--- /dev/null
+++ b/libgit2.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libgit2
+Description: The git library, take 2
+Version: 0.0.1
+Requires:
+Libs: -L${libdir} -lgit2
+Cflags: -I${includedir}