diff options
Diffstat (limited to 'auto/modules/nodejs')
-rw-r--r-- | auto/modules/nodejs | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/auto/modules/nodejs b/auto/modules/nodejs index 56f84876..443ee9d5 100644 --- a/auto/modules/nodejs +++ b/auto/modules/nodejs @@ -15,13 +15,15 @@ for nxt_option; do --node=*) NXT_NODE="$value" ;; --npm=*) NXT_NPM="$value" ;; --node-gyp=*) NXT_NODE_GYP="$value" ;; + --local=*) NXT_NODE_LOCAL="$value" ;; --help) cat << END - --node=NAME set node executable - --npm=NAME set npm executable - --node-gyp=NAME set node-gyp executable + --node=FILE set node executable + --npm=FILE set npm executable + --node-gyp=FILE set node-gyp executable + --local=DIRECTORY set directory path for local installation END exit 0 @@ -49,12 +51,14 @@ fi . $NXT_AUTOCONF_DATA -$echo "configuring nodejs module" -$echo "configuring nodejs module..." >> $NXT_AUTOCONF_ERR - NXT_NODE=${NXT_NODE=node} NXT_NPM=${NXT_NPM=npm} NXT_NODE_GYP=${NXT_NODE_GYP=node-gyp} +NXT_NODE_LOCAL=${NXT_NODE_LOCAL=} + + +$echo "configuring nodejs module" +$echo "configuring nodejs module..." >> $NXT_AUTOCONF_ERR $echo -n "checking for node ..." $echo "checking for node ..." >> $NXT_AUTOCONF_ERR @@ -73,6 +77,7 @@ else exit 1; fi + $echo -n "checking for npm ..." $echo "checking for npm ..." >> $NXT_AUTOCONF_ERR @@ -90,6 +95,7 @@ else exit 1; fi + $echo -n "checking for node-gyp ..." $echo "checking for node-gyp ..." >> $NXT_AUTOCONF_ERR @@ -114,19 +120,29 @@ if grep ^$NXT_NODE: $NXT_MAKEFILE 2>&1 > /dev/null; then exit 1; fi + NXT_NODE_TMP=${NXT_BUILD_DIR}/src/${NXT_NODE}/unit-http NXT_NODE_TARBALL=${NXT_BUILD_DIR}/${NXT_NODE}-unit-http.tar.gz NXT_NODE_EXPORTS="export UNIT_SRC_PATH=${PWD}/src && \ export UNIT_LIB_STATIC_PATH=${PWD}/${NXT_BUILD_DIR}/libunit.a" +if [ -n "$NXT_NODE_LOCAL" ]; then + NXT_NODE_INSTALL=local-install +else + NXT_NODE_INSTALL=install +fi + cat << END >> $NXT_MAKEFILE .PHONY: ${NXT_NODE} .PHONY: ${NXT_NODE}-copy .PHONY: ${NXT_NODE}-install .PHONY: ${NXT_NODE}-uninstall +.PHONY: ${NXT_NODE}-local-check +.PHONY: ${NXT_NODE}-local-install +.PHONY: ${NXT_NODE}-build +.PHONY: ${NXT_NODE}-publish -all: ${NXT_NODE}: ${NXT_NODE}-copy $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC ${NXT_NODE_EXPORTS} && \\ @@ -139,23 +155,37 @@ ${NXT_NODE}-copy: ${NXT_NODE_TARBALL}: ${NXT_NODE}-copy tar -zcvf ${NXT_NODE_TARBALL} -C ${NXT_NODE_TMP} . + +install: ${NXT_NODE}-$NXT_NODE_INSTALL + ${NXT_NODE}-install: ${NXT_NODE_TARBALL} \ $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC ${NXT_NODE_EXPORTS} && \\ - ${NXT_NPM} install -g ${PWD}/${NXT_NODE_TARBALL} --unsafe-perm=true + ${NXT_NPM} install -g ${PWD}/${NXT_NODE_TARBALL} + +${NXT_NODE}-uninstall: + ${NXT_NPM} uninstall -g unit-http -${NXT_NODE}-local-install: ${NXT_NODE_TARBALL} \ +${NXT_NODE}-local-check: + @test -n "\$(DESTDIR)$NXT_NODE_LOCAL" \\ + || (echo; \\ + echo "error: to make ${NXT_NODE}-local-install you need either"; \\ + echo " to configure --local option"; \\ + echo " or to set DESTDIR environment variable."; \\ + echo; \\ + exit 1) + +${NXT_NODE}-local-install: ${NXT_NODE_TARBALL} ${NXT_NODE}-local-check \ $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC ${NXT_NODE_EXPORTS} && \\ - mkdir -p \$(DESTDIR) && \\ - cd \$(DESTDIR) && ${NXT_NPM} install ${PWD}/${NXT_NODE_TARBALL} + mkdir -p \$(DESTDIR)${NXT_NODE_LOCAL} && \\ + cd \$(DESTDIR)${NXT_NODE_LOCAL} && \\ + ${NXT_NPM} install ${PWD}/${NXT_NODE_TARBALL} + ${NXT_NODE}-build: ${NXT_NODE} ${NXT_NODE}-publish: ${NXT_NODE} cd ${NXT_NODE_TMP} && ${NXT_NPM} publish -${NXT_NODE}-uninstall: - ${NXT_NPM} uninstall -g unit-http - END |