From 3fb66694c61502273289861cbc9f61f7db9a7554 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Wed, 26 Dec 2018 15:36:13 -0800 Subject: [PATCH] windows/MSYS Make install improvements Signed-off-by: Russ Magee --- Makefile | 63 +++++++++++++++++++++++++--------------- hkexsh/mintty_wrapper.sh | 6 ++-- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index ec49fe6..596c8d5 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,18 @@ SUBPKGS = logger spinsult hkexnet TOOLS = hkexpasswd hkexsh hkexshd SUBDIRS = $(LIBS) $(TOOLS) +ifeq $(MSYSTEM),MSYS) + GOOS=windows +endif + +ifeq ($(GOOS),windows) +ifeq ($(MSYSTEM),MSYS) + SBIN=bin +endif +else + SBIN=sbin +endif + INSTPREFIX = /usr/local all: common client server passwd @@ -33,21 +45,29 @@ client: common $(MAKE) -C hkexsh -ifeq ($(MSYSTEM),) -ifneq ($(GOOS),windows) server: common - $(MAKE) -C hkexshd +ifeq ($(GOOS),windows) +ifeq ($(MSYSTEM),MSYS) + @echo "(GOOS=windows, MSYSTEM=MSYS):hkexshd server not (yet) supported on Windows" else - echo "Cross-build of hkexshd server for Windows not yet supported" + @echo "(GOOS=windows, MSYSTEM=?):Cross-build of hkexshd server not (yet) supported" endif else -server: common - echo "hkexshd server not (yet) supported on Windows" + $(MAKE) -C hkexshd endif passwd: common +ifneq ($(GOOS),windows) +ifeq ($(MSYSTEM),MSYS) + @echo "(GOOS=windows, MSYSTEM=MSYS): Building hkexpasswd, but won't install until hkexshd works on (windows,MSYS)." $(MAKE) -C hkexpasswd +else + @echo "(GOOS=windows, MSYSTEM=?): unsupported uninstall config." +endif +else + $(MAKE) -C hkexpasswd +endif vis: @which go-callvis >/dev/null 2>&1; \ @@ -66,28 +86,23 @@ lint: reinstall: uninstall install -install: - cp hkexsh/hkexsh $(INSTPREFIX)/bin -ifeq ($(MSYSTEM),) -ifneq ($(GOOS),windows) - cp hkexshd/hkexshd hkexpasswd/hkexpasswd $(INSTPREFIX)/sbin +install: client server passwd +ifeq ($(GOOS),windows) +ifeq ($(MSYSTEM),MSYS) + cp hkexsh/hkexsh.exe $(INSTPREFIX)/bin/.hkexsh.exe + cp hkexsh/hkexsh.exe $(INSTPREFIX)/bin/.hkexcp.exe + cp hkexsh/mintty_wrapper.sh $(INSTPREFIX)/bin/hkexsh.exe + cp hkexsh/mintty_wrapper.sh $(INSTPREFIX)/bin/hkexcp.exe else - mv $(INSTPREFIX)/bin/hkexsh $(INSTPREFIX)/bin/_hkexsh - cp hkexsh/mintty_wrapper.sh $(INSTPREFIX)/bin/hkexsh - echo "Cross-build of hkexshd server for Windows not yet supported" + @echo "(GOOS=windows, MSYSTEM=?):unsupported install config." endif else - echo "Cross-build of hkexshd server for Windows not yet supported" -endif + cp hkexsh/hkexsh $(INSTPREFIX)/bin/hkexsh + cp hkexshd/hkexshd hkexpasswd/hkexpasswd $(INSTPREFIX)/$(SBIN) cd $(INSTPREFIX)/bin && ln -s hkexsh hkexcp && cd - +endif uninstall: - rm -f $(INSTPREFIX)/bin/hkexsh $(INSTPREFIX)/bin/hkexcp $(INSTPREFIX)/bin/_hkexsh -ifeq ($(MSYSTEM),) -ifneq ($(GOOS),windows) - rm -f $(INSTPREFIX)/sbin/hkexshd $(INSTPREFIX)/sbin/hkexpasswd -else -endif -else -endif + rm -f $(INSTPREFIX)/bin/hkexsh* $(INSTPREFIX)/bin/hkexcp* $(INSTPREFIX)/bin/.hkexsh* + rm -f $(INSTPREFIX)/$(SBIN)/hkexshd* $(INSTPREFIX)/$(SBIN)/hkexpasswd* diff --git a/hkexsh/mintty_wrapper.sh b/hkexsh/mintty_wrapper.sh index cef7de8..9695346 100755 --- a/hkexsh/mintty_wrapper.sh +++ b/hkexsh/mintty_wrapper.sh @@ -28,10 +28,12 @@ cleanup() { stty sane } +me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" + if [ ${1}x == "-hx" ]; then - ./hkexsh -h + ."$me".exe -h else stty -echo raw icrnl - ./hkexsh $@ + ."$me".exe $@ fi