From 5d414fcb4b2ccc1ce9d6063292f9c63c9ec67b04 Mon Sep 17 00:00:00 2001 From: Umorrian Date: Sat, 7 Mar 2015 20:33:06 +0100 Subject: [PATCH] makefile: add un/install targets Add install, install-strip and uninstall targets, make DESTDIR usable. PR-URL: https://github.com/joyent/http-parser/pull/228 Reviewed-By: Fedor Indutny Reviewed-By: Ben Noordhuis --- Makefile | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a032dcf..b50fe68 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,11 @@ CFLAGS_LIB = $(CFLAGS_FAST) -fPIC LDFLAGS_LIB = $(LDFLAGS) -shared +INSTALL ?= install +PREFIX ?= $(DESTDIR)/usr/local +LIBDIR = $(PREFIX)/lib +INCLUDEDIR = $(PREFIX)/include + ifneq (darwin,$(PLATFORM)) # TODO(bnoordhuis) The native SunOS linker expects -h rather than -soname... LDFLAGS_LIB += -Wl,-soname=$(SONAME) @@ -105,6 +110,21 @@ parsertrace_g: http_parser_g.o contrib/parsertrace.c tags: http_parser.c http_parser.h test.c ctags $^ +install: library + $(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h + $(INSTALL) -D $(SONAME) $(LIBDIR)/$(SONAME) + ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.so + +install-strip: library + $(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h + $(INSTALL) -D -s $(SONAME) $(LIBDIR)/$(SONAME) + ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.so + +uninstall: + rm $(INCLUDEDIR)/http_parser.h + rm $(LIBDIR)/$(SONAME) + rm $(LIBDIR)/libhttp_parser.so + clean: rm -f *.o *.a tags test test_fast test_g \ http_parser.tar libhttp_parser.so.* \ @@ -113,4 +133,4 @@ clean: contrib/url_parser.c: http_parser.h contrib/parsertrace.c: http_parser.h -.PHONY: clean package test-run test-run-timed test-valgrind +.PHONY: clean package test-run test-run-timed test-valgrind install install-strip uninstall