# Makefile for hiredis install/uninstall
PREFIX = /usr/local

SO_VERSION_MAJOR   =  0
SO_VERSION_MINOR   = 10

SO_VERSION = $(SO_VERSION_MAJOR).$(SO_VERSION_MINOR)


CPOPT = --preserve=mode,timestamps --no-preserve=ownership

default: install

install: libhiredis.a
	install -d -m 0755 $(PREFIX)/include/hiredis
	install -d -m 0755 $(PREFIX)/include/hiredis/adapters
	install -d -m 0755 $(PREFIX)/lib
	install -p -m 0644 hiredis.h async.h  $(PREFIX)/include/hiredis
	install -p -m 0644 adapters/*  $(PREFIX)/include/hiredis/adapters
	install -p -m 0644 libhiredis.a  $(PREFIX)/lib
	install -p -m 0644 libhiredis.so $(PREFIX)/lib/libhiredis.so.$(SO_VERSION)
	cd $(PREFIX)/lib && ln -sf libhiredis.so.0.10 libhiredis.so.$(SO_VERSION_MAJOR)
	cd $(PREFIX)/lib && ln -sf libhiredis.so.0 libhiredis.so

libhiredis.a: net.o hiredis.o sds.o async.o
	ar rcs $@ net.o hiredis.o sds.o async.o


uninstall:
	rm -rf $(PREFIX)/include/hiredis
	rm -f  $(PREFIX)/lib/libhiredis.so.$(SO_VERSION)
	rm -f  $(PREFIX)/lib/libhiredis.so.$(SO_VERSION_MAJOR)
	rm -f  $(PREFIX)/lib/libhiredis.so
	rm -f  $(PREFIX)/lib/libhiredis.a
