diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-03-31 20:40:12 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-04-07 03:21:18 +0300 |
commit | 70c40254fd7f5878a0d66e7444822e8350def432 (patch) | |
tree | f529737098fddee6e3ee0e46754e9b5d528f0812 /Makefile | |
parent | README: update (diff) | |
download | jekyll-docker-70c40254fd7f5878a0d66e7444822e8350def432.tar.gz jekyll-docker-70c40254fd7f5878a0d66e7444822e8350def432.zip |
Makefile: best practices
Diffstat (limited to '')
-rw-r--r-- | Makefile | 39 |
1 files changed, 34 insertions, 5 deletions
@@ -1,15 +1,33 @@ -SHELL := bash -.SHELLFLAGS := -e -o pipefail -c -.DEFAULT_GOAL := jekyll/serve +MAKEFLAGS := --no-builtin-rules --no-builtin-variables --warn-undefined-variables +unexport MAKEFLAGS +.DEFAULT_GOAL := all .DELETE_ON_ERROR: .SUFFIXES: +SHELL := bash +# Careful, -eu doesn't work with chruby, I think. +.SHELLFLAGS := -e -o pipefail -c + +.PHONY: DO +DO: + +escape = $(subst ','\'',$(1)) + +define noexpand +ifeq ($$(origin $(1)),environment) + $(1) := $$(value $(1)) +endif +ifeq ($$(origin $(1)),environment override) + $(1) := $$(value $(1)) +endif +ifeq ($$(origin $(1)),command line) + override $(1) := $$(value $(1)) +endif +endef empty := space := $(empty) $(empty) comma := , -escape = $(subst ','\'',$(1)) - makefile_dir := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) # Jekyll project is in the parent directory by default. @@ -19,6 +37,12 @@ RUBY_VERSION ?= 2.6.5 CHRUBY_VERSION ?= 0.3.9 PREFIX ?= $(HOME)/.local +$(eval $(call noexpand,PROJECT_DIR)) +$(eval $(call noexpand,RUBY_INSTALL_VERSION)) +$(eval $(call noexpand,RUBY_VERSION)) +$(eval $(call noexpand,CHRUBY_VERSION)) +$(eval $(call noexpand,PREFIX)) + ruby_install_url := https://github.com/postmodern/ruby-install/archive/v$(RUBY_INSTALL_VERSION).tar.gz ruby_install_archive := $(makefile_dir)/ruby-install-$(RUBY_INSTALL_VERSION).tar.gz ruby_install_dir := $(makefile_dir)/ruby-install-$(RUBY_INSTALL_VERSION) @@ -30,6 +54,9 @@ chruby_dir := $(makefile_dir)/chruby-$(CHRUBY_VERSION) chruby_sh := $(PREFIX)/share/chruby/chruby.sh auto_sh := $(PREFIX)/share/chruby/auto.sh +.PHONY: all +all: jekyll/serve + .PHONY: ruby-install ruby-install: wget -O '$(call escape,$(ruby_install_archive))' '$(call escape,$(ruby_install_url))' @@ -122,6 +149,8 @@ jekyll/serve: JEKYLL_UID ?= $(shell id -u) JEKYLL_GID ?= $(shell id -g) +$(eval $(call noexpand,JEKYLL_UID)) +$(eval $(call noexpand,JEKYLL_GID)) export JEKYLL_UID JEKYLL_GID docker_compose := cd -- '$(call escape,$(makefile_dir))' && PROJECT_DIR='$(call escape,$(abspath $(PROJECT_DIR)))' docker-compose |