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.76 2007/07/31 23:39:02 mcguire
35 # Don't bail on errors in flex-generated .c files
37 # Revision 1.75 2006/08/24 22:41:23 herscher
38 # <rdar://problem/4580067> POSIX: dnsextd_parser doesn't compile on Linux
40 # Revision 1.74 2006/08/14 23:07:11 cheshire
41 # Added "tab-width" emacs header line
43 # Revision 1.73 2006/07/07 00:54:08 cheshire
44 # <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
45 # Put intermediate files into "objects" folder instead of mDNSShared source code folder
47 # Revision 1.72 2006/07/05 23:53:58 cheshire
48 # <rdar://problem/4472013> Add Private DNS server functionality to dnsextd
50 # Revision 1.71 2006/06/20 23:07:04 rpantos
51 # <rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
53 # Revision 1.70 2006/05/03 23:35:10 cheshire
54 # Add missing dependency: NetMonitor.c textually imports mDNS.c
56 # Revision 1.69 2006/02/26 23:18:50 cheshire
57 # <rdar://problem/4427969> FreeBSD 4 requires "-pthread" option to compile threaded code
59 # Revision 1.68 2006/02/26 01:36:54 cheshire
60 # Rename the poorly named "LIBFLAGS" as "LINKOPTS"
62 # Revision 1.67 2006/02/25 23:14:29 cheshire
63 # Add comment suggesting using "gmake" command
65 # Revision 1.66 2006/01/06 01:06:17 cheshire
66 # <rdar://problem/3978979> Compile library and client programs in one pass
68 # Revision 1.65 2005/12/21 21:15:57 cheshire
69 # Add missing dependency: Identify.c textually imports mDNS.c
71 # Revision 1.64 2005/10/25 23:55:47 cheshire
72 # Add tiger to list of target platforms
74 # Revision 1.63 2005/10/11 21:30:44 cheshire
75 # Add "-Wunreachable-code" (commented out for now)
77 # Revision 1.62 2005/06/30 21:46:55 cheshire
78 # <rdar://problem/4167287> Solaris should use unix domain sockets, not loopback
80 # Revision 1.61 2005/06/30 20:46:05 cheshire
81 # Added Makefile rule to build threadsafe object files where necessary using "-D_REENTRANT".
83 # Revision 1.60 2005/06/30 10:42:38 cheshire
84 # Turn on "-Werror" and "-O" for better error reporting
86 # Revision 1.59 2005/04/14 21:07:10 rpantos
87 # Bug #: 4089257, Clean build broken for Java support on POSIX
88 # Submitted by: Roger Pantos
89 # Reviewed by: Kiren Sekar
91 # Revision 1.58 2005/04/08 21:37:57 ksekar
92 # <rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
94 # Revision 1.57 2005/03/17 04:02:28 cheshire
95 # <rdar://problem/3986419> mDNSResponder won't compile with gcc4 on Tiger
96 # Changed Makefile to link using gcc instead of libtool
98 # Revision 1.56 2005/02/02 02:25:21 cheshire
99 # <rdar://problem/3980388> /var/run/mDNSResponder should be /var/run/mdnsd on Linux
101 # Revision 1.55 2005/01/27 22:55:00 cheshire
102 # Add "make os=tiger" target which uses gcc4 and "-Wdeclaration-after-statement"
104 # Revision 1.54 2004/12/17 19:33:03 cheshire
105 # Add "-lresolv" for Solaris
107 # Revision 1.53 2004/12/01 20:04:31 cheshire
110 # Revision 1.52 2004/12/01 19:46:12 cheshire
111 # Add install case for Suse 9 (rc*.d directories *inside* the init.d directory)
113 # Revision 1.51 2004/12/01 03:30:29 cheshire
114 # <rdar://problem/3889346> Add Unicast DNS support to mDNSPosix
116 # Revision 1.50 2004/12/01 01:14:20 cheshire
117 # Add $(LIBFLAGS) to cc command to build dnsextd (required for Solaris)
119 # Revision 1.49 2004/11/11 01:44:52 cheshire
120 # Updated error message
122 # Revision 1.48 2004/10/06 02:22:19 cheshire
123 # Changed MacRoman copyright symbol (should have been UTF-8 in any case :-) to ASCII-compatible "(c)"
125 # Revision 1.47 2004/10/01 22:15:54 rpantos
126 # rdar://problem/3824265: Replace APSL in client lib with BSD license.
128 # Revision 1.46 2004/09/24 21:15:25 cheshire
129 # <rdar://problem/3724985> Library "libmdns" misnamed; should be "libdns_sd"
131 # Revision 1.45 2004/09/22 16:23:41 cheshire
132 # Modify installation for compatibility with Gentoo Linux
133 # (Thanks to David Black for this information)
135 # Revision 1.44 2004/09/17 01:08:53 cheshire
136 # Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
137 # The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
138 # declared in that file are ONLY appropriate to single-address-space embedded applications.
139 # For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
141 # Revision 1.43 2004/09/17 00:30:11 cheshire
142 # Added some '@' signs to make build output less verbose --
143 # when there's too much on the screen it's easy to miss build errors and warnings
145 # Revision 1.42 2004/08/24 22:04:37 cheshire
146 # Need to specify -lpthread for building dnsextd
148 # Revision 1.41 2004/08/11 00:43:26 ksekar
149 # <rdar://problem/3722542>: DNS Extension daemon for DNS Update Lease
151 # Revision 1.40 2004/07/08 21:45:55 cheshire
152 # Make nss_mdns only build on Linux. We can add it to other targets (Solaris,
153 # FreeBSD, etc., as we verify them). In particular, NSS is NOT supported on
154 # OS X, so including it for "os=jaguar" or "os=panther" broke those builds.
156 # Revision 1.39 2004/06/29 03:34:28 cheshire
157 # Add 'dot-local' Name Service Switch support from Andrew White at NICTA
159 # Revision 1.38 2004/06/25 02:19:40 rpantos
162 # Revision 1.37 2004/06/25 00:51:09 rpantos
163 # And fix the Java build for Posix on Solaris, too.
165 # Revision 1.36 2004/06/25 00:26:27 rpantos
166 # Changes to fix the Posix build on Solaris.
168 # Revision 1.35 2004/06/18 18:51:31 cheshire
169 # Add (commented out) "-pedantic" for when we want to check for "mixed declarations and code" warnings
171 # Revision 1.34 2004/05/25 18:29:33 cheshire
172 # Move DNSServiceConstructFullName() from dnssd_clientstub.c to dnssd_clientlib.c,
173 # so that it's also accessible to dnssd_clientshim.c (single address space) clients.
175 # Revision 1.33 2004/04/30 16:46:32 rpantos
176 # Add support for building Java libraries.
178 # Revision 1.32 2004/04/14 23:09:29 ksekar
179 # Support for TSIG signed dynamic updates.
181 # Revision 1.31 2004/03/15 19:07:06 cheshire
184 # Revision 1.30 2004/03/11 18:58:29 rpantos
185 # Fix Kill /etc/rc scripts so they run at halt & reboot.
187 # Revision 1.29 2004/03/04 23:35:41 cheshire
188 # Instead of using a dummy target to generate an error message, use "$(error text...)"
190 # Revision 1.28 2004/03/04 23:33:42 cheshire
191 # Fixes from Alfred Perlstein for FreeBSD's benefit
193 # Revision 1.27 2004/02/11 21:00:21 cheshire
194 # Update URL for GNU Make manual page
196 # Revision 1.26 2004/02/05 21:28:30 cheshire
197 # Fixes so that "sudo make install" works on *BSD
199 # Revision 1.25 2004/02/05 20:00:22 cheshire
200 # Define mdnsd's PID file to be /var/run/mdnsd.pid on Posix builds
202 # Revision 1.24 2004/02/05 01:00:01 rpantos
203 # Fix some issues that turned up when building for FreeBSD.
205 # Revision 1.23 2004/02/04 01:50:54 cheshire
206 # Make InstalledStartup conditional, so it automatically installs into
207 # either /etc/init.d/ or /etc/rc.d/init.d/ as appropriate
209 # Revision 1.22 2004/01/20 01:41:21 rpantos
210 # Define USES_NETLINK for Linux builds.
212 # Revision 1.21 2003/12/17 00:51:22 cheshire
213 # Changed mDNSNetMonitor and mDNSIdentify to link the object files
214 # instead of #including the "DNSCommon.c" "uDNS.c" and source files
216 # Revision 1.20 2003/12/13 03:05:28 ksekar
217 # Bug #: <rdar://problem/3192548>: DynDNS: Unicast query of service records
219 # Revision 1.19 2003/12/11 19:42:13 cheshire
220 # Change name "mDNSResponderd" to "mdnsd" for consistency with standard Linux (Unix) naming conventions
222 # Revision 1.18 2003/12/11 19:38:34 cheshire
225 # Revision 1.17 2003/12/11 03:16:49 rpantos
226 # One more change for OS X build: make install work a little better.
228 # Revision 1.16 2003/12/11 03:03:51 rpantos
229 # Clean up mDNSPosix so that it builds on OS X again.
231 # Revision 1.15 2003/12/08 20:47:02 rpantos
232 # Add support for mDNSResponder on Linux.
234 # Revision 1.14 2003/11/14 20:59:09 cheshire
235 # Clients can't use AssignDomainName macro because mDNSPlatformMemCopy is defined in mDNSPlatformFunctions.h.
236 # Best solution is just to combine mDNSEmbeddedAPI.h and mDNSPlatformFunctions.h into a single file.
238 # Revision 1.13 2003/08/06 18:20:51 cheshire
241 # Revision 1.12 2003/08/01 02:20:02 cheshire
242 # Add mDNSIdentify tool, used to discover what version of mDNSResponder a particular host is running
244 # Revision 1.11 2003/07/14 18:11:54 cheshire
245 # Fix stricter compiler warnings
247 # Revision 1.10 2003/06/18 05:47:41 cheshire
248 # Enable stricter warnings on Jaguar and Panther builds
250 # Revision 1.9 2003/06/04 18:34:45 ksekar
251 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
252 # Changed build targets "osx10.2" and "osx10.3" to "jaguar" and "panther".
254 # Revision 1.8 2003/06/04 00:23:12 ksekar
255 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
256 # Created separate target OS's for 10.2 and 10.3.
258 # Revision 1.7 2003/04/16 02:11:37 cheshire
259 # Remove unnecessary $(CFLAGS) from linking rules
261 # Revision 1.6 2003/04/04 01:37:14 cheshire
265 # This Makefile builds an mDNSResponder daemon and a libdns_sd.so shared library
266 # for Linux. It also builds several example programs for embedded systems.
268 # Make with no arguments to build all production targets.
269 # 'make DEBUG=1' to build debugging targets.
270 # 'make clean' or 'make clean DEBUG=1' to delete prod/debug objects & targets
271 # 'sudo make install [DEBUG=1]' to install mdnsd daemon and libdns_sd.
274 # $@ means "The file name of the target of the rule"
275 # $< means "The name of the first prerequisite"
276 # $* means "The stem with which an implicit rule matches"
277 # $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
278 # For more magic automatic variables, see
279 # <http://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html>
281 #############################################################################
285 COREDIR = ../mDNSCore
286 SHAREDDIR = ../mDNSShared
296 CFLAGS_COMMON = -I. -I$(COREDIR) -I$(SHAREDDIR) -I$(OBJDIR) -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
299 LINKOPTS_PTHREAD = -lpthread
301 JAVACFLAGS_OS = -fPIC -shared -ldns_sd
303 # Set up diverging paths for debug vs. prod builds
306 CFLAGS_DEBUG = -g -DMDNS_DEBUGMSGS=2
307 OBJDIR = objects/debug
308 BUILDDIR = build/debug
311 # We use -Os for two reasons:
312 # 1. We want to make small binaries, suitable for putting into hardware devices
313 # 2. Some of the code analysis warnings only work when some form of optimization is enabled
314 CFLAGS_DEBUG = -Os -DMDNS_DEBUGMSGS=0
315 OBJDIR = objects/prod
316 BUILDDIR = build/prod
320 # Configure per-OS peculiarities
322 CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
323 -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME
326 LINKOPTS = -lsocket -lnsl -lresolv
327 JAVACFLAGS_OS += -I$(JDK)/include/solaris
334 CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX
336 JAVACFLAGS_OS += -I$(JDK)/include/linux
337 OPTIONALTARG = nss_mdns
338 OPTINSTALL = InstalledNSS
347 # If not already defined, set LOCALBASE to /usr/local
348 # FreeBSD requires the startup script to end in ".sh"
349 LOCALBASE?=/usr/local
350 INSTBASE=$(LOCALBASE)
351 STARTUPSCRIPTNAME=mdns.sh
353 # FreeBSD 4 requires threaded code to be compiled and linked using the "-pthread" option,
354 # and requires that the "-lpthread" link option NOT be used
355 # This appies only to FreeBSD -- "man cc" on FreeBSD says:
356 # FreeBSD SPECIFIC OPTIONS
358 # Link a user-threaded process against libc_r instead of libc.
359 CFLAGS_PTHREAD = -pthread -D_THREAD_SAFE
360 LINKOPTS_PTHREAD = -pthread
361 JAVACFLAGS_OS += -I$(JDK)/include/freebsd
366 CFLAGS_OS = -DHAVE_BROKEN_RECVDSTADDR
371 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -DNOT_HAVE_SOCKLEN_T
372 LD = libtool -dynamic
375 JDK = /System/Library/Frameworks/JavaVM.framework/Home
376 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
380 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror
381 LD = libtool -dynamic
384 JDK = /System/Library/Frameworks/JavaVM.framework/Home
385 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
389 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement #-Wunreachable-code
391 LD = $(CC) -dynamiclib
394 JDK = /System/Library/Frameworks/JavaVM.framework/Home
395 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
398 $(error ERROR: Must specify target OS on command-line, e.g. "make os=tiger [target]".\
399 Supported operating systems include: jaguar, panther, tiger, linux, netbsd, freebsd, openbsd, solaris)
409 NSSLIBNAME := libnss_mdns
411 NSSLIBFILE := $(NSSLIBNAME)-$(NSSVERSION).so
412 NSSLINKNAME := $(NSSLIBNAME).so.2
415 # If not otherwise defined, we install into /usr/lib and /usr/include
416 # and our startup script is called mdns (e.g. /etc/init.d/mdns)
418 STARTUPSCRIPTNAME?=mdns
420 ifeq ($(HAVE_IPV6),1)
421 CFLAGS_OS += -DHAVE_IPV6=1
423 ifeq ($(HAVE_IPV6),0)
424 CFLAGS_OS += -DHAVE_IPV6=0
428 # If directory /usr/share/man exists, then we install man pages into that, else /usr/man
429 ifeq ($(wildcard /usr/share/man), /usr/share/man)
430 MANPATH := /usr/share/man
435 # If directories /etc/init.d/rc*.d exist, then we install into that (Suse)
436 ifeq ($(wildcard /etc/init.d/rc2.d/), /etc/init.d/rc2.d/)
437 STARTUPSCRIPTDIR = /etc/init.d
438 RUNLEVELSCRIPTSDIR = /etc/init.d
440 # else if directory /etc/rc.d/init.d/ exists, then we install into that (old Linux)
441 ifeq ($(wildcard /etc/rc.d/init.d/), /etc/rc.d/init.d/)
442 STARTUPSCRIPTDIR = /etc/rc.d/init.d
443 RUNLEVELSCRIPTSDIR = /etc/rc.d
445 # else if directory /etc/init.d/ exists, then we install into that (new Linux)
446 ifeq ($(wildcard /etc/init.d/), /etc/init.d/)
447 STARTUPSCRIPTDIR = /etc/init.d
448 RUNLEVELSCRIPTSDIR = /etc
450 # else install into /etc/rc.d/ (*BSD)
451 STARTUPSCRIPTDIR = $(INSTBASE)/etc/rc.d
456 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUG)
458 #############################################################################
460 all: setup Daemon libdns_sd Clients SAClient SAResponder SAProxyResponder Identify NetMonitor dnsextd $(OPTIONALTARG)
462 install: setup InstalledDaemon InstalledStartup InstalledLib InstalledManPages InstalledClients $(OPTINSTALL)
464 # 'setup' sets up the build directory structure the way we want
466 @if test ! -d objects ; then mkdir objects ; fi
467 @if test ! -d build ; then mkdir build ; fi
468 @if test ! -d $(OBJDIR) ; then mkdir $(OBJDIR) ; fi
469 @if test ! -d $(BUILDDIR) ; then mkdir $(BUILDDIR) ; fi
471 # clean removes targets and objects
473 @if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
474 @if test -d $(BUILDDIR) ; then rm -r $(BUILDDIR) ; fi
475 @$(MAKE) -C ../Clients clean
477 #############################################################################
479 # daemon target builds the daemon
480 DAEMONOBJS = $(OBJDIR)/PosixDaemon.c.o $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNS.c.o \
481 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/uds_daemon.c.o \
482 $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/dnssd_ipc.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/PlatformCommon.c.o
484 # dnsextd target build dnsextd
485 DNSEXTDOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/DNSDigest.c.o \
486 $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/PlatformCommon.c.o $(OBJDIR)/dnsextd_parser.y.o $(OBJDIR)/dnsextd_lexer.l.o
488 Daemon: setup $(BUILDDIR)/mdnsd
489 @echo "Responder daemon done"
491 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
492 $(CC) -o $@ $+ $(LINKOPTS)
495 # libdns_sd target builds the client library
496 libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
497 @echo "Client library done"
499 CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
501 $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
502 @$(LD) $(LINKOPTS) -o $@ $+
505 Clients: setup libdns_sd ../Clients/build/dns-sd
508 ../Clients/build/dns-sd:
509 @$(MAKE) -C ../Clients
511 # nss_mdns target builds the Name Service Switch module
512 nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)
513 @echo "Name Service Switch module done"
515 $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
516 @$(LD) $(LINKOPTS) -o $@ $+
519 #############################################################################
521 # The Install targets place built stuff in their proper places
522 InstalledDaemon: $(INSTBASE)/sbin/mdnsd
523 @echo $+ " installed"
525 InstalledLib: $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
526 @echo $+ " installed"
528 InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
529 @echo $+ " installed"
531 InstalledManPages: $(MANPATH)/man8/mdnsd.8
532 @echo $+ " installed"
534 InstalledClients: $(INSTBASE)/bin/dns-sd
535 @echo $+ " installed"
537 InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
538 @echo $+ " installed"
540 # Note: If daemon already installed, we make sure it's stopped before overwriting it
541 $(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd
542 @if test -x $@; then $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) stop; fi
545 $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
547 $(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
549 # -m means 'merge into existing database', -R means 'rescan directories'
553 $(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
556 # We make this target dependent on $(INSTBASE)/sbin/mdnsd because we need to ensure
557 # that the daemon is installed *before* we try to execute the command to start it.
558 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR) $(INSTBASE)/sbin/mdnsd
562 ifdef RUNLEVELSCRIPTSDIR
563 ifeq ($(wildcard $(RUNLEVELSCRIPTSDIR)/runlevels/default), $(RUNLEVELSCRIPTSDIR)/runlevels/default)
564 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/runlevels/default/mdns
566 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc2.d/S52mdns
567 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc3.d/S52mdns
568 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc4.d/S52mdns
569 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc5.d/S52mdns
570 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc0.d/K16mdns
571 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc6.d/K16mdns
575 $(MANPATH)/man5/%.5: %.5
579 $(MANPATH)/man8/%.8: %.8
583 $(MANPATH)/man8/mdnsd.8: $(SHAREDDIR)/mDNSResponder.8
587 $(INSTBASE)/bin/dns-sd: ../Clients/build/dns-sd
590 $(NSSINSTPATH)/$(NSSLINKNAME): $(NSSINSTPATH)/$(NSSLIBFILE)
594 $(NSSINSTPATH)/$(NSSLIBFILE): $(BUILDDIR)/$(NSSLIBFILE)
598 /etc/nss_mdns.conf: nss_mdns.conf
601 # Check the nsswitch.conf file.
602 # If 'mdns' does not already appear on the "hosts:" line, then add it right before 'dns'
603 cp -f /etc/nsswitch.conf /etc/nsswitch.conf.pre-mdns
604 sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' /etc/nsswitch.conf.pre-mdns > /etc/nsswitch.conf
606 #############################################################################
608 # The following targets build Java wrappers for the dns-sd.h API.
610 JAVAC = $(JDK)/bin/javac
611 JAVAH = $(JDK)/bin/javah
612 JAVADOC = $(JDK)/bin/javadoc
614 JAVACFLAGS = $(CFLAGS) $(JAVACFLAGS_OS) -I$(JDK)/include
616 Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
617 @echo "Java wrappers done"
619 JAVASRC = $(SHAREDDIR)/Java
620 JARCONTENTS = $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
621 $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
622 $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
623 $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
624 $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
625 $(OBJDIR)/com/apple/dnssd/BaseListener.class \
626 $(OBJDIR)/com/apple/dnssd/BrowseListener.class \
627 $(OBJDIR)/com/apple/dnssd/ResolveListener.class \
628 $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
629 $(OBJDIR)/com/apple/dnssd/QueryListener.class \
630 $(OBJDIR)/com/apple/dnssd/DomainListener.class \
631 $(OBJDIR)/com/apple/dnssd/RegisterRecordListener.class \
632 $(OBJDIR)/com/apple/dnssd/DNSSDRecordRegistrar.class \
633 $(OBJDIR)/com/apple/dnssd/DNSSD.class
635 $(BUILDDIR)/dns_sd.jar: $(JARCONTENTS) setup
636 $(JAR) -cf $@ -C $(OBJDIR) com
638 $(BUILDDIR)/libjdns_sd.$(LDSUFFIX): $(JAVASRC)/JNISupport.c $(OBJDIR)/DNSSD.java.h setup libdns_sd
639 $(CC) -o $@ $< $(JAVACFLAGS) -I$(OBJDIR) -L$(BUILDDIR)
641 $(OBJDIR)/com/apple/dnssd/%.class: $(JAVASRC)/%.java
642 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
644 $(OBJDIR)/DNSSD.java.h: $(OBJDIR)/com/apple/dnssd/DNSSD.class
645 $(JAVAH) -force -classpath $(OBJDIR) -o $@ \
646 com.apple.dnssd.AppleDNSSD \
647 com.apple.dnssd.AppleBrowser \
648 com.apple.dnssd.AppleResolver \
649 com.apple.dnssd.AppleRegistration \
650 com.apple.dnssd.AppleQuery \
651 com.apple.dnssd.AppleDomainEnum \
652 com.apple.dnssd.AppleService
654 #############################################################################
656 # The following target builds documentation for the Java wrappers.
659 $(JAVADOC) $(JAVASRC)/*.java -classpath $(OBJDIR) -d $(BUILDDIR) -public
661 #############################################################################
663 # The following targets build embedded example programs
664 SPECIALOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o
665 COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
666 APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
668 SAClient: setup $(BUILDDIR)/mDNSClientPosix
669 @echo "Embedded Standalone Client done"
671 SAResponder: setup $(BUILDDIR)/mDNSResponderPosix
672 @echo "Embedded Standalone Responder done"
674 SAProxyResponder: setup $(BUILDDIR)/mDNSProxyResponderPosix
675 @echo "Embedded Standalone ProxyResponder done"
677 Identify: setup $(BUILDDIR)/mDNSIdentify
678 @echo "Identify done"
680 NetMonitor: setup $(BUILDDIR)/mDNSNetMonitor
681 @echo "NetMonitor done"
683 dnsextd: setup $(BUILDDIR)/dnsextd
686 $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
687 $(CC) $+ -o $@ $(LINKOPTS)
689 $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
690 $(CC) $+ -o $@ $(LINKOPTS)
692 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o
693 $(CC) $+ -o $@ $(LINKOPTS)
695 $(BUILDDIR)/mDNSIdentify: $(SPECIALOBJ) $(OBJDIR)/Identify.c.o
696 $(CC) $+ -o $@ $(LINKOPTS)
698 $(OBJDIR)/Identify.c.o: $(COREDIR)/mDNS.c # Note: Identify.c textually imports mDNS.c
700 $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
701 $(CC) $+ -o $@ $(LINKOPTS)
703 $(OBJDIR)/NetMonitor.c.o: $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c
705 $(BUILDDIR)/dnsextd: $(DNSEXTDOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o
706 $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD)
708 #############################################################################
712 $(CC) $(CFLAGS) -c -o $@ $<
714 $(OBJDIR)/%.c.o: $(COREDIR)/%.c
715 $(CC) $(CFLAGS) -c -o $@ $<
717 $(OBJDIR)/%.c.o: $(SHAREDDIR)/%.c
718 $(CC) $(CFLAGS) -c -o $@ $<
720 $(OBJDIR)/%.c.threadsafe.o: %.c
721 $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
723 $(OBJDIR)/%.c.threadsafe.o: $(SHAREDDIR)/%.c
724 $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
726 $(OBJDIR)/%.c.so.o: %.c
727 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
729 $(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
730 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
732 $(OBJDIR)/%.y.o: $(SHAREDDIR)/%.y
733 $(BISON) -o $(OBJDIR)/$*.c -d $<
734 $(CC) $(CFLAGS) -c -o $@ $(OBJDIR)/$*.c
736 $(OBJDIR)/%.l.o: $(SHAREDDIR)/%.l
737 $(FLEX) $(FLEXFLAGS_OS) -i -o$(OBJDIR)/$*.l.c $<
738 $(CC) $(CFLAGS) -Wno-error -c -o $@ $(OBJDIR)/$*.l.c