A Crude Attempt at GNU Make
Hello, I'm incompetent.
I'm working on something called cuckooget, and I've added support for installation via pip. However, it was a hassle to run the installation process every time during development, so I decided to try GNU Make this time.
I had an O'Reilly book on GNU Make and had read it, but I thought I wouldn't have a chance to use it since it was based on C/C++. But this time, I felt like it would be a good fit, so I incorporated it.
Makefile
This is what it looks like.
$ cat Makefile
.PHONY: all check-deps build install clean done
WHEEL_DIR = lib/target/wheels
EGG_INFO = cuckooget.egg-info src/cuckooget.egg-info
all: check-deps build
check-deps:
@command -v pyenv >/dev/null || (echo "Please install pyenv" ; exit 1;)
@command -v python3 >/dev/null || (echo "Please install Python3" ; exit 1;)
@command -v maturin >/dev/null || ( echo "Please install maturin (pip install maturin)"; exit 1; )
build:
@echo "Building with maturin..."
cd lib && maturin build
install:
pip install . --force-reinstall
pip install $(WHEEL_DIR)/*.whl --force-reinstall
@echo "Done! How to use \`ck -h\`"
clean:
rm -rf build lib/target $(EGG_INFO)
done:
@echo "All steps completed."
Rust is built separately to be called as a Python library, but make only handles the Rust build.
Thanks to the addition of make clean, I can now delete junk instantly, which is quite convenient.
Anything else?
I'm thinking of introducing it to various other things later, but if you're messing around with a single project, consolidating everything into a Makefile makes it easy to see what can be executed, which I think is good. However, if you're only doing small things, it's probably not necessary.
That's all for now. Best regards.