Netatalk / netatalk

Netatalk is a Free and Open Source AFP fileserver. A *NIX or BSD system running Netatalk is capable of serving many Macintosh clients simultaneously as an AppleShare file server.
https://netatalk.io
GNU General Public License v2.0
360 stars 87 forks source link

meson: compile error on NetBSD when building without CUPS #1774

Closed rdmark closed 1 day ago

rdmark commented 5 days ago

Building with appletalk support but without CUPS reportedly fails on NetBSD.

rdmark commented 5 days ago

@hfath I wasn't able to reproduce what you saw. In my NetBSD 10.0 setup, with no cups libs installed, doing meson setup with -Dwith-appletalk=true I get in the setup log...

cups-config found: NO
Run-time dependency cups found: NO (tried pkgconfig, config-tool and cmake)
Program cups-config found: NO
meson.build:957: WARNING: CUPS not found, you might need to specify the path to cups-config

Afterwards, I can still compile the code without error.

Would you mind sharing your meson-log for a failed build?

hfath commented 2 days ago

I guess the problem is that meson manages to detect an installed cups past the buildlink mechanism that tries to hide it...

    Features:
      ACL                      : YES
      AFP stats via D-Bus      : NO
      AppleTalk                : YES
      Cracklib                 : YES
      CUPS                     : YES

and then

[225/309] Compiling C object etc/papd/papd.p/print_cups.c.o
FAILED: etc/papd/papd.p/print_cups.c.o 
gcc -Ietc/papd/papd.p -Ietc/papd -I../etc/papd -I. -I.. -Iinclude -I../include -Isys -I../sys -Ietc/afpd -I../etc/afpd -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/db5 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -DHAVE_CONFIG_H '-D_U_=__attribute__((unused))' -Wno-pedantic -Wno-extra -Wno-all -Wno-deprecated-declarations -O2 -DNO_STATIC_MODULES '-D_PATH_PAPDCONF="/etc/pkg/netatalk/papd.conf"' '-D_PATH_PAPDUAMPATH="/usr/pkg/lib/netatalk/"' '-DSPOOLDIR="/var/spool/netatalk/"' '-DVERSION="4.0.7"' -MD -MQ etc/papd/papd.p/print_cups.c.o -MF etc/papd/papd.p/print_cups.c.o.d -o etc/papd/papd.p/print_cups.c.o -c ../etc/papd/print_cups.c
../etc/papd/print_cups.c:38:10: fatal error: cups/ipp.h: No such file or directory
   38 | #include <cups/ipp.h>
      |          ^~~~~~~~~~~~
compilation terminated.

From the meson log

Determining dependency 'cups' with pkg-config executable '/var/obj/pkgsrc/net/netatalk4/work/.tools/bin/pkg-config'
env[PKG_SYSCONFDIR]: /etc/pkg/netatalk
env[PKG_CONFIG]: /var/obj/pkgsrc/net/netatalk4/work/.tools/bin/pkg-config
env[PKG_CONFIG_LIBDIR]: /var/obj/pkgsrc/net/netatalk4/work/.buildlink/lib/pkgconfig:/var/obj/pkgsrc/net/netatalk4/work/.buildlink/share/pkgconfig
env[PKG_CONFIG_LOG]: /var/obj/pkgsrc/net/netatalk4/work/.pkg-config.log
env[PKG_CONFIG_PATH]: 
-----------
Called: `/var/obj/pkgsrc/net/netatalk4/work/.tools/bin/pkg-config --modversion cups` -> 1
stderr:
Package cups was not found in the pkg-config search path.
Perhaps you should add the directory containing `cups.pc'
to the PKG_CONFIG_PATH environment variable
Package 'cups' not found
-----------
cups-config binary missing from cross or native file, or env var undefined.
Trying a default cups-config fallback at cups-config
cups-config found: YES (/usr/pkg/bin/cups-config) 2.4.11
-----------
Called: `/usr/pkg/bin/cups-config --cflags` -> 0
stdout:
-I/usr/pkg/include
-----------

I wonder how that can be averted for pkgsrc builds.

hfath commented 2 days ago

For a bit of background: pkgsrc comes with a mechanism that restricts a package build to the declared dependencies (destdir, elsewhere called fakeroot). Toolchain wrappers point include and library paths to directories with symlink farms, and PATH is re-directed likewise.

Since this is not a full-blown chroot, looking for a tool with absolute path (like /usr/pkg/bin/cups-config above) will get you the tool, breaking the abstraction. That could be avoided by just looking for the tool, relying on PATH which pkgsrc then can manipulate.

hfath commented 2 days ago

Alternatively, if meson is just being too smart for its own good, a with-cups option might be what the doctor prescribes.

rdmark commented 2 days ago

Interesting, this gives me a better idea what's going on. We're using the built-in Meson find_program() wrapper to detect cups and cups-config, which is where the absolute paths come from. So right now this smells like a Meson bug / lack of understanding of the NetBSD destdir model to me.

We have a with-cups option declared but not implemented. I think we forgot to port the option from 2.x to 4.0. Let me get that implemented in the next version!

NJRoadfan commented 1 day ago

FWIW, CUPS detection is changing with libcups3. They are moving to a standard pkg-config setup vs. using a dedicated program.