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>
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
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