I have problems with using pkg-config
in a Makefile
, while running in sudo
mode. I need to have PKG_CONFIG_PATH
set for pkg-config to find geany.pc file that is held in /usr/local/lib/pkgconfig
.
If I run:
$ echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
If I run with sudo
:
$ sudo echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
So I try running my Makefile that looks like this:
PLUGIN_DIR=`pkg-config --variable=libdir geany`/geany
all: pyflakes.o
gcc pyflakes.o -o geanypyflakes.so -shared `pkg-config --libs geany`
pyflakes.o: pyflakes.c
gcc -Wall -c pyflakes.c -fPIC `pkg-config --cflags geany`
install:
echo ${PKG_CONFIG_PATH}
cp geanypyflakes.so ${PLUGIN_DIR} --verbose
clean:
rm geanypyflakes.so pyflakes.o
sudo make install
and I get following ouput:
echo
cp geanypyflakes.so `pkg-config --variable=libdir geany`/geany --verbose
`geanypyflakes.so' -> `/geany'
Why suddenly PKG_CONFIG_PATH
is not set? I can run sudo -E
and then it works, but I would like to understand why it suddenly is not working.
EDIT
Running export before didn't help:
$ export PKG_CONFIG_PATH='/usr/local/lib/pkconfig' && sudo make install
echo
cp geanypyflakes.so `pkg-config --variable=libdir geany`/geany --verbose
`geanypyflakes.so' -> `/geany'
export PKG_CONFIG_PATH='/usr/local/lib/pkgconfig' && sudo make install