Installation prefix is wrong when using --prefix on meson or DESDIR in ninja
Closed this issue · 7 comments
It seems that both of them are adding the build machine architecture for installation.
Instead of using /usr/lib or /usr/local/lib it's using usr/lib/x86_64-linux-gnu and usr/local/lib/x86_64-linux-gnu.
This is because I'm compiling for ARM in a X86_64 machine. That's completely wrong. Even if the binary created and installed on that path is for ARM the path is wrong.
In my case:
/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/local/lib/x86_64-linux-gnu/libsg64_core.so
I will also override the values for the prefix and DESTDIR in the cross-file so it can be safely changed when cross-compile in opposition of a normal target build on x86_64 architecture.
So something like this should work.
[binaries]
c = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/bin/arm-linux-gcc'
cpp = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/bin/arm-linux-g++'
ar = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/bin/arm-linux-ar'
strip = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/bin/arm-linux-strip'
pkgconfig = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/bin/pkg-config'
[properties]
root = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot'
DESTDIR = '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot'
prefix= '/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot'
c_args = ['-DTARGET_MACHINE=VAL100',
'--sysroot=/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot']
c_link_args = ['--sysroot=/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot']
cpp_args = ['--sysroot=/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot']
cpp_link_args = ['--sysroot=/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot']
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7hl'
endian = 'little'
[target_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7hl'
endian = 'little'
I can call meson with prefix:
meson --prefix /opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot . build-val100/ --cross-file val100-cross.txt
or I can install with DESTDIR:
DESTDIR=/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot ninja install
But also if I use both. Both paths are added to the installation:
Installing src/libsg64_core.so to /opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot/opt/VAL100/buildroot/buildroot-2015.05/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot/lib/x86_64-linux-gnu/libsg64_core.so
So they are not compatible I think...
meson --version
0.42.1
DESTDIR
is just where to place the files, it should not include the prefix
and its only used for packaging purposes.
I think this is largely a technicality; DESTDIR can also be the same as prefix, even if it may be nonsensical (the --prefix already would have been specified by the user).
I like to think of DESTDIR as simply providing more flexibility for those users who may want to have it. The official description appears to reinforce that notation, for example:
https://www.gnu.org/prep/standards/html_node/DESTDIR.html
"Finally, it can be useful with tools such as stow, where code is installed in one place but made to appear to be installed somewhere else using symbolic links or special mount operations."
E. g. a user to install into his $HOME directory, and/or for testing purposes.
If I understood gadLinux correctly so, then his issue appears to be an automatic conversion towards names such as x86_64-linux-gnu etc... ? I do not know how meson solves this but I think that GNU autoconfigure allowed separate --prefix targets for target library paths too.
My workaround in configure. destdir handles the cross part
meson --prefix=/usr --libdir=lib
It is apparently the default value of libdir which is causing the problem.
FTR: since this is one of the first results for cmake destdir
query, the thread is about DESTDIR in ninja in particular, and yet there's no example how to pass DESTDIR to ninja install
, I'll leave one here:
DESTDIR=/foo/bar/buzz ninja install
https://mesonbuild.com/Installing.html
DESTDIR=/path/to/staging/area ninja install