]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSPosix/Makefile
mDNSResponder-107.6.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 # IMPORTANT NOTE: This is a Makefile for *GNU make*
27 # On some systems, a different program may be the default "make" command.
28 # If "make os=xxx" gives lots of errors like "Missing dependency operator",
29 # then try typing "gmake os=xxx" instead.
30 #
31 # $Log: Makefile,v $
32 # Revision 1.71 2006/06/20 23:07:04 rpantos
33 # <rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
34 #
35 # Revision 1.70 2006/05/03 23:35:10 cheshire
36 # Add missing dependency: NetMonitor.c textually imports mDNS.c
37 #
38 # Revision 1.69 2006/02/26 23:18:50 cheshire
39 # <rdar://problem/4427969> FreeBSD 4 requires "-pthread" option to compile threaded code
40 #
41 # Revision 1.68 2006/02/26 01:36:54 cheshire
42 # Rename the poorly named "LIBFLAGS" as "LINKOPTS"
43 #
44 # Revision 1.67 2006/02/25 23:14:29 cheshire
45 # Add comment suggesting using "gmake" command
46 #
47 # Revision 1.66 2006/01/06 01:06:17 cheshire
48 # <rdar://problem/3978979> Compile library and client programs in one pass
49 #
50 # Revision 1.65 2005/12/21 21:15:57 cheshire
51 # Add missing dependency: Identify.c textually imports mDNS.c
52 #
53 # Revision 1.64 2005/10/25 23:55:47 cheshire
54 # Add tiger to list of target platforms
55 #
56 # Revision 1.63 2005/10/11 21:30:44 cheshire
57 # Add "-Wunreachable-code" (commented out for now)
58 #
59 # Revision 1.62 2005/06/30 21:46:55 cheshire
60 # <rdar://problem/4167287> Solaris should use unix domain sockets, not loopback
61 #
62 # Revision 1.61 2005/06/30 20:46:05 cheshire
63 # Added Makefile rule to build threadsafe object files where necessary using "-D_REENTRANT".
64 #
65 # Revision 1.60 2005/06/30 10:42:38 cheshire
66 # Turn on "-Werror" and "-O" for better error reporting
67 #
68 # Revision 1.59 2005/04/14 21:07:10 rpantos
69 # Bug #: 4089257, Clean build broken for Java support on POSIX
70 # Submitted by: Roger Pantos
71 # Reviewed by: Kiren Sekar
72 #
73 # Revision 1.58 2005/04/08 21:37:57 ksekar
74 # <rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
75 #
76 # Revision 1.57 2005/03/17 04:02:28 cheshire
77 # <rdar://problem/3986419> mDNSResponder won't compile with gcc4 on Tiger
78 # Changed Makefile to link using gcc instead of libtool
79 #
80 # Revision 1.56 2005/02/02 02:25:21 cheshire
81 # <rdar://problem/3980388> /var/run/mDNSResponder should be /var/run/mdnsd on Linux
82 #
83 # Revision 1.55 2005/01/27 22:55:00 cheshire
84 # Add "make os=tiger" target which uses gcc4 and "-Wdeclaration-after-statement"
85 #
86 # Revision 1.54 2004/12/17 19:33:03 cheshire
87 # Add "-lresolv" for Solaris
88 #
89 # Revision 1.53 2004/12/01 20:04:31 cheshire
90 # Tidy up alignment
91 #
92 # Revision 1.52 2004/12/01 19:46:12 cheshire
93 # Add install case for Suse 9 (rc*.d directories *inside* the init.d directory)
94 #
95 # Revision 1.51 2004/12/01 03:30:29 cheshire
96 # <rdar://problem/3889346> Add Unicast DNS support to mDNSPosix
97 #
98 # Revision 1.50 2004/12/01 01:14:20 cheshire
99 # Add $(LIBFLAGS) to cc command to build dnsextd (required for Solaris)
100 #
101 # Revision 1.49 2004/11/11 01:44:52 cheshire
102 # Updated error message
103 #
104 # Revision 1.48 2004/10/06 02:22:19 cheshire
105 # Changed MacRoman copyright symbol (should have been UTF-8 in any case :-) to ASCII-compatible "(c)"
106 #
107 # Revision 1.47 2004/10/01 22:15:54 rpantos
108 # rdar://problem/3824265: Replace APSL in client lib with BSD license.
109 #
110 # Revision 1.46 2004/09/24 21:15:25 cheshire
111 # <rdar://problem/3724985> Library "libmdns" misnamed; should be "libdns_sd"
112 #
113 # Revision 1.45 2004/09/22 16:23:41 cheshire
114 # Modify installation for compatibility with Gentoo Linux
115 # (Thanks to David Black for this information)
116 #
117 # Revision 1.44 2004/09/17 01:08:53 cheshire
118 # Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
119 # The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
120 # declared in that file are ONLY appropriate to single-address-space embedded applications.
121 # For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
122 #
123 # Revision 1.43 2004/09/17 00:30:11 cheshire
124 # Added some '@' signs to make build output less verbose --
125 # when there's too much on the screen it's easy to miss build errors and warnings
126 #
127 # Revision 1.42 2004/08/24 22:04:37 cheshire
128 # Need to specify -lpthread for building dnsextd
129 #
130 # Revision 1.41 2004/08/11 00:43:26 ksekar
131 # <rdar://problem/3722542>: DNS Extension daemon for DNS Update Lease
132 #
133 # Revision 1.40 2004/07/08 21:45:55 cheshire
134 # Make nss_mdns only build on Linux. We can add it to other targets (Solaris,
135 # FreeBSD, etc., as we verify them). In particular, NSS is NOT supported on
136 # OS X, so including it for "os=jaguar" or "os=panther" broke those builds.
137 #
138 # Revision 1.39 2004/06/29 03:34:28 cheshire
139 # Add 'dot-local' Name Service Switch support from Andrew White at NICTA
140 #
141 # Revision 1.38 2004/06/25 02:19:40 rpantos
142 # And FreeBSD...
143 #
144 # Revision 1.37 2004/06/25 00:51:09 rpantos
145 # And fix the Java build for Posix on Solaris, too.
146 #
147 # Revision 1.36 2004/06/25 00:26:27 rpantos
148 # Changes to fix the Posix build on Solaris.
149 #
150 # Revision 1.35 2004/06/18 18:51:31 cheshire
151 # Add (commented out) "-pedantic" for when we want to check for "mixed declarations and code" warnings
152 #
153 # Revision 1.34 2004/05/25 18:29:33 cheshire
154 # Move DNSServiceConstructFullName() from dnssd_clientstub.c to dnssd_clientlib.c,
155 # so that it's also accessible to dnssd_clientshim.c (single address space) clients.
156 #
157 # Revision 1.33 2004/04/30 16:46:32 rpantos
158 # Add support for building Java libraries.
159 #
160 # Revision 1.32 2004/04/14 23:09:29 ksekar
161 # Support for TSIG signed dynamic updates.
162 #
163 # Revision 1.31 2004/03/15 19:07:06 cheshire
164 # Fix error message
165 #
166 # Revision 1.30 2004/03/11 18:58:29 rpantos
167 # Fix Kill /etc/rc scripts so they run at halt & reboot.
168 #
169 # Revision 1.29 2004/03/04 23:35:41 cheshire
170 # Instead of using a dummy target to generate an error message, use "$(error text...)"
171 #
172 # Revision 1.28 2004/03/04 23:33:42 cheshire
173 # Fixes from Alfred Perlstein for FreeBSD's benefit
174 #
175 # Revision 1.27 2004/02/11 21:00:21 cheshire
176 # Update URL for GNU Make manual page
177 #
178 # Revision 1.26 2004/02/05 21:28:30 cheshire
179 # Fixes so that "sudo make install" works on *BSD
180 #
181 # Revision 1.25 2004/02/05 20:00:22 cheshire
182 # Define mdnsd's PID file to be /var/run/mdnsd.pid on Posix builds
183 #
184 # Revision 1.24 2004/02/05 01:00:01 rpantos
185 # Fix some issues that turned up when building for FreeBSD.
186 #
187 # Revision 1.23 2004/02/04 01:50:54 cheshire
188 # Make InstalledStartup conditional, so it automatically installs into
189 # either /etc/init.d/ or /etc/rc.d/init.d/ as appropriate
190 #
191 # Revision 1.22 2004/01/20 01:41:21 rpantos
192 # Define USES_NETLINK for Linux builds.
193 #
194 # Revision 1.21 2003/12/17 00:51:22 cheshire
195 # Changed mDNSNetMonitor and mDNSIdentify to link the object files
196 # instead of #including the "DNSCommon.c" "uDNS.c" and source files
197 #
198 # Revision 1.20 2003/12/13 03:05:28 ksekar
199 # Bug #: <rdar://problem/3192548>: DynDNS: Unicast query of service records
200 #
201 # Revision 1.19 2003/12/11 19:42:13 cheshire
202 # Change name "mDNSResponderd" to "mdnsd" for consistency with standard Linux (Unix) naming conventions
203 #
204 # Revision 1.18 2003/12/11 19:38:34 cheshire
205 # Add APSL
206 #
207 # Revision 1.17 2003/12/11 03:16:49 rpantos
208 # One more change for OS X build: make install work a little better.
209 #
210 # Revision 1.16 2003/12/11 03:03:51 rpantos
211 # Clean up mDNSPosix so that it builds on OS X again.
212 #
213 # Revision 1.15 2003/12/08 20:47:02 rpantos
214 # Add support for mDNSResponder on Linux.
215 #
216 # Revision 1.14 2003/11/14 20:59:09 cheshire
217 # Clients can't use AssignDomainName macro because mDNSPlatformMemCopy is defined in mDNSPlatformFunctions.h.
218 # Best solution is just to combine mDNSEmbeddedAPI.h and mDNSPlatformFunctions.h into a single file.
219 #
220 # Revision 1.13 2003/08/06 18:20:51 cheshire
221 # Makefile cleanup
222 #
223 # Revision 1.12 2003/08/01 02:20:02 cheshire
224 # Add mDNSIdentify tool, used to discover what version of mDNSResponder a particular host is running
225 #
226 # Revision 1.11 2003/07/14 18:11:54 cheshire
227 # Fix stricter compiler warnings
228 #
229 # Revision 1.10 2003/06/18 05:47:41 cheshire
230 # Enable stricter warnings on Jaguar and Panther builds
231 #
232 # Revision 1.9 2003/06/04 18:34:45 ksekar
233 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
234 # Changed build targets "osx10.2" and "osx10.3" to "jaguar" and "panther".
235 #
236 # Revision 1.8 2003/06/04 00:23:12 ksekar
237 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
238 # Created separate target OS's for 10.2 and 10.3.
239 #
240 # Revision 1.7 2003/04/16 02:11:37 cheshire
241 # Remove unnecessary $(CFLAGS) from linking rules
242 #
243 # Revision 1.6 2003/04/04 01:37:14 cheshire
244 # Added NetMonitor.c
245 #
246
247 # This Makefile builds an mDNSResponder daemon and a libdns_sd.so shared library
248 # for Linux. It also builds several example programs for embedded systems.
249 #
250 # Make with no arguments to build all production targets.
251 # 'make DEBUG=1' to build debugging targets.
252 # 'make clean' or 'make clean DEBUG=1' to delete prod/debug objects & targets
253 # 'sudo make install [DEBUG=1]' to install mdnsd daemon and libdns_sd.
254 #
255 # Notes:
256 # $@ means "The file name of the target of the rule"
257 # $< means "The name of the first prerequisite"
258 # $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
259 # For more magic automatic variables, see
260 # <http://www.gnu.org/software/make/manual/html_chapter/make_10.html#SEC111>
261
262 #############################################################################
263
264 LIBVERS = 1
265
266 COREDIR = ../mDNSCore
267 SHAREDDIR = ../mDNSShared
268 JDK = /usr/jdk
269
270 CC = @cc
271 LD = ld -shared
272 CP = cp
273 RM = rm
274 LN = ln -s -f
275 CFLAGS_COMMON = -I. -I$(COREDIR) -I$(SHAREDDIR) -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
276 CFLAGS_PTHREAD =
277 LINKOPTS =
278 LINKOPTS_PTHREAD = -lpthread
279 LDSUFFIX = so
280 JAVACFLAGS_OS = -fPIC -shared -ldns_sd
281
282 # Set up diverging paths for debug vs. prod builds
283 DEBUG=0
284 ifeq ($(DEBUG),1)
285 CFLAGS_DEBUG = -g -DMDNS_DEBUGMSGS=2
286 OBJDIR = objects/debug
287 BUILDDIR = build/debug
288 STRIP = echo
289 else
290 # We use -Os for two reasons:
291 # 1. We want to make small binaries, suitable for putting into hardware devices
292 # 2. Some of the code analysis warnings only work when some form of optimization is enabled
293 CFLAGS_DEBUG = -Os -DMDNS_DEBUGMSGS=0
294 OBJDIR = objects/prod
295 BUILDDIR = build/prod
296 STRIP = strip -S
297 endif
298
299 # Configure per-OS peculiarities
300 ifeq ($(os),solaris)
301 CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
302 -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME
303 CC = gcc
304 LD = gcc -shared
305 LINKOPTS = -lsocket -lnsl -lresolv
306 JAVACFLAGS_OS += -I$(JDK)/include/solaris
307 ifneq ($(DEBUG),1)
308 STRIP = strip
309 endif
310 else
311
312 ifeq ($(os),linux)
313 CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX
314 JAVACFLAGS_OS += -I$(JDK)/include/linux
315 OPTIONALTARG = nss_mdns
316 OPTINSTALL = InstalledNSS
317 else
318
319 ifeq ($(os),netbsd)
320 CFLAGS_OS =
321 LDCONFIG = ldconfig
322 else
323
324 ifeq ($(os),freebsd)
325 # If not already defined, set LOCALBASE to /usr/local
326 # FreeBSD requires the startup script to end in ".sh"
327 LOCALBASE?=/usr/local
328 INSTBASE=$(LOCALBASE)
329 STARTUPSCRIPTNAME=mdns.sh
330 CFLAGS_OS =
331 # FreeBSD 4 requires threaded code to be compiled and linked using the "-pthread" option,
332 # and requires that the "-lpthread" link option NOT be used
333 # This appies only to FreeBSD -- "man cc" on FreeBSD says:
334 # FreeBSD SPECIFIC OPTIONS
335 # -pthread
336 # Link a user-threaded process against libc_r instead of libc.
337 CFLAGS_PTHREAD = -pthread -D_THREAD_SAFE
338 LINKOPTS_PTHREAD = -pthread
339 JAVACFLAGS_OS += -I$(JDK)/include/freebsd
340 LDCONFIG = ldconfig
341 else
342
343 ifeq ($(os),openbsd)
344 CFLAGS_OS = -DHAVE_BROKEN_RECVDSTADDR
345 LDCONFIG = ldconfig
346 else
347
348 ifeq ($(os),jaguar)
349 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -DNOT_HAVE_SOCKLEN_T
350 LD = libtool -dynamic
351 LINKOPTS = -lSystem
352 LDSUFFIX = dylib
353 JDK = /System/Library/Frameworks/JavaVM.framework/Home
354 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
355 else
356
357 ifeq ($(os),panther)
358 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror
359 LD = libtool -dynamic
360 LINKOPTS = -lSystem
361 LDSUFFIX = dylib
362 JDK = /System/Library/Frameworks/JavaVM.framework/Home
363 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
364 else
365
366 ifeq ($(os),tiger)
367 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement #-Wunreachable-code
368 CC = @gcc-4.0
369 LD = $(CC) -dynamiclib
370 LINKOPTS = -lSystem
371 LDSUFFIX = dylib
372 JDK = /System/Library/Frameworks/JavaVM.framework/Home
373 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
374 else
375
376 $(error ERROR: Must specify target OS on command-line, e.g. "make os=tiger [target]".\
377 Supported operating systems include: jaguar, panther, tiger, linux, netbsd, freebsd, openbsd, solaris)
378 endif
379 endif
380 endif
381 endif
382 endif
383 endif
384 endif
385 endif
386
387 NSSLIBNAME := libnss_mdns
388 NSSVERSION := 0.2
389 NSSLIBFILE := $(NSSLIBNAME)-$(NSSVERSION).so
390 NSSLINKNAME := $(NSSLIBNAME).so.2
391 NSSINSTPATH := /lib
392
393 # If not otherwise defined, we install into /usr/lib and /usr/include
394 # and our startup script is called mdns (e.g. /etc/init.d/mdns)
395 INSTBASE?=/usr
396 STARTUPSCRIPTNAME?=mdns
397
398 ifeq ($(HAVE_IPV6),1)
399 CFLAGS_OS += -DHAVE_IPV6=1
400 else
401 ifeq ($(HAVE_IPV6),0)
402 CFLAGS_OS += -DHAVE_IPV6=0
403 endif
404 endif
405
406 # If directory /usr/share/man exists, then we install man pages into that, else /usr/man
407 ifeq ($(wildcard /usr/share/man), /usr/share/man)
408 MANPATH := /usr/share/man
409 else
410 MANPATH := /usr/man
411 endif
412
413 # If directories /etc/init.d/rc*.d exist, then we install into that (Suse)
414 ifeq ($(wildcard /etc/init.d/rc2.d/), /etc/init.d/rc2.d/)
415 STARTUPSCRIPTDIR = /etc/init.d
416 RUNLEVELSCRIPTSDIR = /etc/init.d
417 else
418 # else if directory /etc/rc.d/init.d/ exists, then we install into that (old Linux)
419 ifeq ($(wildcard /etc/rc.d/init.d/), /etc/rc.d/init.d/)
420 STARTUPSCRIPTDIR = /etc/rc.d/init.d
421 RUNLEVELSCRIPTSDIR = /etc/rc.d
422 else
423 # else if directory /etc/init.d/ exists, then we install into that (new Linux)
424 ifeq ($(wildcard /etc/init.d/), /etc/init.d/)
425 STARTUPSCRIPTDIR = /etc/init.d
426 RUNLEVELSCRIPTSDIR = /etc
427 else
428 # else install into /etc/rc.d/ (*BSD)
429 STARTUPSCRIPTDIR = $(INSTBASE)/etc/rc.d
430 endif
431 endif
432 endif
433
434 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUG)
435
436 #############################################################################
437
438 all: setup Daemon libdns_sd Clients SAClient SAResponder SAProxyResponder Identify NetMonitor dnsextd $(OPTIONALTARG)
439
440 install: setup InstalledDaemon InstalledStartup InstalledLib InstalledManPages InstalledClients $(OPTINSTALL)
441
442 # 'setup' sets up the build directory structure the way we want
443 setup:
444 @if test ! -d objects ; then mkdir objects ; fi
445 @if test ! -d build ; then mkdir build ; fi
446 @if test ! -d $(OBJDIR) ; then mkdir $(OBJDIR) ; fi
447 @if test ! -d $(BUILDDIR) ; then mkdir $(BUILDDIR) ; fi
448
449 # clean removes targets and objects
450 clean:
451 @if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
452 @if test -d $(BUILDDIR) ; then rm -r $(BUILDDIR) ; fi
453 @$(MAKE) -C ../Clients clean
454
455 #############################################################################
456
457 # daemon target builds the daemon
458 DAEMONOBJS = $(OBJDIR)/PosixDaemon.c.o $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNS.c.o \
459 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/uds_daemon.c.o \
460 $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/dnssd_ipc.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/PlatformCommon.c.o
461
462 Daemon: setup $(BUILDDIR)/mdnsd
463 @echo "Responder daemon done"
464
465 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
466 $(CC) -o $@ $+ $(LINKOPTS)
467 @$(STRIP) $@
468
469 # libdns_sd target builds the client library
470 libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
471 @echo "Client library done"
472
473 CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
474
475 $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
476 @$(LD) $(LINKOPTS) -o $@ $+
477 @$(STRIP) $@
478
479 Clients: setup libdns_sd ../Clients/build/dns-sd
480 @echo "Clients done"
481
482 ../Clients/build/dns-sd:
483 @$(MAKE) -C ../Clients
484
485 # nss_mdns target builds the Name Service Switch module
486 nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)
487 @echo "Name Service Switch module done"
488
489 $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
490 @$(LD) $(LINKOPTS) -o $@ $+
491 @$(STRIP) $@
492
493 #############################################################################
494
495 # The Install targets place built stuff in their proper places
496 InstalledDaemon: $(INSTBASE)/sbin/mdnsd
497 @echo $+ " installed"
498
499 InstalledLib: $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
500 @echo $+ " installed"
501
502 InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
503 @echo $+ " installed"
504
505 InstalledManPages: $(MANPATH)/man8/mdnsd.8
506 @echo $+ " installed"
507
508 InstalledClients: $(INSTBASE)/bin/dns-sd
509 @echo $+ " installed"
510
511 InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
512 @echo $+ " installed"
513
514 # Note: If daemon already installed, we make sure it's stopped before overwriting it
515 $(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd
516 @if test -x $@; then $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) stop; fi
517 $(CP) $< $@
518
519 $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
520 $(CP) $< $@
521 $(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
522 ifdef LDCONFIG
523 # -m means 'merge into existing database', -R means 'rescan directories'
524 $(LDCONFIG) -mR
525 endif
526
527 $(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
528 $(CP) $< $@
529
530 # We make this target dependent on $(INSTBASE)/sbin/mdnsd because we need to ensure
531 # that the daemon is installed *before* we try to execute the command to start it.
532 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR) $(INSTBASE)/sbin/mdnsd
533 $(CP) $< $@
534 chmod ugo+x $@
535 $@ start
536 ifdef RUNLEVELSCRIPTSDIR
537 ifeq ($(wildcard $(RUNLEVELSCRIPTSDIR)/runlevels/default), $(RUNLEVELSCRIPTSDIR)/runlevels/default)
538 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/runlevels/default/mdns
539 else
540 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc2.d/S52mdns
541 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc3.d/S52mdns
542 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc4.d/S52mdns
543 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc5.d/S52mdns
544 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc0.d/K16mdns
545 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc6.d/K16mdns
546 endif
547 endif
548
549 $(MANPATH)/man5/%.5: %.5
550 cp $< $@
551 chmod 444 $@
552
553 $(MANPATH)/man8/%.8: %.8
554 cp $< $@
555 chmod 444 $@
556
557 $(MANPATH)/man8/mdnsd.8: $(SHAREDDIR)/mDNSResponder.8
558 cp $< $@
559 chmod 444 $@
560
561 $(INSTBASE)/bin/dns-sd: ../Clients/build/dns-sd
562 $(CP) $< $@
563
564 $(NSSINSTPATH)/$(NSSLINKNAME): $(NSSINSTPATH)/$(NSSLIBFILE)
565 $(LN) $< $@
566 ldconfig
567
568 $(NSSINSTPATH)/$(NSSLIBFILE): $(BUILDDIR)/$(NSSLIBFILE)
569 $(CP) $< $@
570 chmod 444 $@
571
572 /etc/nss_mdns.conf: nss_mdns.conf
573 $(CP) $< $@
574 chmod 444 $@
575 # Check the nsswitch.conf file.
576 # If 'mdns' does not already appear on the "hosts:" line, then add it right before 'dns'
577 cp -f /etc/nsswitch.conf /etc/nsswitch.conf.pre-mdns
578 sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' /etc/nsswitch.conf.pre-mdns > /etc/nsswitch.conf
579
580 #############################################################################
581
582 # The following targets build Java wrappers for the dns-sd.h API.
583
584 JAVAC = $(JDK)/bin/javac
585 JAVAH = $(JDK)/bin/javah
586 JAVADOC = $(JDK)/bin/javadoc
587 JAR = $(JDK)/bin/jar
588 JAVACFLAGS = $(CFLAGS) $(JAVACFLAGS_OS) -I$(JDK)/include
589
590 Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
591 @echo "Java wrappers done"
592
593 JAVASRC = $(SHAREDDIR)/Java
594 JARCONTENTS = $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
595 $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
596 $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
597 $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
598 $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
599 $(OBJDIR)/com/apple/dnssd/BaseListener.class \
600 $(OBJDIR)/com/apple/dnssd/BrowseListener.class \
601 $(OBJDIR)/com/apple/dnssd/ResolveListener.class \
602 $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
603 $(OBJDIR)/com/apple/dnssd/QueryListener.class \
604 $(OBJDIR)/com/apple/dnssd/DomainListener.class \
605 $(OBJDIR)/com/apple/dnssd/RegisterRecordListener.class \
606 $(OBJDIR)/com/apple/dnssd/DNSSDRecordRegistrar.class \
607 $(OBJDIR)/com/apple/dnssd/DNSSD.class
608
609 $(BUILDDIR)/dns_sd.jar: $(JARCONTENTS) setup
610 $(JAR) -cf $@ -C $(OBJDIR) com
611
612 $(BUILDDIR)/libjdns_sd.$(LDSUFFIX): $(JAVASRC)/JNISupport.c $(OBJDIR)/DNSSD.java.h setup libdns_sd
613 $(CC) -o $@ $< $(JAVACFLAGS) -I$(OBJDIR) -L$(BUILDDIR)
614
615 $(OBJDIR)/com/apple/dnssd/%.class: $(JAVASRC)/%.java
616 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
617
618 $(OBJDIR)/DNSSD.java.h: $(OBJDIR)/com/apple/dnssd/DNSSD.class
619 $(JAVAH) -force -classpath $(OBJDIR) -o $@ \
620 com.apple.dnssd.AppleDNSSD \
621 com.apple.dnssd.AppleBrowser \
622 com.apple.dnssd.AppleResolver \
623 com.apple.dnssd.AppleRegistration \
624 com.apple.dnssd.AppleQuery \
625 com.apple.dnssd.AppleDomainEnum \
626 com.apple.dnssd.AppleService
627
628 #############################################################################
629
630 # The following target builds documentation for the Java wrappers.
631
632 JavaDoc: Java setup
633 $(JAVADOC) $(JAVASRC)/*.java -classpath $(OBJDIR) -d $(BUILDDIR) -public
634
635 #############################################################################
636
637 # The following targets build embedded example programs
638 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
639 COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
640 APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
641
642 SAClient: setup $(BUILDDIR)/mDNSClientPosix
643 @echo "Embedded Standalone Client done"
644
645 SAResponder: setup $(BUILDDIR)/mDNSResponderPosix
646 @echo "Embedded Standalone Responder done"
647
648 SAProxyResponder: setup $(BUILDDIR)/mDNSProxyResponderPosix
649 @echo "Embedded Standalone ProxyResponder done"
650
651 Identify: setup $(BUILDDIR)/mDNSIdentify
652 @echo "Identify done"
653
654 NetMonitor: setup $(BUILDDIR)/mDNSNetMonitor
655 @echo "NetMonitor done"
656
657 dnsextd: setup $(BUILDDIR)/dnsextd
658 @echo "dnsextd done"
659
660 $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
661 $(CC) $+ -o $@ $(LINKOPTS)
662
663 $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
664 $(CC) $+ -o $@ $(LINKOPTS)
665
666 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o
667 $(CC) $+ -o $@ $(LINKOPTS)
668
669 $(BUILDDIR)/mDNSIdentify: $(SPECIALOBJ) $(OBJDIR)/Identify.c.o
670 $(CC) $+ -o $@ $(LINKOPTS)
671
672 $(OBJDIR)/Identify.c.o: $(COREDIR)/mDNS.c # Note: Identify.c textually imports mDNS.c
673
674 $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
675 $(CC) $+ -o $@ $(LINKOPTS)
676
677 $(OBJDIR)/NetMonitor.c.o: $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c
678
679 $(BUILDDIR)/dnsextd: $(SPECIALOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o
680 $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD)
681
682 #############################################################################
683
684 # Implicit rules
685 $(OBJDIR)/%.c.o: %.c
686 $(CC) $(CFLAGS) -c -o $@ $<
687
688 $(OBJDIR)/%.c.o: $(COREDIR)/%.c
689 $(CC) $(CFLAGS) -c -o $@ $<
690
691 $(OBJDIR)/%.c.o: $(SHAREDDIR)/%.c
692 $(CC) $(CFLAGS) -c -o $@ $<
693
694 $(OBJDIR)/%.c.threadsafe.o: %.c
695 $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
696
697 $(OBJDIR)/%.c.so.o: %.c
698 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
699
700 $(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
701 $(CC) $(CFLAGS) -c -fPIC -o $@ $<