Commit 5ddbd5edf83e034a62499a1a9c94645d7b9030dc

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

Add make install and uninstall targets. It accepts a prefix= parameter (default: /usr/local). Signed-off-by: Steve Frécinaux <code@istique.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

diff --git a/Makefile b/Makefile
index 8c08cf6..bf2fe2a 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@ all::
 
 DOXYGEN = doxygen
 
+prefix=/usr/local
+
 CFLAGS = -g -O2 -Wall
 OS     = unix
 
@@ -44,6 +46,21 @@ 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)
+	@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
+
+uninstall:
+	@rm -f $(prefix)/lib/libgit2.a
+	@for i in $(PUBLIC_HEADERS); do \
+		rm -f $(prefix)/include/$${i##src/}; \
+	done
+	@rmdir $(prefix)/include/git
+
 .c.o:
 	$(CC) $(ALL_CFLAGS) -c $< -o $@
 
@@ -93,4 +110,5 @@ $(TEST_RUN): tests/%.run: tests/%.exe
 .PHONY: test $(TEST_RUN)
 .PHONY: apidocs
 .PHONY: install-headers
+.PHONY: install uninstall
 .PHONY: sparse