diff --git a/auto/help b/auto/help index 064a209b4..7fb6f6e23 100644 --- a/auto/help +++ b/auto/help @@ -16,6 +16,8 @@ default: "$NJS_ADDRESS_SANITIZER" --cc=FILE sets C compiler filename, default: "$CC" --cc-opt=OPTIONS sets additional C compiler options, \ default: "$NJS_CC_OPT" + --pic=OPTION sets position independent code flag, \ +default: "$NJS_PIC" --debug=YES enables additional runtime checks, \ default: "$NJS_DEBUG" --debug-memory=YES enables memory alloc debug, \ diff --git a/auto/make b/auto/make index feffb69aa..296ff5a8d 100644 --- a/auto/make +++ b/auto/make @@ -89,7 +89,8 @@ cat << END > $NJS_MAKEFILE NJS_CC = ${CC} NJS_STATIC_LINK = ${AR} -r -c NJS_LINK = ${CC} ${NJS_LD_OPT} -NJS_CFLAGS = ${NJS_CFLAGS} ${NJS_CC_OPT} ${CFLAGS} +NJS_PIC = ${NJS_PIC} +CFLAGS = ${NJS_CC_OPT} ${CFLAGS:-${NJS_CFLAGS}} NJS_LIB_AUX_CFLAGS = ${NJS_LIB_AUX_CFLAGS} NJS_VER = $(grep NJS_VERSION src/njs.h | sed -e 's#.*"\(.*\)".*#\1#') @@ -132,7 +133,7 @@ do cat << END >> $NJS_MAKEFILE $NJS_BUILD_DIR/$njs_obj: $njs_src - \$(NJS_CC) -c \$(NJS_LIB_INCS) \$(NJS_CFLAGS) \\ + \$(NJS_CC) -c \$(NJS_LIB_INCS) \$(NJS_PIC) \$(CFLAGS) \\ \$(NJS_LIB_AUX_CFLAGS) \\ -o $NJS_BUILD_DIR/$njs_obj \\ $njs_dep_flags \\ @@ -154,7 +155,7 @@ do cat << END >> $NJS_MAKEFILE $NJS_BUILD_DIR/$njs_obj: $njs_src - \$(NJS_CC) -c \$(NJS_LIB_INCS) \$(NJS_CFLAGS) \\ + \$(NJS_CC) -c \$(NJS_LIB_INCS) \$(NJS_PIC) \$(CFLAGS) \\ \$(NJS_LIB_AUX_CFLAGS) \\ -o $NJS_BUILD_DIR/$njs_obj \\ $njs_dep_flags \\ @@ -175,7 +176,7 @@ $NJS_BUILD_DIR/njs: \\ $NJS_BUILD_DIR/libnjs.a $QJS_LIB \\ external/njs_shell.c \$(NJS_LINK) -o $NJS_BUILD_DIR/njs \$(NJS_LIB_INCS) \\ - \$(NJS_CFLAGS) \$(NJS_LIB_AUX_CFLAGS)\\ + \$(CFLAGS) \$(NJS_LIB_AUX_CFLAGS)\\ external/njs_shell.c \\ $NJS_BUILD_DIR/libnjs.a $QJS_LIB \\ $NJS_LD_OPT -lm $NJS_LIBS $NJS_LIB_AUX_LIBS $NJS_READLINE_LIB @@ -220,7 +221,7 @@ do $NJS_BUILD_DIR/$njs_bin: $njs_src \\ $NJS_BUILD_DIR/libnjs.a \$(NJS_LINK) -o $NJS_BUILD_DIR/$njs_bin \$(NJS_LIB_INCS) \\ - \$(NJS_CFLAGS) $njs_dep_flags \\ + \$(CFLAGS) $njs_dep_flags \\ $njs_src $NJS_BUILD_DIR/libnjs.a \\ $njs_dep_post -lm $NJS_LD_OPT @@ -244,7 +245,7 @@ cat << END >> $NJS_MAKEFILE $NJS_BUILD_DIR/$njs_externals_obj: \\ $njs_src - \$(NJS_CC) -c \$(NJS_LIB_INCS) \$(NJS_CFLAGS) \\ + \$(NJS_CC) -c \$(NJS_LIB_INCS) \$(CFLAGS) \\ \$(NJS_LIB_AUX_CFLAGS) \\ -o $NJS_BUILD_DIR/$njs_externals_obj \\ $njs_dep_flags \\ @@ -268,7 +269,7 @@ $NJS_BUILD_DIR/$njs_bin: $njs_src \\ $NJS_BUILD_DIR/libnjs.a \\ $NJS_BUILD_DIR/$njs_externals_obj \$(NJS_LINK) -o $NJS_BUILD_DIR/$njs_bin \$(NJS_LIB_INCS) \\ - \$(NJS_CFLAGS) \$(NJS_LIB_AUX_CFLAGS) \\ + \$(CFLAGS) \$(NJS_LIB_AUX_CFLAGS) \\ $njs_dep_flags \\ $NJS_BUILD_DIR/$njs_externals_obj \\ $njs_src $NJS_BUILD_DIR/libnjs.a \\ diff --git a/auto/options b/auto/options index 0a4dc6c74..49d980192 100644 --- a/auto/options +++ b/auto/options @@ -3,8 +3,9 @@ # Copyright (C) NGINX, Inc. -NJS_CC_OPT=${NJS_CC_OPT:--O} -NJS_LD_OPT=${NJS_CC_OPT:--O} +NJS_CC_OPT= +NJS_LD_OPT= +NJS_PIC=-fPIC NJS_DEBUG=NO NJS_DEBUG_MEMORY=NO @@ -40,6 +41,8 @@ do --ld-opt=*) NJS_LD_OPT="$value" ;; --ar=*) AR="$value" ;; + --pic=*) NJS_PIC="$value" ;; + --build-dir=*) NJS_BUILD_DIR="$value" ;; --address-sanitizer=*) NJS_ADDRESS_SANITIZER="$value" ;; diff --git a/auto/summary b/auto/summary index f540f11ec..59d70428c 100644 --- a/auto/summary +++ b/auto/summary @@ -7,7 +7,7 @@ echo echo "NJS configuration summary:" echo echo " + using CC: \"$CC\"" -echo " + using CFLAGS: \"$NJS_CFLAGS $NJS_CC_OPT $CFLAGS\"" +echo " + using CFLAGS: \"$NJS_CC_OPT ${CFLAGS:-$NJS_CFLAGS}\"" echo if [ $NJS_HAVE_PCRE = YES ]; then