]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSPosix/Makefile
mDNSResponder-107.3.tar.gz
[apple/mdnsresponder.git] / mDNSPosix / Makefile
1 # Copyright (c) 2002-2004, Apple Computer, Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
5 #
6 # 1. Redistributions of source code must retain the above copyright notice,
7 # this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright notice,
9 # this list of conditions and the following disclaimer in the documentation
10 # and/or other materials provided with the distribution.
11 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
12 # contributors may be used to endorse or promote products derived from this
13 # software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #
26 # $Log: Makefile,v $
27 # Revision 1.56 2005/02/02 02:25:21 cheshire
28 # <rdar://problem/3980388> /var/run/mDNSResponder should be /var/run/mdnsd on Linux
29 #
30 # Revision 1.55 2005/01/27 22:55:00 cheshire
31 # Add "make os=tiger" target which uses gcc4 and "-Wdeclaration-after-statement"
32 #
33 # Revision 1.54 2004/12/17 19:33:03 cheshire
34 # Add "-lresolv" for Solaris
35 #
36 # Revision 1.53 2004/12/01 20:04:31 cheshire
37 # Tidy up alignment
38 #
39 # Revision 1.52 2004/12/01 19:46:12 cheshire
40 # Add install case for Suse 9 (rc*.d directories *inside* the init.d directory)
41 #
42 # Revision 1.51 2004/12/01 03:30:29 cheshire
43 # <rdar://problem/3889346> Add Unicast DNS support to mDNSPosix
44 #
45 # Revision 1.50 2004/12/01 01:14:20 cheshire
46 # Add $(LIBFLAGS) to cc command to build dnsextd (required for Solaris)
47 #
48 # Revision 1.49 2004/11/11 01:44:52 cheshire
49 # Updated error message
50 #
51 # Revision 1.48 2004/10/06 02:22:19 cheshire
52 # Changed MacRoman copyright symbol (should have been UTF-8 in any case :-) to ASCII-compatible "(c)"
53 #
54 # Revision 1.47 2004/10/01 22:15:54 rpantos
55 # rdar://problem/3824265: Replace APSL in client lib with BSD license.
56 #
57 # Revision 1.46 2004/09/24 21:15:25 cheshire
58 # <rdar://problem/3724985> Library "libmdns" misnamed; should be "libdns_sd"
59 #
60 # Revision 1.45 2004/09/22 16:23:41 cheshire
61 # Modify installation for compatibility with Gentoo Linux
62 # (Thanks to David Black for this information)
63 #
64 # Revision 1.44 2004/09/17 01:08:53 cheshire
65 # Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
66 # The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
67 # declared in that file are ONLY appropriate to single-address-space embedded applications.
68 # For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
69 #
70 # Revision 1.43 2004/09/17 00:30:11 cheshire
71 # Added some '@' signs to make build output less verbose --
72 # when there's too much on the screen it's easy to miss build errors and warnings
73 #
74 # Revision 1.42 2004/08/24 22:04:37 cheshire
75 # Need to specify -lpthread for building dnsextd
76 #
77 # Revision 1.41 2004/08/11 00:43:26 ksekar
78 # <rdar://problem/3722542>: DNS Extension daemon for DNS Update Lease
79 #
80 # Revision 1.40 2004/07/08 21:45:55 cheshire
81 # Make nss_mdns only build on Linux. We can add it to other targets (Solaris,
82 # FreeBSD, etc., as we verify them). In particular, NSS is NOT supported on
83 # OS X, so including it for "os=jaguar" or "os=panther" broke those builds.
84 #
85 # Revision 1.39 2004/06/29 03:34:28 cheshire
86 # Add 'dot-local' Name Service Switch support from Andrew White at NICTA
87 #
88 # Revision 1.38 2004/06/25 02:19:40 rpantos
89 # And FreeBSD...
90 #
91 # Revision 1.37 2004/06/25 00:51:09 rpantos
92 # And fix the Java build for Posix on Solaris, too.
93 #
94 # Revision 1.36 2004/06/25 00:26:27 rpantos
95 # Changes to fix the Posix build on Solaris.
96 #
97 # Revision 1.35 2004/06/18 18:51:31 cheshire
98 # Add (commented out) "-pedantic" for when we want to check for "mixed declarations and code" warnings
99 #
100 # Revision 1.34 2004/05/25 18:29:33 cheshire
101 # Move DNSServiceConstructFullName() from dnssd_clientstub.c to dnssd_clientlib.c,
102 # so that it's also accessible to dnssd_clientshim.c (single address space) clients.
103 #
104 # Revision 1.33 2004/04/30 16:46:32 rpantos
105 # Add support for building Java libraries.
106 #
107 # Revision 1.32 2004/04/14 23:09:29 ksekar
108 # Support for TSIG signed dynamic updates.
109 #
110 # Revision 1.31 2004/03/15 19:07:06 cheshire
111 # Fix error message
112 #
113 # Revision 1.30 2004/03/11 18:58:29 rpantos
114 # Fix Kill /etc/rc scripts so they run at halt & reboot.
115 #
116 # Revision 1.29 2004/03/04 23:35:41 cheshire
117 # Instead of using a dummy target to generate an error message, use "$(error text...)"
118 #
119 # Revision 1.28 2004/03/04 23:33:42 cheshire
120 # Fixes from Alfred Perlstein for FreeBSD's benefit
121 #
122 # Revision 1.27 2004/02/11 21:00:21 cheshire
123 # Update URL for GNU Make manual page
124 #
125 # Revision 1.26 2004/02/05 21:28:30 cheshire
126 # Fixes so that "sudo make install" works on *BSD
127 #
128 # Revision 1.25 2004/02/05 20:00:22 cheshire
129 # Define mdnsd's PID file to be /var/run/mdnsd.pid on Posix builds
130 #
131 # Revision 1.24 2004/02/05 01:00:01 rpantos
132 # Fix some issues that turned up when building for FreeBSD.
133 #
134 # Revision 1.23 2004/02/04 01:50:54 cheshire
135 # Make InstalledStartup conditional, so it automatically installs into
136 # either /etc/init.d/ or /etc/rc.d/init.d/ as appropriate
137 #
138 # Revision 1.22 2004/01/20 01:41:21 rpantos
139 # Define USES_NETLINK for Linux builds.
140 #
141 # Revision 1.21 2003/12/17 00:51:22 cheshire
142 # Changed mDNSNetMonitor and mDNSIdentify to link the object files
143 # instead of #including the "DNSCommon.c" "uDNS.c" and source files
144 #
145 # Revision 1.20 2003/12/13 03:05:28 ksekar
146 # Bug #: <rdar://problem/3192548>: DynDNS: Unicast query of service records
147 #
148 # Revision 1.19 2003/12/11 19:42:13 cheshire
149 # Change name "mDNSResponderd" to "mdnsd" for consistency with standard Linux (Unix) naming conventions
150 #
151 # Revision 1.18 2003/12/11 19:38:34 cheshire
152 # Add APSL
153 #
154 # Revision 1.17 2003/12/11 03:16:49 rpantos
155 # One more change for OS X build: make install work a little better.
156 #
157 # Revision 1.16 2003/12/11 03:03:51 rpantos
158 # Clean up mDNSPosix so that it builds on OS X again.
159 #
160 # Revision 1.15 2003/12/08 20:47:02 rpantos
161 # Add support for mDNSResponder on Linux.
162 #
163 # Revision 1.14 2003/11/14 20:59:09 cheshire
164 # Clients can't use AssignDomainName macro because mDNSPlatformMemCopy is defined in mDNSPlatformFunctions.h.
165 # Best solution is just to combine mDNSEmbeddedAPI.h and mDNSPlatformFunctions.h into a single file.
166 #
167 # Revision 1.13 2003/08/06 18:20:51 cheshire
168 # Makefile cleanup
169 #
170 # Revision 1.12 2003/08/01 02:20:02 cheshire
171 # Add mDNSIdentify tool, used to discover what version of mDNSResponder a particular host is running
172 #
173 # Revision 1.11 2003/07/14 18:11:54 cheshire
174 # Fix stricter compiler warnings
175 #
176 # Revision 1.10 2003/06/18 05:47:41 cheshire
177 # Enable stricter warnings on Jaguar and Panther builds
178 #
179 # Revision 1.9 2003/06/04 18:34:45 ksekar
180 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
181 # Changed build targets "osx10.2" and "osx10.3" to "jaguar" and "panther".
182 #
183 # Revision 1.8 2003/06/04 00:23:12 ksekar
184 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
185 # Created separate target OS's for 10.2 and 10.3.
186 #
187 # Revision 1.7 2003/04/16 02:11:37 cheshire
188 # Remove unnecessary $(CFLAGS) from linking rules
189 #
190 # Revision 1.6 2003/04/04 01:37:14 cheshire
191 # Added NetMonitor.c
192 #
193
194 # This Makefile builds an mDNSResponder daemon and a libdns_sd.so shared library
195 # for Linux. It also builds several example programs for embedded systems.
196 #
197 # Make with no arguments to build all production targets.
198 # 'make DEBUG=1' to build debugging targets.
199 # 'make clean' or 'make clean DEBUG=1' to delete prod/debug objects & targets
200 # 'sudo make install [DEBUG=1]' to install mdnsd daemon and libdns_sd.
201 #
202 # Notes:
203 # $@ means "The file name of the target of the rule"
204 # $< means "The name of the first prerequisite"
205 # $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
206 # For more magic automatic variables, see
207 # <http://www.gnu.org/software/make/manual/html_chapter/make_10.html#SEC111>
208
209 #############################################################################
210
211 LIBVERS = 1
212
213 COREDIR = ../mDNSCore
214 SHAREDDIR = ../mDNSShared
215 JDK = /usr/jdk
216
217 CC = @cc
218 LD = ld -shared
219 CP = cp
220 RM = rm
221 LN = ln -s -f
222 CFLAGS_COMMON = -I. -I$(COREDIR) -I$(SHAREDDIR) -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
223 LIBFLAGS =
224 DNSEXT_FLAGS = -D_REENTRANT -g -Wall -lpthread
225 LDSUFFIX = so
226 JAVACFLAGS_OS = -fPIC -shared -ldns_sd
227
228 # Set up diverging paths for debug vs. prod builds
229 DEBUG=0
230 ifeq ($(DEBUG),1)
231 CFLAGS_DEBUG = -g -DMDNS_DEBUGMSGS=2
232 OBJDIR = objects/debug
233 BUILDDIR = build/debug
234 STRIP = echo
235 else
236 CFLAGS_DEBUG = -O0 -DMDNS_DEBUGMSGS=0
237 OBJDIR = objects/prod
238 BUILDDIR = build/prod
239 STRIP = strip -S
240 endif
241
242 # Configure per-OS peculiarities
243 ifeq ($(os),solaris)
244 CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
245 -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME -DUSE_TCP_LOOPBACK
246 CC = gcc
247 LD = gcc -shared
248 LIBFLAGS = -lsocket -lnsl -lresolv
249 JAVACFLAGS_OS += -I$(JDK)/include/solaris
250 ifneq ($(DEBUG),1)
251 STRIP = strip
252 endif
253 else
254
255 ifeq ($(os),linux)
256 CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK
257 JAVACFLAGS_OS += -I$(JDK)/include/linux
258 OPTIONALTARG = nss_mdns
259 OPTINSTALL = InstalledNSS
260 else
261
262 ifeq ($(os),netbsd)
263 CFLAGS_OS =
264 LDCONFIG = ldconfig
265 else
266
267 ifeq ($(os),freebsd)
268 # If not already defined, set LOCALBASE to /usr/local
269 # FreeBSD requires the startup script to end in ".sh"
270 LOCALBASE?=/usr/local
271 INSTBASE=$(LOCALBASE)
272 STARTUPSCRIPTNAME=mdns.sh
273 CFLAGS_OS =
274 JAVACFLAGS_OS += -I$(JDK)/include/freebsd
275 LDCONFIG = ldconfig
276 else
277
278 ifeq ($(os),openbsd)
279 CFLAGS_OS = -DHAVE_BROKEN_RECVDSTADDR
280 LDCONFIG = ldconfig
281 else
282
283 ifeq ($(os),jaguar)
284 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -DNOT_HAVE_SOCKLEN_T
285 LD = libtool -dynamic
286 LIBFLAGS = -lSystem
287 LDSUFFIX = dylib
288 JDK = /System/Library/Frameworks/JavaVM.framework/Home
289 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
290 else
291
292 ifeq ($(os),panther)
293 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp #-pedantic
294 LD = libtool -dynamic
295 LIBFLAGS = -lSystem
296 LDSUFFIX = dylib
297 JDK = /System/Library/Frameworks/JavaVM.framework/Home
298 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
299 else
300
301 ifeq ($(os),tiger)
302 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Wdeclaration-after-statement
303 CC = @gcc-4.0
304 LD = libtool -dynamic
305 LIBFLAGS = -lSystem
306 LDSUFFIX = dylib
307 JDK = /System/Library/Frameworks/JavaVM.framework/Home
308 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
309 else
310
311 $(error ERROR: Must specify target OS on command-line, e.g. "make os=tiger [target]".\
312 Supported operating systems include: jaguar, panther, linux, netbsd, freebsd, openbsd, solaris)
313 endif
314 endif
315 endif
316 endif
317 endif
318 endif
319 endif
320 endif
321
322 NSSLIBNAME := libnss_mdns
323 NSSVERSION := 0.2
324 NSSLIBFILE := $(NSSLIBNAME)-$(NSSVERSION).so
325 NSSLINKNAME := $(NSSLIBNAME).so.2
326 NSSINSTPATH := /lib
327
328 # If not otherwise defined, we install into /usr/lib and /usr/include
329 # and our startup script is called mdns (e.g. /etc/init.d/mdns)
330 INSTBASE?=/usr
331 STARTUPSCRIPTNAME?=mdns
332
333 ifeq ($(HAVE_IPV6),1)
334 CFLAGS_OS += -DHAVE_IPV6=1
335 else
336 ifeq ($(HAVE_IPV6),0)
337 CFLAGS_OS += -DHAVE_IPV6=0
338 endif
339 endif
340
341 # If directory /usr/share/man exists, then we install man pages into that, else /usr/man
342 ifeq ($(wildcard /usr/share/man), /usr/share/man)
343 MANPATH := /usr/share/man
344 else
345 MANPATH := /usr/man
346 endif
347
348 # If directories /etc/init.d/rc*.d exist, then we install into that (Suse)
349 ifeq ($(wildcard /etc/init.d/rc2.d/), /etc/init.d/rc2.d/)
350 STARTUPSCRIPTDIR = /etc/init.d
351 RUNLEVELSCRIPTSDIR = /etc/init.d
352 else
353 # else if directory /etc/rc.d/init.d/ exists, then we install into that (old Linux)
354 ifeq ($(wildcard /etc/rc.d/init.d/), /etc/rc.d/init.d/)
355 STARTUPSCRIPTDIR = /etc/rc.d/init.d
356 RUNLEVELSCRIPTSDIR = /etc/rc.d
357 else
358 # else if directory /etc/init.d/ exists, then we install into that (new Linux)
359 ifeq ($(wildcard /etc/init.d/), /etc/init.d/)
360 STARTUPSCRIPTDIR = /etc/init.d
361 RUNLEVELSCRIPTSDIR = /etc
362 else
363 # else install into /etc/rc.d/ (*BSD)
364 STARTUPSCRIPTDIR = $(INSTBASE)/etc/rc.d
365 endif
366 endif
367 endif
368
369 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUG)
370
371 #############################################################################
372
373 all: setup Daemon libdns_sd Client Responder ProxyResponder Identify NetMonitor dnsextd $(OPTIONALTARG)
374
375 install: setup InstalledDaemon InstalledLib InstalledStartup InstalledManPages $(OPTINSTALL)
376
377 # 'setup' sets up the build directory structure the way we want
378 setup:
379 @if test ! -d objects ; then mkdir objects ; fi
380 @if test ! -d build ; then mkdir build ; fi
381 @if test ! -d $(OBJDIR) ; then mkdir $(OBJDIR) ; fi
382 @if test ! -d $(BUILDDIR) ; then mkdir $(BUILDDIR) ; fi
383
384 # clean removes targets and objects
385 clean:
386 if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
387 if test -d $(BUILDDIR) ; then rm -r $(BUILDDIR) ; fi
388
389 #############################################################################
390
391 # daemon target builds the daemon
392 DAEMONOBJS = $(OBJDIR)/PosixDaemon.c.o $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNS.c.o \
393 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/uds_daemon.c.o \
394 $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/dnssd_ipc.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/PlatformCommon.c.o
395
396 Daemon: setup $(BUILDDIR)/mdnsd
397 @echo "Responder daemon done"
398
399 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
400 $(CC) -o $@ $+ $(CFLAGS) $(LIBFLAGS)
401 @$(STRIP) $@
402
403 # libdns_sd target builds the client library
404 libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
405 @echo "Client library done"
406
407 CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
408
409 $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
410 @$(LD) $(LIBFLAGS) -o $@ $+
411 @$(STRIP) $@
412
413 # nss_mdns target builds the Name Service Switch module
414 nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)
415 @echo "Name Service Switch module done"
416
417 $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
418 @$(LD) $(LIBFLAGS) -o $@ $+
419 @$(STRIP) $@
420
421 #############################################################################
422
423 # The Install targets place built stuff in their proper places
424 InstalledDaemon: $(INSTBASE)/sbin/mdnsd
425 @echo $+ " installed"
426
427 InstalledLib: $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
428 @echo $+ " installed"
429
430 InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
431 @echo $+ " installed"
432
433 InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
434 @echo $+ " installed"
435
436 InstalledManPages: $(MANPATH)/man8/mdnsd.8
437 @echo $+ " installed"
438
439 $(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd
440 $(CP) $< $@
441
442 $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
443 $(CP) $< $@
444 $(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
445 ifdef LDCONFIG
446 # -m means 'merge into existing database', -R means 'rescan directories'
447 $(LDCONFIG) -mR
448 endif
449
450 $(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
451 $(CP) $< $@
452
453 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR)
454 $(CP) $< $@
455 chmod ugo+x $@
456 ifdef RUNLEVELSCRIPTSDIR
457 ifeq ($(wildcard $(RUNLEVELSCRIPTSDIR)/runlevels/default), $(RUNLEVELSCRIPTSDIR)/runlevels/default)
458 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/runlevels/default/mdns
459 else
460 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc2.d/S52mdns
461 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc3.d/S52mdns
462 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc4.d/S52mdns
463 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc5.d/S52mdns
464 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc0.d/K16mdns
465 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc6.d/K16mdns
466 endif
467 endif
468
469 $(NSSINSTPATH)/$(NSSLINKNAME): $(NSSINSTPATH)/$(NSSLIBFILE)
470 $(LN) $< $@
471 ldconfig
472
473 $(NSSINSTPATH)/$(NSSLIBFILE): $(BUILDDIR)/$(NSSLIBFILE)
474 $(CP) $< $@
475 chmod 444 $@
476
477 /etc/nss_mdns.conf: nss_mdns.conf
478 $(CP) $< $@
479 chmod 444 $@
480 # Check the nsswitch.conf file.
481 # If 'mdns' does not already appear on the "hosts:" line, then add it right before 'dns'
482 cp -f /etc/nsswitch.conf /etc/nsswitch.conf.pre-mdns
483 sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' /etc/nsswitch.conf.pre-mdns > /etc/nsswitch.conf
484
485 $(MANPATH)/man5/%.5: %.5
486 cp $< $@
487 chmod 444 $@
488
489 $(MANPATH)/man8/%.8: %.8
490 cp $< $@
491 chmod 444 $@
492
493 $(MANPATH)/man8/mdnsd.8: $(SHAREDDIR)/mDNSResponder.8
494 cp $< $@
495 chmod 444 $@
496
497 #############################################################################
498
499 # The following targets build Java wrappers for the dns-sd.h API.
500
501 JAVAC = $(JDK)/bin/javac
502 JAVAH = $(JDK)/bin/javah
503 JAVADOC = $(JDK)/bin/javadoc
504 JAR = $(JDK)/bin/jar
505 JAVACFLAGS = $(CFLAGS) $(JAVACFLAGS_OS) -I$(JDK)/include
506
507 Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
508 @echo "Java wrappers done"
509
510 JAVASRC = $(SHAREDDIR)/Java
511 JARCONTENTS = $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
512 $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
513 $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
514 $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
515 $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
516 $(OBJDIR)/com/apple/dnssd/BaseListener.class \
517 $(OBJDIR)/com/apple/dnssd/BrowseListener.class \
518 $(OBJDIR)/com/apple/dnssd/ResolveListener.class \
519 $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
520 $(OBJDIR)/com/apple/dnssd/QueryListener.class \
521 $(OBJDIR)/com/apple/dnssd/DomainListener.class \
522 $(OBJDIR)/com/apple/dnssd/DNSSD.class
523
524 $(BUILDDIR)/dns_sd.jar: $(JARCONTENTS)
525 $(JAR) -cf $@ -C $(OBJDIR) com
526
527 $(BUILDDIR)/libjdns_sd.$(LDSUFFIX): $(JAVASRC)/JNISupport.c $(OBJDIR)/DNSSD.java.h
528 $(CC) -o $@ $< $(JAVACFLAGS) -I$(OBJDIR)
529
530 $(OBJDIR)/com/apple/dnssd/%.class: $(JAVASRC)/%.java
531 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
532
533 $(OBJDIR)/DNSSD.java.h: $(OBJDIR)/com/apple/dnssd/DNSSD.class
534 $(JAVAH) -force -classpath $(OBJDIR) -o $@ \
535 com.apple.dnssd.AppleDNSSD \
536 com.apple.dnssd.AppleBrowser \
537 com.apple.dnssd.AppleResolver \
538 com.apple.dnssd.AppleRegistration \
539 com.apple.dnssd.AppleQuery \
540 com.apple.dnssd.AppleDomainEnum \
541 com.apple.dnssd.AppleService
542
543 #############################################################################
544
545 # The following target builds documentation for the Java wrappers.
546
547 JavaDoc: setup Java
548 $(JAVADOC) $(JAVASRC)/*.java -classpath $(OBJDIR) -d $(BUILDDIR) -public
549
550 #############################################################################
551
552 # The following targets build embedded example programs
553 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
554 COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
555 APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
556
557 Client: setup $(BUILDDIR)/mDNSClientPosix
558 @echo "Embedded Standalone Client done"
559
560 Responder: setup $(BUILDDIR)/mDNSResponderPosix
561 @echo "Embedded Standalone Responder done"
562
563 ProxyResponder: setup $(BUILDDIR)/mDNSProxyResponderPosix
564 @echo "Embedded Standalone ProxyResponder done"
565
566 Identify: setup $(BUILDDIR)/mDNSIdentify
567 @echo "Identify done"
568
569 NetMonitor: setup $(BUILDDIR)/mDNSNetMonitor
570 @echo "NetMonitor done"
571
572 dnsextd: setup $(BUILDDIR)/dnsextd
573 @echo "dnsextd done"
574
575 $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
576 $(CC) $+ -o $@ $(LIBFLAGS)
577
578 $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
579 $(CC) $+ -o $@ $(LIBFLAGS)
580
581 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o
582 $(CC) $+ -o $@ $(LIBFLAGS)
583
584 $(BUILDDIR)/mDNSIdentify: $(SPECIALOBJ) $(OBJDIR)/Identify.c.o
585 $(CC) $+ -o $@ $(LIBFLAGS)
586
587 $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
588 $(CC) $+ -o $@ $(LIBFLAGS)
589
590 $(BUILDDIR)/dnsextd: $(SPECIALOBJ) $(OBJDIR)/dnsextd.c.o
591 $(CC) $+ -o $@ $(LIBFLAGS) $(DNSEXT_FLAGS)
592
593 #############################################################################
594
595 # Implicit rules
596 $(OBJDIR)/%.c.o: %.c
597 $(CC) $(CFLAGS) -c -o $@ $<
598
599 $(OBJDIR)/%.c.o: $(COREDIR)/%.c
600 $(CC) $(CFLAGS) -c -o $@ $<
601
602 $(OBJDIR)/%.c.o: $(SHAREDDIR)/%.c
603 $(CC) $(CFLAGS) -c -o $@ $<
604
605 $(OBJDIR)/%.c.so.o: %.c
606 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
607
608 $(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
609 $(CC) $(CFLAGS) -c -fPIC -o $@ $<