diff --git a/config b/config index 1f6905d731..28b40781c0 100644 --- a/config +++ b/config @@ -12,29 +12,31 @@ ngx_lua_opt_I= ngx_lua_opt_L= if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then - # explicitly set Lua lib path - ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env)" + # explicitly set LuaJIT paths + + # attempt to link with -ldl, static linking on Linux requires it. + ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl)" ngx_feature_path="$LUAJIT_INC" ngx_lua_opt_I="-I$LUAJIT_INC" ngx_lua_opt_L="-L$LUAJIT_LIB" if [ $NGX_RPATH = YES ]; then - ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm" + ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm -ldl" else - ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm" + ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm -ldl" fi . auto/feature if [ $ngx_found = no ]; then - # retry with -ldl, static linking on Linux requires it. - ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl)" + # retry without -ldl + ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env)" ngx_feature_path="$LUAJIT_INC" ngx_lua_opt_I="-I$LUAJIT_INC" ngx_lua_opt_L="-L$LUAJIT_LIB" if [ $NGX_RPATH = YES ]; then - ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm -ldl" + ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm" else - ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm -ldl" + ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm" fi . auto/feature @@ -65,19 +67,34 @@ END esac else if [ -n "$LUA_INC" -o -n "$LUA_LIB" ]; then - # explicitly set Lua lib path + # explicitly set Lua paths ngx_feature="Lua library in $LUA_LIB and $LUA_INC (specified by the LUA_LIB and LUA_INC env)" ngx_feature_path="$LUA_INC" ngx_lua_opt_I="-I$LUA_INC" ngx_lua_opt_L="-L$LUA_LIB" if [ $NGX_RPATH = YES ]; then - ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm" + ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm -ldl" else - ngx_feature_libs="$ngx_lua_opt_L -llua -lm" + ngx_feature_libs="$ngx_lua_opt_L -llua -lm -ldl" fi . auto/feature + if [ $ngx_found = no ]; then + # retry without -ldl + + ngx_feature_path="$LUA_INC" + ngx_lua_opt_I="-I$LUA_INC" + ngx_lua_opt_L="-L$LUA_LIB" + if [ $NGX_RPATH = YES ]; then + ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm" + else + ngx_feature_libs="$ngx_lua_opt_L -llua -lm" + fi + + . auto/feature + fi + if [ $ngx_found = no ]; then cat << END $0: error: ngx_http_lua_module requires the Lua or LuaJIT library and LUA_LIB is defined as $LUA_LIB and LUA_INC (path for lua.h) is $LUA_INC, but we cannot find standard Lua there. @@ -175,25 +192,25 @@ END fi if [ $ngx_found = no ]; then - # Gentoo with LuaJIT-2.0 + # Gentoo with LuaJIT-2.0, try with -ldl ngx_feature="LuaJIT library in /usr/" ngx_feature_path="/usr/include/luajit-2.0" if [ $NGX_RPATH = YES ]; then - ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1" + ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl" else - ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1" + ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1 -ldl" fi . auto/feature fi if [ $ngx_found = no ]; then - # Gentoo with LuaJIT-2.0, retry with -ldl + # Gentoo with LuaJIT 2.0 ngx_feature="LuaJIT library in /usr/" ngx_feature_path="/usr/include/luajit-2.0" if [ $NGX_RPATH = YES ]; then - ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl" + ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1" else - ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1 -ldl" + ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1" fi . auto/feature fi