2018-10-03 14:50:03 +00:00
|
|
|
|
|
|
|
# Copyright (C) NGINX, Inc.
|
|
|
|
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
for nxt_option; do
|
|
|
|
|
|
|
|
case "$nxt_option" in
|
|
|
|
-*=*) value=`echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
|
|
|
|
*) value="" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$nxt_option" in
|
|
|
|
--node=*) NXT_NODE="$value" ;;
|
|
|
|
--npm=*) NXT_NPM="$value" ;;
|
|
|
|
--node-gyp=*) NXT_NODE_GYP="$value" ;;
|
2018-11-14 17:12:47 +00:00
|
|
|
--local=*) NXT_NODE_LOCAL="$value" ;;
|
2018-10-03 14:50:03 +00:00
|
|
|
|
|
|
|
--help)
|
|
|
|
cat << END
|
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
--node=FILE set node executable
|
|
|
|
--npm=FILE set npm executable
|
|
|
|
--node-gyp=FILE set node-gyp executable
|
2018-11-14 17:12:47 +00:00
|
|
|
--local=DIRECTORY set directory path for local installation
|
2018-10-03 14:50:03 +00:00
|
|
|
|
|
|
|
END
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo
|
|
|
|
echo $0: error: invalid Node option \"$nxt_option\"
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f $NXT_AUTOCONF_DATA ]; then
|
|
|
|
echo
|
|
|
|
echo Please run common $0 before configuring module \"$nxt_module\".
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
. $NXT_AUTOCONF_DATA
|
|
|
|
|
|
|
|
|
|
|
|
NXT_NODE=${NXT_NODE=node}
|
|
|
|
NXT_NPM=${NXT_NPM=npm}
|
|
|
|
NXT_NODE_GYP=${NXT_NODE_GYP=node-gyp}
|
2018-11-14 17:12:47 +00:00
|
|
|
NXT_NODE_LOCAL=${NXT_NODE_LOCAL=}
|
2018-10-03 14:50:03 +00:00
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
|
|
|
|
$echo "configuring nodejs module"
|
|
|
|
$echo "configuring nodejs module..." >> $NXT_AUTOCONF_ERR
|
|
|
|
|
2018-10-03 14:50:03 +00:00
|
|
|
$echo -n "checking for node ..."
|
|
|
|
$echo "checking for node ..." >> $NXT_AUTOCONF_ERR
|
|
|
|
|
|
|
|
if /bin/sh -c "${NXT_NODE} -v" >> $NXT_AUTOCONF_ERR 2>&1; then
|
|
|
|
$echo " found"
|
|
|
|
|
|
|
|
NXT_NODE_VERSION="`${NXT_NODE} -v`"
|
|
|
|
$echo " + node version ${NXT_NODE_VERSION}"
|
|
|
|
|
|
|
|
else
|
|
|
|
$echo " not found"
|
|
|
|
$echo
|
|
|
|
$echo $0: error: no Node found.
|
|
|
|
$echo
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
|
2018-10-03 14:50:03 +00:00
|
|
|
$echo -n "checking for npm ..."
|
|
|
|
$echo "checking for npm ..." >> $NXT_AUTOCONF_ERR
|
|
|
|
|
|
|
|
if /bin/sh -c "${NXT_NPM} -v" >> $NXT_AUTOCONF_ERR 2>&1; then
|
|
|
|
$echo " found"
|
|
|
|
|
|
|
|
NXT_NPM_VERSION="`${NXT_NPM} -v`"
|
|
|
|
$echo " + npm version ${NXT_NPM_VERSION}"
|
|
|
|
|
|
|
|
else
|
|
|
|
$echo " not found"
|
|
|
|
$echo
|
|
|
|
$echo $0: error: no npm found.
|
|
|
|
$echo
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
|
2018-10-03 14:50:03 +00:00
|
|
|
$echo -n "checking for node-gyp ..."
|
|
|
|
$echo "checking for node-gyp ..." >> $NXT_AUTOCONF_ERR
|
|
|
|
|
|
|
|
if /bin/sh -c "${NXT_NODE_GYP} -v" >> $NXT_AUTOCONF_ERR 2>&1; then
|
|
|
|
$echo " found"
|
|
|
|
|
|
|
|
NXT_NODE_GYP_VERSION="`${NXT_NODE_GYP} -v`"
|
|
|
|
$echo " + node-gyp version ${NXT_NODE_GYP_VERSION}"
|
|
|
|
|
|
|
|
else
|
|
|
|
$echo " not found"
|
|
|
|
$echo
|
|
|
|
$echo $0: error: no node-gyp found.
|
|
|
|
$echo
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep ^$NXT_NODE: $NXT_MAKEFILE 2>&1 > /dev/null; then
|
|
|
|
$echo
|
|
|
|
$echo $0: error: duplicate \"$NXT_NODE\" package configured.
|
|
|
|
$echo
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
|
2018-10-03 14:50:03 +00:00
|
|
|
NXT_NODE_TMP=${NXT_BUILD_DIR}/src/${NXT_NODE}/unit-http
|
2021-03-25 13:09:24 +00:00
|
|
|
NXT_NODE_TMP_G=${NXT_BUILD_DIR}/src/${NXT_NODE}/unit-http-g
|
2023-11-07 19:38:28 +00:00
|
|
|
NXT_NODE_TARBALL=${NXT_BUILD_DIR}/src/${NXT_NODE}-unit-http.tar.gz
|
|
|
|
NXT_NODE_TARBALL_G=${NXT_BUILD_DIR}/src/${NXT_NODE}-unit-http-g.tar.gz
|
2021-03-25 13:09:24 +00:00
|
|
|
NXT_NODE_VERSION_FILE=${NXT_BUILD_DIR}/src/${NXT_NODE}/version.h
|
|
|
|
NXT_NODE_PACKAGE_FILE=${NXT_BUILD_DIR}/src/${NXT_NODE}/package.json
|
2018-12-19 12:56:54 +00:00
|
|
|
NXT_NODE_EXPORTS="export UNIT_SRC_PATH=${PWD}/src \
|
|
|
|
&& export UNIT_BUILD_PATH=${PWD}/${NXT_BUILD_DIR} \
|
Auto: mirroring installation structure in build tree.
This makes the build tree more organized, which is good for adding new
stuff. Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.
Previously, the build tree was quite flat, and looked like this (after
`./configure && make`):
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── echo
├── libnxt.a
├── nxt_auto_config.h
├── nxt_version.h
├── unitd
└── unitd.8
1 directory, 9 files
And after this patch, it looks like this:
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── bin
│ └── echo
├── include
│ ├── nxt_auto_config.h
│ └── nxt_version.h
├── lib
│ ├── libnxt.a
│ └── unit
│ └── modules
├── sbin
│ └── unitd
├── share
│ └── man
│ └── man8
│ └── unitd.8
└── var
├── lib
│ └── unit
├── log
│ └── unit
└── run
└── unit
17 directories, 9 files
It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames."). Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`). Now, since it expects files in a very specific
location, that has been broken. By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:
$ ./configure --prefix=./build
$ make
$ ./build/sbin/unitd
Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly <liam@nginx.com>
Reviewed-by: Konstantin Pavlov <thresh@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Cc: Andrei Zeliankou <zelenkov@nginx.com>
Cc: Zhidao Hong <z.hong@f5.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2023-03-22 15:55:02 +00:00
|
|
|
&& export UNIT_LIB_STATIC_PATH=${PWD}/${NXT_BUILD_DIR}/lib/libunit.a"
|
2018-10-03 14:50:03 +00:00
|
|
|
|
2018-11-14 17:12:47 +00:00
|
|
|
if [ -n "$NXT_NODE_LOCAL" ]; then
|
|
|
|
NXT_NODE_INSTALL=local-install
|
|
|
|
else
|
|
|
|
NXT_NODE_INSTALL=install
|
|
|
|
fi
|
|
|
|
|
2018-10-03 14:50:03 +00:00
|
|
|
cat << END >> $NXT_MAKEFILE
|
|
|
|
|
|
|
|
.PHONY: ${NXT_NODE}
|
|
|
|
.PHONY: ${NXT_NODE}-copy
|
2021-03-25 13:09:24 +00:00
|
|
|
.PHONY: ${NXT_NODE}-copy-g
|
2018-10-03 14:50:03 +00:00
|
|
|
.PHONY: ${NXT_NODE}-install
|
|
|
|
.PHONY: ${NXT_NODE}-uninstall
|
2018-11-14 17:12:47 +00:00
|
|
|
.PHONY: ${NXT_NODE}-local-check
|
2018-11-14 17:01:34 +00:00
|
|
|
.PHONY: ${NXT_NODE}-local-install
|
|
|
|
.PHONY: ${NXT_NODE}-build
|
|
|
|
.PHONY: ${NXT_NODE}-publish
|
2018-10-03 14:50:03 +00:00
|
|
|
|
Auto: mirroring installation structure in build tree.
This makes the build tree more organized, which is good for adding new
stuff. Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.
Previously, the build tree was quite flat, and looked like this (after
`./configure && make`):
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── echo
├── libnxt.a
├── nxt_auto_config.h
├── nxt_version.h
├── unitd
└── unitd.8
1 directory, 9 files
And after this patch, it looks like this:
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── bin
│ └── echo
├── include
│ ├── nxt_auto_config.h
│ └── nxt_version.h
├── lib
│ ├── libnxt.a
│ └── unit
│ └── modules
├── sbin
│ └── unitd
├── share
│ └── man
│ └── man8
│ └── unitd.8
└── var
├── lib
│ └── unit
├── log
│ └── unit
└── run
└── unit
17 directories, 9 files
It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames."). Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`). Now, since it expects files in a very specific
location, that has been broken. By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:
$ ./configure --prefix=./build
$ make
$ ./build/sbin/unitd
Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly <liam@nginx.com>
Reviewed-by: Konstantin Pavlov <thresh@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Cc: Andrei Zeliankou <zelenkov@nginx.com>
Cc: Zhidao Hong <z.hong@f5.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2023-03-22 15:55:02 +00:00
|
|
|
${NXT_NODE}: ${NXT_NODE}-copy $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
|
2018-10-03 14:50:03 +00:00
|
|
|
${NXT_NODE_EXPORTS} && \\
|
|
|
|
cd ${NXT_NODE_TMP} && ${NXT_NODE_GYP} configure build clean
|
|
|
|
|
2021-03-25 13:09:24 +00:00
|
|
|
${NXT_NODE}-copy: ${NXT_NODE_VERSION_FILE} ${NXT_NODE_PACKAGE_FILE}
|
|
|
|
mkdir -p ${NXT_NODE_TMP}
|
|
|
|
cp -rp src/nodejs/unit-http/* ${NXT_NODE_TMP}/
|
|
|
|
cp -p ${NXT_NODE_VERSION_FILE} ${NXT_NODE_PACKAGE_FILE} ${NXT_NODE_TMP}/
|
2021-06-15 07:35:15 +00:00
|
|
|
rm -f ${NXT_NODE_TMP}/binding_pub.gyp
|
2021-03-25 13:09:24 +00:00
|
|
|
|
|
|
|
${NXT_NODE}-copy-g: ${NXT_NODE_VERSION_FILE} ${NXT_NODE_PACKAGE_FILE}
|
|
|
|
mkdir -p ${NXT_NODE_TMP_G}
|
|
|
|
cp -rp src/nodejs/unit-http/* ${NXT_NODE_TMP_G}/
|
|
|
|
cp -p ${NXT_NODE_VERSION_FILE} ${NXT_NODE_PACKAGE_FILE} ${NXT_NODE_TMP_G}/
|
|
|
|
mv ${NXT_NODE_TMP_G}/binding_pub.gyp ${NXT_NODE_TMP_G}/binding.gyp
|
2018-12-19 12:56:57 +00:00
|
|
|
|
2019-02-22 13:31:44 +00:00
|
|
|
${NXT_NODE_VERSION_FILE}: ${NXT_VERSION_H}
|
2021-03-25 13:09:24 +00:00
|
|
|
mkdir -p ${NXT_BUILD_DIR}/src/${NXT_NODE}
|
2019-02-22 13:31:44 +00:00
|
|
|
$echo '#define NXT_NODE_VERNUM \$(NXT_VERNUM)' > $NXT_NODE_VERSION_FILE
|
2018-10-03 14:50:03 +00:00
|
|
|
|
2021-03-25 13:09:24 +00:00
|
|
|
${NXT_NODE_PACKAGE_FILE}: ${NXT_VERSION_H} src/nodejs/unit-http/package.json
|
|
|
|
mkdir -p ${NXT_BUILD_DIR}/src/${NXT_NODE}
|
2021-03-25 13:15:03 +00:00
|
|
|
sed -e "s|%%VERSION%%|\$(NXT_VERSION)|" \
|
2021-03-25 13:09:24 +00:00
|
|
|
src/nodejs/unit-http/package.json > ${NXT_NODE_PACKAGE_FILE}
|
|
|
|
|
|
|
|
${NXT_NODE_TARBALL}: ${NXT_NODE}-copy
|
2021-06-15 07:35:15 +00:00
|
|
|
cd ${NXT_NODE_TMP} && npm pack
|
|
|
|
mv ${NXT_NODE_TMP}/unit-http-\$(NXT_VERSION).tgz ${NXT_NODE_TARBALL}
|
2018-10-03 14:50:03 +00:00
|
|
|
|
2021-03-25 13:09:24 +00:00
|
|
|
${NXT_NODE_TARBALL_G}: ${NXT_NODE}-copy-g
|
2021-06-15 07:35:15 +00:00
|
|
|
cd ${NXT_NODE_TMP_G} && npm pack
|
|
|
|
mv ${NXT_NODE_TMP_G}/unit-http-\$(NXT_VERSION).tgz ${NXT_NODE_TARBALL_G}
|
2021-03-25 13:09:24 +00:00
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
|
2018-11-14 17:12:47 +00:00
|
|
|
install: ${NXT_NODE}-$NXT_NODE_INSTALL
|
|
|
|
|
2021-03-25 13:09:24 +00:00
|
|
|
${NXT_NODE}-install: ${NXT_NODE_TARBALL_G} libunit-install
|
|
|
|
${NXT_NPM} install -g --unsafe-perm ${PWD}/${NXT_NODE_TARBALL_G}
|
2018-11-14 17:01:34 +00:00
|
|
|
|
|
|
|
${NXT_NODE}-uninstall:
|
|
|
|
${NXT_NPM} uninstall -g unit-http
|
2018-10-03 14:50:03 +00:00
|
|
|
|
2018-11-14 17:12:47 +00:00
|
|
|
${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 \
|
Auto: mirroring installation structure in build tree.
This makes the build tree more organized, which is good for adding new
stuff. Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.
Previously, the build tree was quite flat, and looked like this (after
`./configure && make`):
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── echo
├── libnxt.a
├── nxt_auto_config.h
├── nxt_version.h
├── unitd
└── unitd.8
1 directory, 9 files
And after this patch, it looks like this:
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── bin
│ └── echo
├── include
│ ├── nxt_auto_config.h
│ └── nxt_version.h
├── lib
│ ├── libnxt.a
│ └── unit
│ └── modules
├── sbin
│ └── unitd
├── share
│ └── man
│ └── man8
│ └── unitd.8
└── var
├── lib
│ └── unit
├── log
│ └── unit
└── run
└── unit
17 directories, 9 files
It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames."). Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`). Now, since it expects files in a very specific
location, that has been broken. By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:
$ ./configure --prefix=./build
$ make
$ ./build/sbin/unitd
Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly <liam@nginx.com>
Reviewed-by: Konstantin Pavlov <thresh@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Cc: Andrei Zeliankou <zelenkov@nginx.com>
Cc: Zhidao Hong <z.hong@f5.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2023-03-22 15:55:02 +00:00
|
|
|
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
|
2018-10-03 14:50:03 +00:00
|
|
|
${NXT_NODE_EXPORTS} && \\
|
2018-11-14 17:12:47 +00:00
|
|
|
mkdir -p \$(DESTDIR)${NXT_NODE_LOCAL} && \\
|
|
|
|
cd \$(DESTDIR)${NXT_NODE_LOCAL} && \\
|
|
|
|
${NXT_NPM} install ${PWD}/${NXT_NODE_TARBALL}
|
2018-10-03 14:50:03 +00:00
|
|
|
|
2018-11-14 17:01:34 +00:00
|
|
|
|
2018-10-03 14:50:03 +00:00
|
|
|
${NXT_NODE}-build: ${NXT_NODE}
|
|
|
|
|
|
|
|
${NXT_NODE}-publish: ${NXT_NODE}
|
|
|
|
cd ${NXT_NODE_TMP} && ${NXT_NPM} publish
|
|
|
|
|
|
|
|
END
|