DEV Community

Discussion on: How To Make A Makefile

Collapse
 
djhi profile image
Gildas Garcia • Edited

Nice article, thanks :) We use this to auto document our makefiles (see marmelab.com/blog/2016/02/29/auto-...), I thought you might find it interesting:

help:
    @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

clean: ## Cleanup
        rm -rf $(BUILDDIR)/*.o $(BUILDDIR)/$(EXEC)

The help command show a list of all commands with associated help extracted from the comments (##)

Collapse
 
deciduously profile image
Ben Lovy • Edited

Aha! Very cool, thanks for sharing. Much better than hardcoding.