From 6a81fa5f6ea79f6837b646bffd25202e8e9d2117 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 26 Aug 2020 15:55:38 -0500 Subject: [PATCH] Makefile: address review suggestions --- Makefile | 73 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index b1e30637..339e8db3 100644 --- a/Makefile +++ b/Makefile @@ -9,16 +9,6 @@ DST=_site BUNDLE := $(shell which bundle 2>/dev/null) GEMFILES := $(wildcard Gemfile Gemfile.lock) -ifneq (, $(GEMFILES)) - ifneq (, $(BUNDLE)) - JEKYLL := bundle exec jekyll - else - JEKYLL := jekyll - endif -else - JEKYLL := jekyll -endif - # Check Python 3 is installed and determine if it's called via python3 or python # (https://stackoverflow.com/a/4933395) PYTHON3_EXE := $(shell which python3 2>/dev/null) @@ -53,12 +43,12 @@ endif ## ================================================= ## * serve : render website and run a local server -serve : lesson-md - ${JEKYLL} serve +serve : lesson-md .vendor/bundle index.md reference.md setup.md + @bundle exec jekyll serve ## * site : build website but do not run a server -site : lesson-md - ${JEKYLL} build +site : lesson-md .vendor/bundle index.md reference.md setup.md + @bundle exec jekyll build ## * docker-serve : use Docker to serve the site docker-serve : @@ -173,37 +163,68 @@ lesson-fixme : ## IV. Auxililary (plumbing) commands ## ================================================= -.PHONY : commands bundle +.PHONY : commands bundle update-bundle ## * commands : show all commands commands : @sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST) -## * bundle : install Ruby gems specified in Gemfile / Gemfile.lock +## * bundle : install Ruby gems (required for building lesson website locally) bundle : .vendor/bundle @: -.vendor/bundle: Gemfile Gemfile.lock +.vendor/bundle: Gemfile.lock ifeq (, $(BUNDLE)) - @echo "Please install Bundler using 'gem install bundler'" -else ifeq (, $(GEMFILES)) - @echo Can not create bundle: neither Gemfile nor Gemfile.lock have been found. + $(error Please install Bundler using 'gem install bundler') else @bundle config set --local path '.vendor/bundle' @bundle install - @bundle update --quiet github-pages @touch .vendor/bundle endif -# Gemfile target below does nothing. This is intentional. +## * update-bundle : update Ruby gems (required for building lesson website locally) +update-bundle : Gemfile.lock +ifeq (, $(BUNDLE)) + $(error Please install Bundler using 'gem install bundler') +else + @bundle config set --local path '.vendor/bundle' + @bundle update github-pages + @touch .vendor/bundle +endif + Gemfile: +ifeq (, $(wildcard Gemfile)) + $(error Gemfile not found!) +else @: +endif Gemfile.lock: Gemfile ifeq (, $(BUNDLE)) - @echo "Please install Bundler using 'gem install bundler'" -else ifeq (, $(wildcard Gemfile)) - @echo Gemfile not found! -else + $(error Please install Bundler using 'gem install bundler') +else ifeq (, $(wildcard Gemfile.lock)) @bundle lock +else + @: +endif + +index.md : +ifeq (, $(wildcard index.md)) + $(error index.md not found) +else + @: +endif + +setup.md : +ifeq (, $(wildcard setup.md)) + $(error setup.md not found) +else + @: +endif + +reference.md : +ifeq (, $(wildcard reference.md)) + $(error reference.md not found) +else + @: endif