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

SO_VERSION_MAJOR   = 4
SO_VERSION_MINOR   = 0
SO_VERSION_RELEASE = 0

SO_VERSION = $(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_RELEASE)


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

default: install

install:
	mkdir -p -m 755 $(PREFIX)
	mkdir -p -m 755 $(PREFIX)/lib
	mkdir -p -m 755 $(PREFIX)/lib/pkgconfig
	mkdir -p -m 755 $(PREFIX)/include

	cp $(CPOPT) libwebsockets.pc $(PREFIX)/lib/pkgconfig/libwebsockets.pc
	cp $(CPOPT) libwebsockets.h $(PREFIX)/include/libwebsockets.h
	cp $(CPOPT) lib/libwebsockets.a $(PREFIX)/lib/libwebsockets.a
	cp $(CPOPT) lib/libwebsockets.so.$(SO_VERSION) $(PREFIX)/lib/libwebsockets.so.$(SO_VERSION)
	cd $(PREFIX)/lib; rm -f libwebsockets.so; ln -s libwebsockets.so.$(SO_VERSION) libwebsockets.so


uninstall:
	rm -f $(PREFIX)/lib/pkgconfig/libwebsockets.pc
	rm -f $(PREFIX)/include/libwebsockets.h
	rm -f $(PREFIX)/lib/libwebsockets.a
	rm -f $(PREFIX)/lib/libwebsockets.so.$(SO_VERSION)
	rm -f $(PREFIX)/lib/libwebsockets.so
	rm -f $(PREFIX)/bin/libwebsockets-test-client
	rm -f $(PREFIX)/bin/libwebsockets-test-server
	rm -f $(PREFIX)/bin/libwebsockets-test-server-extpoll
	rm -f $(PREFIX)/bin/libwebsockets-test-fraggle
	rm -f $(PREFIX)/bin/libwebsockets-test-ping
	rm -f $(PREFIX)/bin/libwebsockets-test-echo
	rm -rf $(PREFIX)/share/libwebsockets-test-server/
