No, in this case I am not building with --static, and I am not passing --static to pkg-config either. However, there may be systems where I don't know whether the compiler (behind my back) uses --static, e.g. Cray or Blue Gene systems. Is it safe to always use --static with pkg-config?
I determine include paths, library paths, and libraries with the following shell code:
HWLOC_INC_DIRS="$(echo '' $(pkg-config hwloc --cflags) '' | sed -e 's+ -I/include + +g;s+ -I/usr/include + +g;s+ -I/usr/local/include + +g' | sed -e 's/ -I/ /g')"
HWLOC_LIB_DIRS="$(echo '' $(pkg-config hwloc --libs) '' | sed -e 's/ -l[^ ]*/ /g' | sed -e 's+ -L/lib + +g;s+ -L/lib64 + +g;s+ -L/usr/lib + +g;s+ -L/usr/lib64 + +g;s+ -L/usr/local/lib + +g;s+ -L/usr/local/lib64 + +g' | sed -e 's/ -L/ /g')"
HWLOC_LIBS="$(echo '' $(pkg-config hwloc --libs) '' | sed -e 's/ -[^l][^ ]*/ /g' | sed -e 's/ -l/ /g')"
The sed magic remove /usr/include and similar system paths if they are present, because having these present can lead to build problems. This does not affect whether -lnuma is present and not. The magic also removes the -I, -L, and -l prefixes that my build system insists on adding again (for historic reasons).