This will most probably be obvious and / or a banality. But since I am trying different approaches for hours without success...
I am on Linux Mint 19. I am entirely new to Makefiles. Excuse me, if the problem is trivial.
Let it be clear, that I care for the distrib
and SHA512SUMS
targets only in this question.
As I heavily change the code of those scripts, I would like the SHA512SUMS
file to be re-generated each time I run the distrib
target, but not in case I run the check
target, of course, that would make the check
target irrelevant, as you can see.
This Makefile is becoming to be a little complicated for a shell scripter. Any help will be appreciated.
PREFIX?=/usr/local/bin
install_path=$(DESTDIR)$(PREFIX)
encrypt_script=encrypt-file-aes256
decrypt_script=decrypt-file-aes256
distrib_name=openssl-file-encryption-decryption-shell-scripts
.PHONY: check install uninstall distrib
check: $(encrypt_script) $(decrypt_script) SHA512SUMS
echo && sha512sum --check --status SHA512SUMS && ( echo "Ok. You may use 'sudo make install' or '(sudo) make install PREFIX=SomeDir' command now." ) || ( echo "ERROR: Files hash sum mismatch!" && echo && exit 1 )
install: check
echo && [ -d $(install_path) ] || mkdir --parents $(install_path)
install --verbose --mode=0755 --target-directory=$(install_path) $(encrypt_script) $(decrypt_script)
uninstall:
rm $(install_path)/$(encrypt_script) $(install_path)/$(decrypt_script)
rmdir --ignore-fail-on-non-empty $(install_path)
distrib: check $(encrypt_script) $(decrypt_script) Makefile SHA512SUMS
if [ $$(id --user) -eq 0 ]; then ( echo && echo "Target 'distrib' has to be run as normal user!" && echo && exit 1 ) fi
rm --force $(distrib_name).tar.xz
rm --force $(distrib_name).tar.xz.asc
rm --force --recursive $(distrib_name)
mkdir $(distrib_name)
# sha512sum $(encrypt_script) $(decrypt_script) > $(distrib_name)/SHA512SUMS
cp $(encrypt_script) $(decrypt_script) Makefile SHA512SUMS $(distrib_name)
wget --quiet --output-document=$(distrib_name)/LICENSE https://git.io/fxByv # https://raw.githubusercontent.com/burianvlastimil/openssl-file-encryption-decryption-shell-scripts/master/LICENSE
wget --quiet --output-document=$(distrib_name)/README.md https://git.io/fxByJ # https://raw.githubusercontent.com/burianvlastimil/openssl-file-encryption-decryption-shell-scripts/master/README.md
chmod 755 $(distrib_name)/$(encrypt_script) $(distrib_name)/$(decrypt_script)
chmod 644 $(distrib_name)/Makefile $(distrib_name)/SHA512SUMS $(distrib_name)/LICENSE $(distrib_name)/README.md
tar --create --file=$(distrib_name).tar $(distrib_name)
xz --format=xz -9 --extreme --check=sha256 $(distrib_name).tar
rm --force --recursive $(distrib_name)
gpg --local-user 7D2E022E39A88ACF3EF6D4498F37AF4CE46008C3 --sign --armor --output $(distrib_name).tar.xz.asc --detach-sig $(distrib_name).tar.xz
SHA512SUMS:
sha512sum --check --status SHA512SUMS || sha512sum $(encrypt_script) $(decrypt_script) > SHA512SUMS