ntop / nDPI

Open Source Deep Packet Inspection Software Toolkit
http://www.ntop.org
GNU Lesser General Public License v3.0
3.73k stars 884 forks source link

`src/lib/Makefile.in` has a broken libdir path. #1971

Open ghost opened 1 year ago

ghost commented 1 year ago

It has

cp $(NDPI_LIBS) $(DESTDIR)$(PREFIX)$(libdir)/

which is installing libraries into /usr/usr/lib64/, because in Autotools logic, $libdir must be absolute.

Just make it

cp $(NDPI_LIBS) $(DESTDIR)$(libdir)/
utoni commented 9 months ago

But shouldn't it be DESTDIR=/ in your case? Because you want to install it to / with PREFIX=usr/. Or am I wrong?

ghost commented 9 months ago

But shouldn't it be DESTDIR=/ in your case? Because you want to install it to / with PREFIX=usr/. Or am I wrong?

No, that is not the point of DESTDIR. DESTDIR is normally equal to /tmp/package-ndpi-prefix, and is used to obtain an installation tree somewhere outside of the normal OS directory hierarchy.

utoni commented 9 months ago

You're damn right. $(PREFIX) is usually part of $(libdir) if not set by the user explicitly. I remember that a long time ago there was an "anomaly" within all those Makefile.ins which caused issues with DESTDIR and PREFIX.

utoni commented 9 months ago

I think there is something broken. Using this patch:

diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index 918547ad..e76d8edc 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -91,8 +91,9 @@ cppcheck:
        cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I ../include *.c protocols/*.c

 install: $(NDPI_LIBS)
-       mkdir -p $(DESTDIR)$(PREFIX)$(libdir)
-       cp $(NDPI_LIBS) $(DESTDIR)$(PREFIX)$(libdir)/
+       mkdir -p $(DESTDIR)$(libdir)
+       cp $(NDPI_LIBS) $(DESTDIR)$(libdir)/
+
        cp -P $(NDPI_LIB_SHARED_BASE) $(DESTDIR)$(PREFIX)$(libdir)/
        cp -P $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR) $(DESTDIR)$(PREFIX)$(libdir)/
        mkdir -p $(DESTDIR)$(PREFIX)$(includedir)

and I get this error:

Making install in src/lib
make[1]: Entering directory '/home/toni/git/nDPI/src/lib'
mkdir -p /home/toni/git/nDPI/tmp_install/lib
cp libndpi.a libndpi.so.4.9.0 /home/toni/git/nDPI/tmp_install/lib/
cp -P libndpi.so /home/toni/git/nDPI/tmp_install/usr/bla/lib/
cp: cannot create symbolic link '/home/toni/git/nDPI/tmp_install/usr/bla/lib/': No such file or directory
make[1]: *** [Makefile:96: install] Error 1
make[1]: Leaving directory '/home/toni/git/nDPI/src/lib'
make: *** [Makefile:557: install-recursive] Error 1

while configuring and building it with:

./autogen.sh --prefix=/usr/bla && make install DESTDIR=$(realpath ./tmp_install)

Does it work for you or do I miss something?

utoni commented 9 months ago

Nevermind, the patch is not enough to fix this. ;)

ghost commented 9 months ago

See https://gitlab.com/Lockywolf/lwfslackbuilds/-/blob/master/53_todo_services/ntopng/ntopng.SlackBuild?ref_type=heads