xref: /aosp_15_r20/external/libcups/config-scripts/cups-dnssd.m4 (revision 5e7646d21f1134fb0638875d812ef646c12ab91e)
1*5e7646d2SAndroid Build Coastguard Workerdnl
2*5e7646d2SAndroid Build Coastguard Workerdnl DNS Service Discovery (aka Bonjour) stuff for CUPS.
3*5e7646d2SAndroid Build Coastguard Workerdnl
4*5e7646d2SAndroid Build Coastguard Workerdnl Copyright © 2007-2019 by Apple Inc.
5*5e7646d2SAndroid Build Coastguard Workerdnl
6*5e7646d2SAndroid Build Coastguard Workerdnl Licensed under Apache License v2.0.  See the file "LICENSE" for more
7*5e7646d2SAndroid Build Coastguard Workerdnl information.
8*5e7646d2SAndroid Build Coastguard Workerdnl
9*5e7646d2SAndroid Build Coastguard Worker
10*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_ENABLE(avahi, [  --disable-avahi         disable DNS Service Discovery support using Avahi])
11*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_ENABLE(dnssd, [  --disable-dnssd         disable DNS Service Discovery support using mDNSResponder])
12*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(dnssd-libs, [  --with-dnssd-libs       set directory for DNS Service Discovery library],
13*5e7646d2SAndroid Build Coastguard Worker	LDFLAGS="-L$withval $LDFLAGS"
14*5e7646d2SAndroid Build Coastguard Worker	DSOFLAGS="-L$withval $DSOFLAGS",)
15*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(dnssd-includes, [  --with-dnssd-includes   set directory for DNS Service Discovery includes],
16*5e7646d2SAndroid Build Coastguard Worker	CFLAGS="-I$withval $CFLAGS"
17*5e7646d2SAndroid Build Coastguard Worker	CPPFLAGS="-I$withval $CPPFLAGS",)
18*5e7646d2SAndroid Build Coastguard Worker
19*5e7646d2SAndroid Build Coastguard WorkerDNSSDLIBS=""
20*5e7646d2SAndroid Build Coastguard WorkerDNSSD_BACKEND=""
21*5e7646d2SAndroid Build Coastguard WorkerIPPFIND_BIN=""
22*5e7646d2SAndroid Build Coastguard WorkerIPPFIND_MAN=""
23*5e7646d2SAndroid Build Coastguard Worker
24*5e7646d2SAndroid Build Coastguard Workerif test "x$PKGCONFIG" != x -a x$enable_avahi != xno -a x$host_os_name != xdarwin; then
25*5e7646d2SAndroid Build Coastguard Worker	AC_MSG_CHECKING(for Avahi)
26*5e7646d2SAndroid Build Coastguard Worker	if $PKGCONFIG --exists avahi-client; then
27*5e7646d2SAndroid Build Coastguard Worker		AC_MSG_RESULT(yes)
28*5e7646d2SAndroid Build Coastguard Worker		CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`"
29*5e7646d2SAndroid Build Coastguard Worker		DNSSDLIBS="`$PKGCONFIG --libs avahi-client`"
30*5e7646d2SAndroid Build Coastguard Worker		DNSSD_BACKEND="dnssd"
31*5e7646d2SAndroid Build Coastguard Worker		IPPFIND_BIN="ippfind"
32*5e7646d2SAndroid Build Coastguard Worker		IPPFIND_MAN="ippfind.1"
33*5e7646d2SAndroid Build Coastguard Worker		AC_DEFINE(HAVE_AVAHI)
34*5e7646d2SAndroid Build Coastguard Worker	else
35*5e7646d2SAndroid Build Coastguard Worker		AC_MSG_RESULT(no)
36*5e7646d2SAndroid Build Coastguard Worker	fi
37*5e7646d2SAndroid Build Coastguard Workerfi
38*5e7646d2SAndroid Build Coastguard Worker
39*5e7646d2SAndroid Build Coastguard Workerif test "x$DNSSD_BACKEND" = x -a x$enable_dnssd != xno; then
40*5e7646d2SAndroid Build Coastguard Worker	AC_CHECK_HEADER(dns_sd.h, [
41*5e7646d2SAndroid Build Coastguard Worker		case "$host_os_name" in
42*5e7646d2SAndroid Build Coastguard Worker			darwin*)
43*5e7646d2SAndroid Build Coastguard Worker				# Darwin and macOS...
44*5e7646d2SAndroid Build Coastguard Worker				AC_DEFINE(HAVE_DNSSD)
45*5e7646d2SAndroid Build Coastguard Worker				DNSSD_BACKEND="dnssd"
46*5e7646d2SAndroid Build Coastguard Worker				IPPFIND_BIN="ippfind"
47*5e7646d2SAndroid Build Coastguard Worker				IPPFIND_MAN="ippfind.1"
48*5e7646d2SAndroid Build Coastguard Worker				;;
49*5e7646d2SAndroid Build Coastguard Worker			*)
50*5e7646d2SAndroid Build Coastguard Worker				# All others...
51*5e7646d2SAndroid Build Coastguard Worker				AC_MSG_CHECKING(for current version of dns_sd library)
52*5e7646d2SAndroid Build Coastguard Worker				SAVELIBS="$LIBS"
53*5e7646d2SAndroid Build Coastguard Worker				LIBS="$LIBS -ldns_sd"
54*5e7646d2SAndroid Build Coastguard Worker				AC_TRY_COMPILE([#include <dns_sd.h>],
55*5e7646d2SAndroid Build Coastguard Worker					[int constant = kDNSServiceFlagsShareConnection;
56*5e7646d2SAndroid Build Coastguard Worker					unsigned char txtRecord[100];
57*5e7646d2SAndroid Build Coastguard Worker					uint8_t valueLen;
58*5e7646d2SAndroid Build Coastguard Worker					TXTRecordGetValuePtr(sizeof(txtRecord),
59*5e7646d2SAndroid Build Coastguard Worker					    txtRecord, "value", &valueLen);],
60*5e7646d2SAndroid Build Coastguard Worker					AC_MSG_RESULT(yes)
61*5e7646d2SAndroid Build Coastguard Worker					AC_DEFINE(HAVE_DNSSD)
62*5e7646d2SAndroid Build Coastguard Worker					DNSSDLIBS="-ldns_sd"
63*5e7646d2SAndroid Build Coastguard Worker					DNSSD_BACKEND="dnssd",
64*5e7646d2SAndroid Build Coastguard Worker					IPPFIND_BIN="ippfind"
65*5e7646d2SAndroid Build Coastguard Worker					IPPFIND_MAN="ippfind.1"
66*5e7646d2SAndroid Build Coastguard Worker					AC_MSG_RESULT(no))
67*5e7646d2SAndroid Build Coastguard Worker				LIBS="$SAVELIBS"
68*5e7646d2SAndroid Build Coastguard Worker				;;
69*5e7646d2SAndroid Build Coastguard Worker		esac
70*5e7646d2SAndroid Build Coastguard Worker	])
71*5e7646d2SAndroid Build Coastguard Workerfi
72*5e7646d2SAndroid Build Coastguard Worker
73*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(DNSSDLIBS)
74*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(DNSSD_BACKEND)
75*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(IPPFIND_BIN)
76*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(IPPFIND_MAN)
77