3 # Copyright (c) 2002-2004, Apple Computer, Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
8 # 1. Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
13 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
14 # contributors may be used to endorse or promote products derived from this
15 # software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 # IMPORTANT NOTE: This is a Makefile for *GNU make*
29 # On some systems, a different program may be the default "make" command.
30 # If "make os=xxx" gives lots of errors like "Missing dependency operator",
31 # then try typing "gmake os=xxx" instead.
34 # Revision 1.78 2007/10/22 20:16:49 cheshire
35 # Got rid of jaguar and panther from list of target platforms;
36 # changed "os=tiger" to "os=x" (which works with both Tiger and Leopard)
38 # Revision 1.77 2007/10/22 20:04:51 cheshire
39 # Need to include PlatformCommon.c.o in embedded targets
41 # Revision 1.76 2007/07/31 23:39:02 mcguire
42 # Don't bail on errors in flex-generated .c files
44 # Revision 1.75 2006/08/24 22:41:23 herscher
45 # <rdar://problem/4580067> POSIX: dnsextd_parser doesn't compile on Linux
47 # Revision 1.74 2006/08/14 23:07:11 cheshire
48 # Added "tab-width" emacs header line
50 # Revision 1.73 2006/07/07 00:54:08 cheshire
51 # <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
52 # Put intermediate files into "objects" folder instead of mDNSShared source code folder
54 # Revision 1.72 2006/07/05 23:53:58 cheshire
55 # <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
57 # Revision 1.71 2006/06/20 23:07:04 rpantos
58 # <rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
60 # Revision 1.70 2006/05/03 23:35:10 cheshire
61 # Add missing dependency: NetMonitor.c textually imports mDNS.c
63 # Revision 1.69 2006/02/26 23:18:50 cheshire
64 # <rdar://problem/4427969> FreeBSD 4 requires "-pthread" option to compile threaded code
66 # Revision 1.68 2006/02/26 01:36:54 cheshire
67 # Rename the poorly named "LIBFLAGS" as "LINKOPTS"
69 # Revision 1.67 2006/02/25 23:14:29 cheshire
70 # Add comment suggesting using "gmake" command
72 # Revision 1.66 2006/01/06 01:06:17 cheshire
73 # <rdar://problem/3978979> Compile library and client programs in one pass
75 # Revision 1.65 2005/12/21 21:15:57 cheshire
76 # Add missing dependency: Identify.c textually imports mDNS.c
78 # Revision 1.64 2005/10/25 23:55:47 cheshire
79 # Add tiger to list of target platforms
81 # Revision 1.63 2005/10/11 21:30:44 cheshire
82 # Add "-Wunreachable-code" (commented out for now)
84 # Revision 1.62 2005/06/30 21:46:55 cheshire
85 # <rdar://problem/4167287> Solaris should use unix domain sockets, not loopback
87 # Revision 1.61 2005/06/30 20:46:05 cheshire
88 # Added Makefile rule to build threadsafe object files where necessary using "-D_REENTRANT".
90 # Revision 1.60 2005/06/30 10:42:38 cheshire
91 # Turn on "-Werror" and "-O" for better error reporting
93 # Revision 1.59 2005/04/14 21:07:10 rpantos
94 # Bug #: 4089257, Clean build broken for Java support on POSIX
95 # Submitted by: Roger Pantos
96 # Reviewed by: Kiren Sekar
98 # Revision 1.58 2005/04/08 21:37:57 ksekar
99 # <rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
101 # Revision 1.57 2005/03/17 04:02:28 cheshire
102 # <rdar://problem/3986419> mDNSResponder won't compile with gcc4 on Tiger
103 # Changed Makefile to link using gcc instead of libtool
105 # Revision 1.56 2005/02/02 02:25:21 cheshire
106 # <rdar://problem/3980388> /var/run/mDNSResponder should be /var/run/mdnsd on Linux
108 # Revision 1.55 2005/01/27 22:55:00 cheshire
109 # Add "make os=tiger" target which uses gcc4 and "-Wdeclaration-after-statement"
111 # Revision 1.54 2004/12/17 19:33:03 cheshire
112 # Add "-lresolv" for Solaris
114 # Revision 1.53 2004/12/01 20:04:31 cheshire
117 # Revision 1.52 2004/12/01 19:46:12 cheshire
118 # Add install case for Suse 9 (rc*.d directories *inside* the init.d directory)
120 # Revision 1.51 2004/12/01 03:30:29 cheshire
121 # <rdar://problem/3889346> Add Unicast DNS support to mDNSPosix
123 # Revision 1.50 2004/12/01 01:14:20 cheshire
124 # Add $(LIBFLAGS) to cc command to build dnsextd (required for Solaris)
126 # Revision 1.49 2004/11/11 01:44:52 cheshire
127 # Updated error message
129 # Revision 1.48 2004/10/06 02:22:19 cheshire
130 # Changed MacRoman copyright symbol (should have been UTF-8 in any case :-) to ASCII-compatible "(c)"
132 # Revision 1.47 2004/10/01 22:15:54 rpantos
133 # rdar://problem/3824265: Replace APSL in client lib with BSD license.
135 # Revision 1.46 2004/09/24 21:15:25 cheshire
136 # <rdar://problem/3724985> Library "libmdns" misnamed; should be "libdns_sd"
138 # Revision 1.45 2004/09/22 16:23:41 cheshire
139 # Modify installation for compatibility with Gentoo Linux
140 # (Thanks to David Black for this information)
142 # Revision 1.44 2004/09/17 01:08:53 cheshire
143 # Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
144 # The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
145 # declared in that file are ONLY appropriate to single-address-space embedded applications.
146 # For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
148 # Revision 1.43 2004/09/17 00:30:11 cheshire
149 # Added some '@' signs to make build output less verbose --
150 # when there's too much on the screen it's easy to miss build errors and warnings
152 # Revision 1.42 2004/08/24 22:04:37 cheshire
153 # Need to specify -lpthread for building dnsextd
155 # Revision 1.41 2004/08/11 00:43:26 ksekar
156 # <rdar://problem/3722542>: DNS Extension daemon for DNS Update Lease
158 # Revision 1.40 2004/07/08 21:45:55 cheshire
159 # Make nss_mdns only build on Linux. We can add it to other targets (Solaris,
160 # FreeBSD, etc., as we verify them). In particular, NSS is NOT supported on
161 # OS X, so including it for "os=jaguar" or "os=panther" broke those builds.
163 # Revision 1.39 2004/06/29 03:34:28 cheshire
164 # Add 'dot-local' Name Service Switch support from Andrew White at NICTA
166 # Revision 1.38 2004/06/25 02:19:40 rpantos
169 # Revision 1.37 2004/06/25 00:51:09 rpantos
170 # And fix the Java build for Posix on Solaris, too.
172 # Revision 1.36 2004/06/25 00:26:27 rpantos
173 # Changes to fix the Posix build on Solaris.
175 # Revision 1.35 2004/06/18 18:51:31 cheshire
176 # Add (commented out) "-pedantic" for when we want to check for "mixed declarations and code" warnings
178 # Revision 1.34 2004/05/25 18:29:33 cheshire
179 # Move DNSServiceConstructFullName() from dnssd_clientstub.c to dnssd_clientlib.c,
180 # so that it's also accessible to dnssd_clientshim.c (single address space) clients.
182 # Revision 1.33 2004/04/30 16:46:32 rpantos
183 # Add support for building Java libraries.
185 # Revision 1.32 2004/04/14 23:09:29 ksekar
186 # Support for TSIG signed dynamic updates.
188 # Revision 1.31 2004/03/15 19:07:06 cheshire
191 # Revision 1.30 2004/03/11 18:58:29 rpantos
192 # Fix Kill /etc/rc scripts so they run at halt & reboot.
194 # Revision 1.29 2004/03/04 23:35:41 cheshire
195 # Instead of using a dummy target to generate an error message, use "$(error text...)"
197 # Revision 1.28 2004/03/04 23:33:42 cheshire
198 # Fixes from Alfred Perlstein for FreeBSD's benefit
200 # Revision 1.27 2004/02/11 21:00:21 cheshire
201 # Update URL for GNU Make manual page
203 # Revision 1.26 2004/02/05 21:28:30 cheshire
204 # Fixes so that "sudo make install" works on *BSD
206 # Revision 1.25 2004/02/05 20:00:22 cheshire
207 # Define mdnsd's PID file to be /var/run/mdnsd.pid on Posix builds
209 # Revision 1.24 2004/02/05 01:00:01 rpantos
210 # Fix some issues that turned up when building for FreeBSD.
212 # Revision 1.23 2004/02/04 01:50:54 cheshire
213 # Make InstalledStartup conditional, so it automatically installs into
214 # either /etc/init.d/ or /etc/rc.d/init.d/ as appropriate
216 # Revision 1.22 2004/01/20 01:41:21 rpantos
217 # Define USES_NETLINK for Linux builds.
219 # Revision 1.21 2003/12/17 00:51:22 cheshire
220 # Changed mDNSNetMonitor and mDNSIdentify to link the object files
221 # instead of #including the "DNSCommon.c" "uDNS.c" and source files
223 # Revision 1.20 2003/12/13 03:05:28 ksekar
224 # Bug #: <rdar://problem/3192548>: DynDNS: Unicast query of service records
226 # Revision 1.19 2003/12/11 19:42:13 cheshire
227 # Change name "mDNSResponderd" to "mdnsd" for consistency with standard Linux (Unix) naming conventions
229 # Revision 1.18 2003/12/11 19:38:34 cheshire
232 # Revision 1.17 2003/12/11 03:16:49 rpantos
233 # One more change for OS X build: make install work a little better.
235 # Revision 1.16 2003/12/11 03:03:51 rpantos
236 # Clean up mDNSPosix so that it builds on OS X again.
238 # Revision 1.15 2003/12/08 20:47:02 rpantos
239 # Add support for mDNSResponder on Linux.
241 # Revision 1.14 2003/11/14 20:59:09 cheshire
242 # Clients can't use AssignDomainName macro because mDNSPlatformMemCopy is defined in mDNSPlatformFunctions.h.
243 # Best solution is just to combine mDNSEmbeddedAPI.h and mDNSPlatformFunctions.h into a single file.
245 # Revision 1.13 2003/08/06 18:20:51 cheshire
248 # Revision 1.12 2003/08/01 02:20:02 cheshire
249 # Add mDNSIdentify tool, used to discover what version of mDNSResponder a particular host is running
251 # Revision 1.11 2003/07/14 18:11:54 cheshire
252 # Fix stricter compiler warnings
254 # Revision 1.10 2003/06/18 05:47:41 cheshire
255 # Enable stricter warnings on Jaguar and Panther builds
257 # Revision 1.9 2003/06/04 18:34:45 ksekar
258 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
259 # Changed build targets "osx10.2" and "osx10.3" to "jaguar" and "panther".
261 # Revision 1.8 2003/06/04 00:23:12 ksekar
262 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
263 # Created separate target OS's for 10.2 and 10.3.
265 # Revision 1.7 2003/04/16 02:11:37 cheshire
266 # Remove unnecessary $(CFLAGS) from linking rules
268 # Revision 1.6 2003/04/04 01:37:14 cheshire
272 # This Makefile builds an mDNSResponder daemon and a libdns_sd.so shared library
273 # for Linux. It also builds several example programs for embedded systems.
275 # Make with no arguments to build all production targets.
276 # 'make DEBUG=1' to build debugging targets.
277 # 'make clean' or 'make clean DEBUG=1' to delete prod/debug objects & targets
278 # 'sudo make install [DEBUG=1]' to install mdnsd daemon and libdns_sd.
281 # $@ means "The file name of the target of the rule"
282 # $< means "The name of the first prerequisite"
283 # $* means "The stem with which an implicit rule matches"
284 # $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
285 # For more magic automatic variables, see
286 # <http://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html>
288 #############################################################################
292 COREDIR = ../mDNSCore
293 SHAREDDIR = ../mDNSShared
303 CFLAGS_COMMON = -I. -I$(COREDIR) -I$(SHAREDDIR) -I$(OBJDIR) -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
306 LINKOPTS_PTHREAD = -lpthread
308 JAVACFLAGS_OS = -fPIC -shared -ldns_sd
310 # Set up diverging paths for debug vs. prod builds
313 CFLAGS_DEBUG = -g -DMDNS_DEBUGMSGS=2
314 OBJDIR = objects/debug
315 BUILDDIR = build/debug
318 # We use -Os for two reasons:
319 # 1. We want to make small binaries, suitable for putting into hardware devices
320 # 2. Some of the code analysis warnings only work when some form of optimization is enabled
321 CFLAGS_DEBUG = -Os -DMDNS_DEBUGMSGS=0
322 OBJDIR = objects/prod
323 BUILDDIR = build/prod
327 # Configure per-OS peculiarities
329 CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
330 -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME
333 LINKOPTS = -lsocket -lnsl -lresolv
334 JAVACFLAGS_OS += -I$(JDK)/include/solaris
341 CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX
343 JAVACFLAGS_OS += -I$(JDK)/include/linux
344 OPTIONALTARG = nss_mdns
345 OPTINSTALL = InstalledNSS
354 # If not already defined, set LOCALBASE to /usr/local
355 # FreeBSD requires the startup script to end in ".sh"
356 LOCALBASE?=/usr/local
357 INSTBASE=$(LOCALBASE)
358 STARTUPSCRIPTNAME=mdns.sh
360 # FreeBSD 4 requires threaded code to be compiled and linked using the "-pthread" option,
361 # and requires that the "-lpthread" link option NOT be used
362 # This appies only to FreeBSD -- "man cc" on FreeBSD says:
363 # FreeBSD SPECIFIC OPTIONS
365 # Link a user-threaded process against libc_r instead of libc.
366 CFLAGS_PTHREAD = -pthread -D_THREAD_SAFE
367 LINKOPTS_PTHREAD = -pthread
368 JAVACFLAGS_OS += -I$(JDK)/include/freebsd
373 CFLAGS_OS = -DHAVE_BROKEN_RECVDSTADDR
378 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement #-Wunreachable-code
380 LD = $(CC) -dynamiclib
383 JDK = /System/Library/Frameworks/JavaVM.framework/Home
384 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
387 $(error ERROR: Must specify target OS on command-line, e.g. "make os=x [target]".\
388 Supported operating systems include: x, linux, netbsd, freebsd, openbsd, solaris)
396 NSSLIBNAME := libnss_mdns
398 NSSLIBFILE := $(NSSLIBNAME)-$(NSSVERSION).so
399 NSSLINKNAME := $(NSSLIBNAME).so.2
402 # If not otherwise defined, we install into /usr/lib and /usr/include
403 # and our startup script is called mdns (e.g. /etc/init.d/mdns)
405 STARTUPSCRIPTNAME?=mdns
407 ifeq ($(HAVE_IPV6),1)
408 CFLAGS_OS += -DHAVE_IPV6=1
410 ifeq ($(HAVE_IPV6),0)
411 CFLAGS_OS += -DHAVE_IPV6=0
415 # If directory /usr/share/man exists, then we install man pages into that, else /usr/man
416 ifeq ($(wildcard /usr/share/man), /usr/share/man)
417 MANPATH := /usr/share/man
422 # If directories /etc/init.d/rc*.d exist, then we install into that (Suse)
423 ifeq ($(wildcard /etc/init.d/rc2.d/), /etc/init.d/rc2.d/)
424 STARTUPSCRIPTDIR = /etc/init.d
425 RUNLEVELSCRIPTSDIR = /etc/init.d
427 # else if directory /etc/rc.d/init.d/ exists, then we install into that (old Linux)
428 ifeq ($(wildcard /etc/rc.d/init.d/), /etc/rc.d/init.d/)
429 STARTUPSCRIPTDIR = /etc/rc.d/init.d
430 RUNLEVELSCRIPTSDIR = /etc/rc.d
432 # else if directory /etc/init.d/ exists, then we install into that (new Linux)
433 ifeq ($(wildcard /etc/init.d/), /etc/init.d/)
434 STARTUPSCRIPTDIR = /etc/init.d
435 RUNLEVELSCRIPTSDIR = /etc
437 # else install into /etc/rc.d/ (*BSD)
438 STARTUPSCRIPTDIR = $(INSTBASE)/etc/rc.d
443 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUG)
445 #############################################################################
447 all: setup Daemon libdns_sd Clients SAClient SAResponder SAProxyResponder Identify NetMonitor dnsextd $(OPTIONALTARG)
449 install: setup InstalledDaemon InstalledStartup InstalledLib InstalledManPages InstalledClients $(OPTINSTALL)
451 # 'setup' sets up the build directory structure the way we want
453 @if test ! -d objects ; then mkdir objects ; fi
454 @if test ! -d build ; then mkdir build ; fi
455 @if test ! -d $(OBJDIR) ; then mkdir $(OBJDIR) ; fi
456 @if test ! -d $(BUILDDIR) ; then mkdir $(BUILDDIR) ; fi
458 # clean removes targets and objects
460 @if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
461 @if test -d $(BUILDDIR) ; then rm -r $(BUILDDIR) ; fi
462 @$(MAKE) -C ../Clients clean
464 #############################################################################
466 # daemon target builds the daemon
467 DAEMONOBJS = $(OBJDIR)/PosixDaemon.c.o $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNS.c.o \
468 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/uds_daemon.c.o \
469 $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/dnssd_ipc.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/PlatformCommon.c.o
471 # dnsextd target build dnsextd
472 DNSEXTDOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/DNSDigest.c.o \
473 $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/PlatformCommon.c.o $(OBJDIR)/dnsextd_parser.y.o $(OBJDIR)/dnsextd_lexer.l.o
475 Daemon: setup $(BUILDDIR)/mdnsd
476 @echo "Responder daemon done"
478 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
479 $(CC) -o $@ $+ $(LINKOPTS)
482 # libdns_sd target builds the client library
483 libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
484 @echo "Client library done"
486 CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
488 $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
489 @$(LD) $(LINKOPTS) -o $@ $+
492 Clients: setup libdns_sd ../Clients/build/dns-sd
495 ../Clients/build/dns-sd:
496 @$(MAKE) -C ../Clients
498 # nss_mdns target builds the Name Service Switch module
499 nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)
500 @echo "Name Service Switch module done"
502 $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
503 @$(LD) $(LINKOPTS) -o $@ $+
506 #############################################################################
508 # The Install targets place built stuff in their proper places
509 InstalledDaemon: $(INSTBASE)/sbin/mdnsd
510 @echo $+ " installed"
512 InstalledLib: $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
513 @echo $+ " installed"
515 InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
516 @echo $+ " installed"
518 InstalledManPages: $(MANPATH)/man8/mdnsd.8
519 @echo $+ " installed"
521 InstalledClients: $(INSTBASE)/bin/dns-sd
522 @echo $+ " installed"
524 InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
525 @echo $+ " installed"
527 # Note: If daemon already installed, we make sure it's stopped before overwriting it
528 $(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd
529 @if test -x $@; then $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) stop; fi
532 $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
534 $(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
536 # -m means 'merge into existing database', -R means 'rescan directories'
540 $(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
543 # We make this target dependent on $(INSTBASE)/sbin/mdnsd because we need to ensure
544 # that the daemon is installed *before* we try to execute the command to start it.
545 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR) $(INSTBASE)/sbin/mdnsd
549 ifdef RUNLEVELSCRIPTSDIR
550 ifeq ($(wildcard $(RUNLEVELSCRIPTSDIR)/runlevels/default), $(RUNLEVELSCRIPTSDIR)/runlevels/default)
551 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/runlevels/default/mdns
553 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc2.d/S52mdns
554 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc3.d/S52mdns
555 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc4.d/S52mdns
556 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc5.d/S52mdns
557 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc0.d/K16mdns
558 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc6.d/K16mdns
562 $(MANPATH)/man5/%.5: %.5
566 $(MANPATH)/man8/%.8: %.8
570 $(MANPATH)/man8/mdnsd.8: $(SHAREDDIR)/mDNSResponder.8
574 $(INSTBASE)/bin/dns-sd: ../Clients/build/dns-sd
577 $(NSSINSTPATH)/$(NSSLINKNAME): $(NSSINSTPATH)/$(NSSLIBFILE)
581 $(NSSINSTPATH)/$(NSSLIBFILE): $(BUILDDIR)/$(NSSLIBFILE)
585 /etc/nss_mdns.conf: nss_mdns.conf
588 # Check the nsswitch.conf file.
589 # If 'mdns' does not already appear on the "hosts:" line, then add it right before 'dns'
590 cp -f /etc/nsswitch.conf /etc/nsswitch.conf.pre-mdns
591 sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' /etc/nsswitch.conf.pre-mdns > /etc/nsswitch.conf
593 #############################################################################
595 # The following targets build Java wrappers for the dns-sd.h API.
597 JAVAC = $(JDK)/bin/javac
598 JAVAH = $(JDK)/bin/javah
599 JAVADOC = $(JDK)/bin/javadoc
601 JAVACFLAGS = $(CFLAGS) $(JAVACFLAGS_OS) -I$(JDK)/include
603 Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
604 @echo "Java wrappers done"
606 JAVASRC = $(SHAREDDIR)/Java
607 JARCONTENTS = $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
608 $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
609 $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
610 $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
611 $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
612 $(OBJDIR)/com/apple/dnssd/BaseListener.class \
613 $(OBJDIR)/com/apple/dnssd/BrowseListener.class \
614 $(OBJDIR)/com/apple/dnssd/ResolveListener.class \
615 $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
616 $(OBJDIR)/com/apple/dnssd/QueryListener.class \
617 $(OBJDIR)/com/apple/dnssd/DomainListener.class \
618 $(OBJDIR)/com/apple/dnssd/RegisterRecordListener.class \
619 $(OBJDIR)/com/apple/dnssd/DNSSDRecordRegistrar.class \
620 $(OBJDIR)/com/apple/dnssd/DNSSD.class
622 $(BUILDDIR)/dns_sd.jar: $(JARCONTENTS) setup
623 $(JAR) -cf $@ -C $(OBJDIR) com
625 $(BUILDDIR)/libjdns_sd.$(LDSUFFIX): $(JAVASRC)/JNISupport.c $(OBJDIR)/DNSSD.java.h setup libdns_sd
626 $(CC) -o $@ $< $(JAVACFLAGS) -I$(OBJDIR) -L$(BUILDDIR)
628 $(OBJDIR)/com/apple/dnssd/%.class: $(JAVASRC)/%.java
629 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
631 $(OBJDIR)/DNSSD.java.h: $(OBJDIR)/com/apple/dnssd/DNSSD.class
632 $(JAVAH) -force -classpath $(OBJDIR) -o $@ \
633 com.apple.dnssd.AppleDNSSD \
634 com.apple.dnssd.AppleBrowser \
635 com.apple.dnssd.AppleResolver \
636 com.apple.dnssd.AppleRegistration \
637 com.apple.dnssd.AppleQuery \
638 com.apple.dnssd.AppleDomainEnum \
639 com.apple.dnssd.AppleService
641 #############################################################################
643 # The following target builds documentation for the Java wrappers.
646 $(JAVADOC) $(JAVASRC)/*.java -classpath $(OBJDIR) -d $(BUILDDIR) -public
648 #############################################################################
650 # The following targets build embedded example programs
651 SPECIALOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o \
652 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/PlatformCommon.c.o
653 COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
654 APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
656 SAClient: setup $(BUILDDIR)/mDNSClientPosix
657 @echo "Embedded Standalone Client done"
659 SAResponder: setup $(BUILDDIR)/mDNSResponderPosix
660 @echo "Embedded Standalone Responder done"
662 SAProxyResponder: setup $(BUILDDIR)/mDNSProxyResponderPosix
663 @echo "Embedded Standalone ProxyResponder done"
665 Identify: setup $(BUILDDIR)/mDNSIdentify
666 @echo "Identify done"
668 NetMonitor: setup $(BUILDDIR)/mDNSNetMonitor
669 @echo "NetMonitor done"
671 dnsextd: setup $(BUILDDIR)/dnsextd
674 $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
675 $(CC) $+ -o $@ $(LINKOPTS)
677 $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
678 $(CC) $+ -o $@ $(LINKOPTS)
680 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o
681 $(CC) $+ -o $@ $(LINKOPTS)
683 $(BUILDDIR)/mDNSIdentify: $(SPECIALOBJ) $(OBJDIR)/Identify.c.o
684 $(CC) $+ -o $@ $(LINKOPTS)
686 $(OBJDIR)/Identify.c.o: $(COREDIR)/mDNS.c # Note: Identify.c textually imports mDNS.c
688 $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
689 $(CC) $+ -o $@ $(LINKOPTS)
691 $(OBJDIR)/NetMonitor.c.o: $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c
693 $(BUILDDIR)/dnsextd: $(DNSEXTDOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o
694 $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD)
696 #############################################################################
700 $(CC) $(CFLAGS) -c -o $@ $<
702 $(OBJDIR)/%.c.o: $(COREDIR)/%.c
703 $(CC) $(CFLAGS) -c -o $@ $<
705 $(OBJDIR)/%.c.o: $(SHAREDDIR)/%.c
706 $(CC) $(CFLAGS) -c -o $@ $<
708 $(OBJDIR)/%.c.threadsafe.o: %.c
709 $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
711 $(OBJDIR)/%.c.threadsafe.o: $(SHAREDDIR)/%.c
712 $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
714 $(OBJDIR)/%.c.so.o: %.c
715 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
717 $(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
718 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
720 $(OBJDIR)/%.y.o: $(SHAREDDIR)/%.y
721 $(BISON) -o $(OBJDIR)/$*.c -d $<
722 $(CC) $(CFLAGS) -c -o $@ $(OBJDIR)/$*.c
724 $(OBJDIR)/%.l.o: $(SHAREDDIR)/%.l
725 $(FLEX) $(FLEXFLAGS_OS) -i -o$(OBJDIR)/$*.l.c $<
726 $(CC) $(CFLAGS) -Wno-error -c -o $@ $(OBJDIR)/$*.l.c