# @packagehubzero-mw2-exec-virtualssh
# @file         Makefile
# @author       Pascal Meunier <pmeunier@purdue.edu>
# @copyright    Copyright (c) 2016-2017 HUBzero Foundation, LLC.
# @license      http://opensource.org/licenses/MIT MIT
#
#
# Copyright (c) 2016-2017 HUBzero Foundation, LLC.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# HUBzero is a registered trademark of HUBzero Foundation, LLC.
#

# Common libraries are installed as owned by root so the client can't modify them, as root may need to use them 

VARLIBDIR=$(DESTDIR)/var/lib
LOGDIR=$(DESTDIR)/var/log
OWNER=root
USRBIN=$(DESTDIR)/usr/bin
USRSBIN=$(DESTDIR)/usr/sbin
USRLIB=$(DESTDIR)/usr/lib
ETC=$(DESTDIR)/etc
USRSHARE=$(DESTDIR)/usr/share
USRSHAREMAN=$(DESTDIR)/usr/share/man
USRSHAREDOC=$(DESTDIR)/usr/share/doc
SBIN=$(DESTDIR)/sbin
VARLOG=$(DESTDIR)/var/log
USRSHAREMANMAN8=$(DESTDIR)/usr/share/man/man8
USRLOCAL=$(DESTDIR)/usr/local

all:
	@true

install:
	install --mode 0755 -D vsshd_start $(USRBIN)/vsshd_start
	install --mode 0755 -D vssh_exec_proxy $(USRBIN)/vssh_exec_proxy
	# no logs so no log rotation
	install --mode 0755 -d $(ETC)/mw-virtualssh
	install --mode 0640 -D exec_ssh_config $(ETC)/mw-virtualssh/exec_ssh_config
	install --mode 0644 -D sshd_config $(ETC)/mw-virtualssh/sshd_config
	install --mode 0755 -D xauth $(ETC)/mw-virtualssh/xauth
	install --mode 0750 -d $(VARLOG)/mw-virtualssh

manual_install: install
	@true

uninstall:
	rm -f $(USRBIN)/vsshd_start
	rm -f $(USRBIN)/vssh_exec_proxy

postinst:
	@true

clean:
	rm -f $(USRBIN)/vsshd_start
	rm -f $(USRBIN)/vssh_exec_proxy
	rm -f $(ETC)/mw-virtualssh/exec_ssh_config
	rm -f $(ETC)/mw-virtualssh/sshd_config
	rm -f $(ETC)/mw-virtualssh/xauth
	rm -f $(ETC)/mw-virtualssh/ssh_guest_key
	rm -rf $(ETC)/mw-virtualssh/ssh

.PHONY: all install uninstall postinst clean
