52 lines
1.5 KiB
Makefile
52 lines
1.5 KiB
Makefile
# Sources of inspiration:
|
|
# https://makefiletutorial.com/
|
|
# https://code.larlet.fr/makefile/
|
|
# https://www.thapaliya.com/en/writings/well-documented-makefiles/
|
|
|
|
.DEFAULT_GOAL:=help
|
|
SHELL:=/bin/bash
|
|
|
|
# Get the output of the pandoc command
|
|
pandoc=$(shell command -v pandoc)
|
|
# Get the version of pandoc
|
|
pandoc_version=$(shell pandoc --version | sed -e 's/.* // ; 1q')
|
|
# Get the output of the awk command
|
|
awk=$(shell command -v awk)
|
|
|
|
# Get the datetime
|
|
now=$(shell date +%Y%m%d%H%M%S)
|
|
# Build the filename
|
|
filename=$(now).md
|
|
|
|
# Export date and id as environment variable to replace the variables in the
|
|
# template file
|
|
export date:=$(shell date +%Y-%m-%dT%H:%M:%S%:z)
|
|
export id:=$(now)
|
|
|
|
# Set the templates and notes directories
|
|
templates_directory=templates
|
|
notes_directory=notes
|
|
|
|
.PHONY: help deps
|
|
|
|
help: ## Display this help
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
|
|
|
|
deps: ## Check dependencies
|
|
$(info Checking and getting dependencies)
|
|
ifeq ($(strip ($pandoc)),)
|
|
@echo "pandoc is required and not installed"
|
|
else
|
|
@echo "pandoc" $(pandoc_version) "is installed"
|
|
endif
|
|
ifeq ($(strip ($awk)),)
|
|
@echo "awk is required and not installed"
|
|
else
|
|
@echo "awk is installed"
|
|
endif
|
|
|
|
new: ## Create a new file
|
|
$(info Creating a new file)
|
|
@ envsubst <$(templates_directory)/default.md >$(notes_directory)/$(filename)
|
|
$(info Your new file is $(notes_directory)/$(filename))
|