Skip to content

Instantly share code, notes, and snippets.

@ThomasThoren
Last active March 9, 2019 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasThoren/88e568a3da3ef9b0efc1b3a6be4e66ef to your computer and use it in GitHub Desktop.
Save ThomasThoren/88e568a3da3ef9b0efc1b3a6be4e66ef to your computer and use it in GitHub Desktop.
Make

Make

Arguments

Parallel processes.

-j 2
--jobs=2

Variables

$< -- first prerequisite file $^ -- all prerequisite files $@ -- target file $% -- target name ("file" in "file.json")

$(@D) -- target directory $(dir $@) -- target directory $(notdir $@) -- target file name ("file.json" in "/home/user/file.json")

Check if in virtual environment

check_virtualenv:
    @if [ -z $(VIRTUAL_ENV) ]; then \
            echo 'Not in virtual environment. Continuing...'; \
	else \
	    echo 'In virtual environment. Halting.'; \
	    exit 1; \
	fi

Resources

# Default Makefile
# Save as ~/.Makefile or similar and use as starting point for new Makefiles.
PROJECT_DIR=`pwd`
# Keep intermediate files
.SECONDARY:
.PHONY: help
.DEFAULT_GOAL := help
help: ## Prints help list for targets.
@# Source: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
cleanup: ## Removes any temporary files.
@rm -rf tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment