Skip to content

Instantly share code, notes, and snippets.

Created January 10, 2014 16:15
What would you like to do?
Use GNU autotools to call node-gyp to build a native node module
# If
# (1) Your project is built using the GNU autotools.
# (2) Your project depends on a native node.js module which it ships with
# (3) You find autotools hard
# Then you might find this gist useful for building your node module alongside your main project during ./configure and make
# Simpler than it sounds. :)
# Check for node and node-gyp
AC_CHECK_PROG(HAVE_NODE, [node], [node])
AC_CHECK_PROG(HAVE_NODE_GYP, [node-gyp], [node-gyp])
test -z "$HAVE_NODE" && AC_MSG_ERROR([Could not find node.js. Please make sure you have it installed])
test -z "$HAVE_NODE_GYP" && AC_MSG_ERROR([Could not find node_gyp. Please make sure you have it installed])
# Run node-gyp configure during ./configure
(cd $(NODE_MODULE_DIR) && node-gyp configure)
bin_PROGRAMS = some_node_module
-cd $(NODE_MODULE_DIR) && node-gyp build
-cd $(NODE_MODULE_DIR) && node-gyp clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment