zstd
zstd copied to clipboard
[Documentation] Clarify the variables that affect installation
Describe the bug The Makefile is very unclear about the destination directory.
To Reproduce Extract the tarball and run "make" and then "make install" seems to try to create files in the system directories.
Expected behavior There should be a DESTDIR target or a configure script or perhaps even some autotools/automake/autoconf input that allows a configure script to exist.
Desktop (please complete the following information): Red Hat Enterprise Linux 6 with gcc 12.1.0 and no CFLAGS other than -std=iso9899:2011 -fno-builtin -g -O0 -m64
Build system is whatever you provide in the tarball. The Makefile.
Software that is compiled and then tested with some testsuite should be optionally installed into a non-system directory.
I see a DESTDIR here :
https://github.com/facebook/zstd/blob/9a5e73c74ef2d621992154306ab1ab6ba44ac8fa/lib/Makefile#L259
However that is not in the main Makefile.
I did some reading in the lib/Makefile where it mentions a DESTDIR and that seems to work. I really don't know what the testsuite is doing so I don't know if I should do the install or not. I will test the DESTDIR and see what that does with some throw away destination target.
Why not just have a configure script the SAME as every other thing on the planet like GCC and binutils and grep and fifty other popular projects.
This is not just an issue of unusual convention. The resulting libzstd.pc file will have the wrong value for "prefix=" when generated with the current implementation. Normal use of the normal tooling should account for automation in .pc files.
I'm pretty sure that the makefile already supports what's being requested here, and the issue is that not everybody is familiar with GNU Make's conventions.
This is not just an issue of unusual convention. The resulting libzstd.pc file will have the wrong value for "prefix=" when generated with the current implementation. Normal use of the normal tooling should account for automation in .pc files.
DESTDIR shouldn't be used to alter the installation prefix, that's the job of PREFIX. PREFIX tells make where you want to install the "release" build of the project, while DESTDIR is mainly used to override the installation prefix for staging builds; it's kinda like the prefix of PREFIX.
So the installation path is more or less obtained this way:
$DESTDIR/$PREFIX/
PREFIX is /usr/local by default, while DESTDIR is unset.
In your case the .pc file has a wrong prefix= value because the .pc generation doesn't account for DESTDIR, it only accounts for PREFIX.
Here's an example:
$ make PREFIX=/usr DESTDIR="$PWD/staging" install
[... build log ...]
$ cat staging/usr/lib/pkgconfig/libzstd.pc
# ZSTD - standard compression algorithm
# Copyright (C) 2014-2016, Yann Collet, Facebook
# BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: zstd
Description: fast lossless compression algorithm library
URL: http://www.zstd.net/
Version: 1.5.3
Libs: -L${libdir} -lzstd
Libs.private: -pthread
Cflags: -I${includedir}
Thanks for answering the question @Tachi107! That is absolutely correct.
I'm going to re-name this task, and put it up as help wanted. The action would be to better document the Makefile to make these variables more clear.