TOKEN = $(wildcard ~/token) ifeq (,${TOKEN}) TOKEN = $(wildcard token) endif ifeq (bib,$(firstword $(MAKECMDGOALS))) # use the rest as arguments for "bib" SEARCH_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) # ...and turn them into do-nothing targets $(eval $(SEARCH_ARGS):;@:) endif all: biblio echo "run" latexmk -latexoption="-file-line-error -shell-escape -interaction=errorstopmode -halt-on-error -synctex=1" -g -pdf main.tex clean: latexmk -C biblio: -CHECK_DEP=${CHECK_DEP} python3 bibtool.py --tokenfile=${TOKEN} --server https://bib.gruss.cc get --exclude_sub_dirs bib: python3 bibtool.py --tokenfile=${TOKEN} --server https://bib.gruss.cc --exclude_sub_dirs --query "$(SEARCH_ARGS)" search