diff --git a/Makefile b/Makefile index 93f51a6ae7e5e6..d67e89a2771035 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ EXEEXT := $(shell $(PYTHON) -c \ NODE_EXE = node$(EXEEXT) NODE ?= ./$(NODE_EXE) NODE_G_EXE = node_g$(EXEEXT) +NPM ?= ./deps/npm/bin/npm-cli.js # Flags for packaging. BUILD_DOWNLOAD_FLAGS ?= --download=all @@ -286,11 +287,25 @@ out/doc/%: doc/% # check if ./node is actually set, else use user pre-installed binary gen-json = tools/doc/generate.js --format=json $< > $@ out/doc/api/%.json: doc/api/%.md + [ -e tools/doc/node_modules/js-yaml/package.json ] || \ + [ -e tools/eslint/node_modules/js-yaml/package.json ] || \ + if [ -x $(NODE) ]; then \ + cd tools/doc && ../../$(NODE) ../../$(NPM) install; \ + else \ + cd tools/doc && node ../../$(NPM) install; \ + fi [ -x $(NODE) ] && $(NODE) $(gen-json) || node $(gen-json) # check if ./node is actually set, else use user pre-installed binary gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html --template=doc/template.html $< > $@ out/doc/api/%.html: doc/api/%.md + [ -e tools/doc/node_modules/js-yaml/package.json ] || \ + [ -e tools/eslint/node_modules/js-yaml/package.json ] || \ + if [ -x $(NODE) ]; then \ + cd tools/doc && ../../$(NODE) ../../$(NPM) install; \ + else \ + cd tools/doc && node ../../$(NPM) install; \ + fi [ -x $(NODE) ] && $(NODE) $(gen-html) || node $(gen-html) docopen: out/doc/api/all.html