1.在auto/make脚本里添加新的编译器和链接器:
#LINK = $LINK #原25行附近注释掉原链接器
CXX=g++ #新增C++编译器
CXXFLAGS=-std=c++0x -Wall #新增C++编译选项,启用C++11
LINK=g++ #新增C++链接器
2.来到340行附近,红底粗体为修改部分
# the stream sources
if [ $STREAM = YES ]; then
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
ngx_cxx="\$(CXX) $ngx_compile_opt \$(CXXFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(STREAM_INCS)"
ngx_cxx="\$(CXX) $ngx_compile_opt \$(CXXFLAGS) \$(CORE_INCS) \$(STREAM_INCS)"
fi
for ngx_src in $STREAM_SRCS
do
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_obj=`echo $ngx_src \
| sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
-e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
ext=`echo ${ngx_src} | cut -d . -f 2`
ngx_gcc=$ngx_cc
if [ $ext = "cpp" ]; then
ngx_gcc=$ngx_cxx
fi
cat << END >> $NGX_MAKEFILE
$ngx_obj: \$(CORE_DEPS) \$(STREAM_DEPS)$ngx_cont$ngx_src
$ngx_gcc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
END