From 933c2ff9d2b96eae3d62a0949488b6d1171d5fd9 Mon Sep 17 00:00:00 2001 From: Artem Yelizarov <52959979+artem-y@users.noreply.github.com> Date: Sun, 5 Jan 2025 10:14:52 +0200 Subject: [PATCH 1/6] Improve make install --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d5b2497..6d11d5d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ .PHONY: install install: - swift build -q -c release - install .build/release/hexcode /usr/local/bin/hexcode - + @INSTALLATION_PATH=$$(which hexcode) ; \ + if [ -z "$${INSTALLATION_PATH}" ]; then \ + INSTALLATION_PATH=/usr/local/bin/hexcode ; \ + fi && \ + swift build -q -c release ; \ + install .build/release/hexcode "$${INSTALLATION_PATH}" ; \ + echo "Installed at $${INSTALLATION_PATH}" From fad325ac6022e337e3cb7fa34d8a5fc9f8dfee2f Mon Sep 17 00:00:00 2001 From: Artem Yelizarov <52959979+artem-y@users.noreply.github.com> Date: Sun, 5 Jan 2025 12:14:24 +0200 Subject: [PATCH 2/6] Prevent next steps if build or installation failed --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6d11d5d..5e715e0 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,6 @@ install: if [ -z "$${INSTALLATION_PATH}" ]; then \ INSTALLATION_PATH=/usr/local/bin/hexcode ; \ fi && \ - swift build -q -c release ; \ - install .build/release/hexcode "$${INSTALLATION_PATH}" ; \ + swift build -q -c release && \ + install .build/release/hexcode "$${INSTALLATION_PATH}" && \ echo "Installed at $${INSTALLATION_PATH}" From a74f145c49f902d825004f9b68d0104550bfd017 Mon Sep 17 00:00:00 2001 From: Artem Yelizarov <52959979+artem-y@users.noreply.github.com> Date: Sun, 5 Jan 2025 12:19:36 +0200 Subject: [PATCH 3/6] Enable custom installation path --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e715e0..ffe5549 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: install install: - @INSTALLATION_PATH=$$(which hexcode) ; \ + @INSTALLATION_PATH=$(if $(filter install, $(MAKECMDGOALS)), $(word 2, $(MAKECMDGOALS)), $(which hexcode)) ; \ if [ -z "$${INSTALLATION_PATH}" ]; then \ INSTALLATION_PATH=/usr/local/bin/hexcode ; \ fi && \ From a2ef85162f21234d91995423f932f06b847d9d88 Mon Sep 17 00:00:00 2001 From: Artem Yelizarov <52959979+artem-y@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:06:11 +0200 Subject: [PATCH 4/6] Add clean and uninstall --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index ffe5549..2445b97 100644 --- a/Makefile +++ b/Makefile @@ -7,3 +7,11 @@ install: swift build -q -c release && \ install .build/release/hexcode "$${INSTALLATION_PATH}" && \ echo "Installed at $${INSTALLATION_PATH}" + +.PHONY: uninstall +uninstall: + @rm $$(which hexcode) + +.PHONY: clean +clean: + @rm -rf .build \ No newline at end of file From ce1bc26714d44c7710dd6a021864a2b57a30267d Mon Sep 17 00:00:00 2001 From: Artem Yelizarov <52959979+artem-y@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:28:08 +0200 Subject: [PATCH 5/6] Mention updated make install command in README --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2204b8..77652ed 100644 --- a/README.md +++ b/README.md @@ -67,10 +67,15 @@ Or you can just run it as an executable Swift package [without installation](#ru ### Using make: From the root of the repository, run the following command: ``` -sudo make install +make install ``` -If you want to install it into a directory other than default `/usr/local/bin`, replace it in the `Makefile` with your target directory. -Just make sure it's added to the PATH. +With no in stallation path provided, it will try to install `hexcode` to where it's already installed. If this is the first-time installation, the default path is `/usr/local/bin`. + +There's also an option to provide a custom installation path: +``` +make install +``` +Just make sure it's added to the PATH or sourced if you want the command to be visible from anywhere without typing the full path to it. Depending on the installation path and current user, `make install` command might need `sudo` access. ### Running without installation: From the `hexcode` directory (or passing it as `--package-path`), the command can be run as executable package without previous installation, for example: ``` From e276689024742d897df314bdcb7ffd2196ababbd Mon Sep 17 00:00:00 2001 From: Artem Yelizarov <52959979+artem-y@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:32:30 +0200 Subject: [PATCH 6/6] Fix typo in README installation description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77652ed..abda727 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ From the root of the repository, run the following command: ``` make install ``` -With no in stallation path provided, it will try to install `hexcode` to where it's already installed. If this is the first-time installation, the default path is `/usr/local/bin`. +With no installation path provided, it will try to install `hexcode` to where it's already installed. If this is the first-time installation, the default path is `/usr/local/bin`. There's also an option to provide a custom installation path: ```