Commit d7fbfe155fbddb41936407612fbce9c34276b671

Steve Frécinaux 2008-12-30T12:10:01

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>

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}