]> git.kaiwu.me - njs.git/commitdiff
Configure: fix pkg-config paths for absolute build directories
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 22 Oct 2026 14:14:14 +0000 (07:14 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 22 Oct 2026 21:25:01 +0000 (14:25 -0700)
The generated njs.pc prepends the source directory to an absolute
build directory, producing invalid include and library paths.

Preserve absolute build paths and resolve only relative ones against
the source directory.  This also supports engine builds embedded in
nginx without changing the standalone CLI configuration.

auto/make

index 5696329379a0b0099c83581f89b0719ddd15b7da..dacb610eeb6f72b9ebb637f63a92706d74ca553d 100644 (file)
--- a/auto/make
+++ b/auto/make
@@ -439,14 +439,20 @@ ts_clean:
 END
 
 # pkg-config file
+njs_pc_build_dir=$NJS_BUILD_DIR
+case "$njs_pc_build_dir" in
+    /*) ;;
+    *) njs_pc_build_dir="$(pwd)/$njs_pc_build_dir" ;;
+esac
+
 cat << END >> $NJS_MAKEFILE
 
 pc: $NJS_BUILD_DIR/njs.pc
 
 $NJS_BUILD_DIR/njs.pc: $NJS_BUILD_DIR/njs_auto_config.h
-       sed -e "s#@PREFIX@#$(pwd)/$NJS_BUILD_DIR#" \\
-               -e "s#@LIBDIR@#$(pwd)/$NJS_BUILD_DIR#" \\
-               -e "s#@CFLAGS@#-I$(pwd)/$NJS_BUILD_DIR -I$(pwd)/src#" \\
+       sed -e "s#@PREFIX@#$njs_pc_build_dir#" \\
+               -e "s#@LIBDIR@#$njs_pc_build_dir#" \\
+               -e "s#@CFLAGS@#-I$njs_pc_build_dir -I$(pwd)/src#" \\
                -e "s#@VERSION@#\$(NJS_VER)#" \\
                -e "s#@EXTRA_LIBS@#-lm $NJS_LIBS $NJS_LIB_AUX_LIBS#" \\
                src/njs.pc.in > \$@