]> git.saurik.com Git - apple/mdnsresponder.git/blame - mDNSPosix/Makefile
mDNSResponder-1310.40.42.tar.gz
[apple/mdnsresponder.git] / mDNSPosix / Makefile
CommitLineData
67c8f8a1
A
1# -*- tab-width: 4 -*-
2#
f0cc3e7b 3# Copyright (c) 2002-2019 Apple Inc. All rights reserved.
7f0064bd
A
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7#
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.
16#
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.
8e92c31c 27#
67c8f8a1
A
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.
32#
95d7a4a3
A
33# This Makefile builds an mDNSResponder daemon and a libdns_sd.so shared library
34# for Linux. It also builds several example programs for embedded systems.
8e92c31c
A
35#
36# Make with no arguments to build all production targets.
37# 'make DEBUG=1' to build debugging targets.
38# 'make clean' or 'make clean DEBUG=1' to delete prod/debug objects & targets
7f0064bd 39# 'sudo make install [DEBUG=1]' to install mdnsd daemon and libdns_sd.
8e92c31c
A
40#
41# Notes:
42# $@ means "The file name of the target of the rule"
43# $< means "The name of the first prerequisite"
67c8f8a1 44# $* means "The stem with which an implicit rule matches"
8e92c31c
A
45# $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
46# For more magic automatic variables, see
67c8f8a1 47# <http://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html>
8e92c31c
A
48
49#############################################################################
50
51LIBVERS = 1
52
53COREDIR = ../mDNSCore
32bb7e43 54SHAREDDIR ?= ../mDNSShared
f0cc3e7b 55DSODIR ?= ../DSO
8e92c31c
A
56JDK = /usr/jdk
57
f0cc3e7b
A
58SYSTEM := $(shell uname -s)
59ifeq ($(SYSTEM), Darwin)
60 os=x
61else ifeq ($(SYSTEM), Linux)
62 os=linux
63endif
64
65CC = cc
66BISON = bison
67FLEX = flex
68ST = strip
69LD = ld
70SOOPTS = -shared
8e92c31c
A
71CP = cp
72RM = rm
73LN = ln -s -f
f0cc3e7b 74CFLAGS_COMMON = -I$(COREDIR) -I$(SHAREDDIR) -I$(DSODIR) -I$(PROXYDIR) -I$(OBJDIR) -fwrapv -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
67c8f8a1
A
75CFLAGS_PTHREAD =
76LINKOPTS =
77LINKOPTS_PTHREAD = -lpthread
8e92c31c 78LDSUFFIX = so
7f0064bd 79JAVACFLAGS_OS = -fPIC -shared -ldns_sd
c9b9ae52 80
f0cc3e7b
A
81ifeq "$(OPEN_SOURCE)" "1"
82CFLAGS_OPEN_SOURCE=-D__OPEN_SOURCE__
83else
84CFLAGS_OPEN_SOURCE=
85endif
86
8e92c31c 87# Set up diverging paths for debug vs. prod builds
f0cc3e7b
A
88ifeq "$(DEBUG)" "1"
89CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=2
8e92c31c
A
90OBJDIR = objects/debug
91BUILDDIR = build/debug
95d7a4a3 92STRIP = echo
8e92c31c 93else
f0cc3e7b
A
94ifeq "$(DEBUGSYMS)" "1"
95CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=0
96OBJDIR = objects/prod
97BUILDDIR = build/prod
98STRIP = echo
99else
4aea607d
A
100# We use -Os for two reasons:
101# 1. We want to make small binaries, suitable for putting into hardware devices
102# 2. Some of the code analysis warnings only work when some form of optimization is enabled
f0cc3e7b 103CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=0
32bb7e43
A
104OBJDIR ?= objects/prod
105BUILDDIR ?= build/prod
95d7a4a3 106STRIP = $(ST) -S
8e92c31c 107endif
f0cc3e7b 108endif
8e92c31c
A
109
110# Configure per-OS peculiarities
c9b9ae52 111ifeq ($(os),solaris)
f0cc3e7b 112CFLAGS_DEBUGGING = -O0 -DMDNS_DEBUGMSGS=0
7f0064bd 113CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
32bb7e43 114 -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME -DTARGET_OS_SOLARIS
7f0064bd 115CC = gcc
f0cc3e7b
A
116LD = gcc
117SOOPTS = -shared
67c8f8a1 118LINKOPTS = -lsocket -lnsl -lresolv
7f0064bd
A
119JAVACFLAGS_OS += -I$(JDK)/include/solaris
120ifneq ($(DEBUG),1)
95d7a4a3 121STRIP = $(ST)
7f0064bd 122endif
c9b9ae52 123else
7f0064bd 124
83fb1e36
A
125# any target that contains the string "linux"
126ifeq ($(findstring linux,$(os)),linux)
f0cc3e7b
A
127CFLAGS_OS = -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX -ftabstop=4
128LD = $(CC)
129SOOPTS = -shared
67c8f8a1 130FLEXFLAGS_OS = -l
8e92c31c 131JAVACFLAGS_OS += -I$(JDK)/include/linux
83fb1e36
A
132
133# uClibc does not support Name Service Switch
134ifneq ($(os),linux-uclibc)
7f0064bd
A
135OPTIONALTARG = nss_mdns
136OPTINSTALL = InstalledNSS
83fb1e36 137endif
c9b9ae52 138else
7f0064bd 139
c9b9ae52
A
140ifeq ($(os),netbsd)
141CFLAGS_OS =
8e92c31c 142LDCONFIG = ldconfig
c9b9ae52 143else
7f0064bd 144
c9b9ae52 145ifeq ($(os),freebsd)
8e92c31c 146# If not already defined, set LOCALBASE to /usr/local
8e92c31c
A
147LOCALBASE?=/usr/local
148INSTBASE=$(LOCALBASE)
83fb1e36 149CFLAGS_OS = -DHAVE_IPV6
67c8f8a1
A
150# FreeBSD 4 requires threaded code to be compiled and linked using the "-pthread" option,
151# and requires that the "-lpthread" link option NOT be used
152# This appies only to FreeBSD -- "man cc" on FreeBSD says:
153# FreeBSD SPECIFIC OPTIONS
154# -pthread
155# Link a user-threaded process against libc_r instead of libc.
156CFLAGS_PTHREAD = -pthread -D_THREAD_SAFE
157LINKOPTS_PTHREAD = -pthread
7f0064bd 158JAVACFLAGS_OS += -I$(JDK)/include/freebsd
8e92c31c 159LDCONFIG = ldconfig
c9b9ae52 160else
7f0064bd 161
c9b9ae52
A
162ifeq ($(os),openbsd)
163CFLAGS_OS = -DHAVE_BROKEN_RECVDSTADDR
8e92c31c 164LDCONFIG = ldconfig
c9b9ae52 165else
7f0064bd 166
96f69b28 167ifeq ($(os),x)
32bb7e43
A
168# We have to define __MAC_OS_X_VERSION_MIN_REQUIRED=__MAC_OS_X_VERSION_10_4 or on Leopard
169# we get build failures: ‘daemon’ is deprecated (declared at /usr/include/stdlib.h:283)
170CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement \
4a95efb2 171 -D__MAC_OS_X_VERSION_MIN_REQUIRED=__MAC_OS_X_VERSION_10_4 \
f0cc3e7b 172 -DHAVE_STRLCPY=1 -DTARGET_OS_MAC \
4a95efb2 173 -D__APPLE_USE_RFC_2292 #-Wunreachable-code
294beb6e 174CC = gcc
f0cc3e7b
A
175LD = $(CC)
176SOOPTS = -dynamiclib
67c8f8a1 177LINKOPTS = -lSystem
283ee3ff
A
178LDSUFFIX = dylib
179JDK = /System/Library/Frameworks/JavaVM.framework/Home
95d7a4a3 180JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
9f221bca 181OPTIONALTARG = dnsextd
283ee3ff
A
182else
183
96f69b28 184$(error ERROR: Must specify target OS on command-line, e.g. "make os=x [target]".\
95d7a4a3 185Supported operating systems include: x, linux, linux-uclibc, netbsd, freebsd, openbsd, solaris)
c9b9ae52
A
186endif
187endif
188endif
189endif
190endif
283ee3ff 191endif
c9b9ae52 192
7f0064bd
A
193NSSLIBNAME := libnss_mdns
194NSSVERSION := 0.2
195NSSLIBFILE := $(NSSLIBNAME)-$(NSSVERSION).so
196NSSLINKNAME := $(NSSLIBNAME).so.2
197NSSINSTPATH := /lib
198
8e92c31c
A
199# If not otherwise defined, we install into /usr/lib and /usr/include
200# and our startup script is called mdns (e.g. /etc/init.d/mdns)
f0cc3e7b 201ETCBASE?=/etc
8e92c31c
A
202INSTBASE?=/usr
203STARTUPSCRIPTNAME?=mdns
204
205ifeq ($(HAVE_IPV6),1)
206CFLAGS_OS += -DHAVE_IPV6=1
207else
208ifeq ($(HAVE_IPV6),0)
209CFLAGS_OS += -DHAVE_IPV6=0
210endif
211endif
c9b9ae52 212
7f0064bd
A
213# If directory /usr/share/man exists, then we install man pages into that, else /usr/man
214ifeq ($(wildcard /usr/share/man), /usr/share/man)
215MANPATH := /usr/share/man
216else
217MANPATH := /usr/man
218endif
219
220# If directories /etc/init.d/rc*.d exist, then we install into that (Suse)
221ifeq ($(wildcard /etc/init.d/rc2.d/), /etc/init.d/rc2.d/)
222STARTUPSCRIPTDIR = /etc/init.d
223RUNLEVELSCRIPTSDIR = /etc/init.d
224else
19fa75a9
A
225# Else if directory /etc/rc.d/init.d/ exists, then we install into that (old Linux)
226ifeq ($(wildcard /etc/rc.d/init.d/), /etc/rc.d/init.d/)
227STARTUPSCRIPTDIR = /etc/rc.d/init.d
228RUNLEVELSCRIPTSDIR = /etc/rc.d
229else
230# Else if directory /etc/init.d/ exists, then we install into that (new Linux)
231ifeq ($(wildcard /etc/init.d/), /etc/init.d/)
232STARTUPSCRIPTDIR = /etc/init.d
233RUNLEVELSCRIPTSDIR = /etc
234else
235# Else install into /etc/rc.d/ (*BSD)
236STARTUPSCRIPTDIR = $(INSTBASE)/etc/rc.d
237endif
238endif
239endif
240
241MDNSCFLAGS = $(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUGGING) $(CFLAGS_OPEN_SOURCE)
242
243#############################################################################
244
245all: setup Daemon libdns_sd Clients SAClient SAResponder SAProxyResponder NetMonitor $(OPTIONALTARG)
246
247install: setup InstalledStartup InstalledDaemon InstalledLib InstalledManPages InstalledClients $(OPTINSTALL)
248
249# 'setup' sets up the build directory structure the way we want
250setup:
251 @if test ! -d $(OBJDIR) ; then mkdir -p $(OBJDIR) ; fi
252 @if test ! -d $(BUILDDIR) ; then mkdir -p $(BUILDDIR) ; fi
253
254# clean removes targets and objects
255clean:
256 @if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
257 @if test -d $(BUILDDIR) ; then rm -r $(BUILDDIR) ; fi
258 @$(MAKE) -C ../Clients clean
259
260#############################################################################
261
262# daemon target builds the daemon
263DAEMONOBJS = $(OBJDIR)/PosixDaemon.c.o $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNS.c.o \
264 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/uds_daemon.c.o \
265 $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/dnssd_ipc.c.o $(OBJDIR)/GenLinkedList.c.o \
266 $(OBJDIR)/PlatformCommon.c.o $(OBJDIR)/ClientRequests.c.o \
267 $(OBJDIR)/dso.c.o $(OBJDIR)/dso-transport.c.o $(OBJDIR)/dnssd_clientshim.c.o \
268 $(OBJDIR)/posix_utilities.c.o
269
270# dnsextd target build dnsextd
271DNSEXTDOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o $(OBJDIR)/DNSDigest.c.o \
272 $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/PlatformCommon.c.o $(OBJDIR)/dnsextd_parser.y.o $(OBJDIR)/dnsextd_lexer.l.o
273
274Daemon: setup $(BUILDDIR)/mdnsd
275 @echo "Responder daemon done"
276
277$(BUILDDIR)/mdnsd: $(DAEMONOBJS)
278 $(CC) -o $@ $+ $(LINKOPTS)
279 $(STRIP) $@
280
281# libdns_sd target builds the client library
282libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
283 @echo "Client library done"
284
285CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
286
287$(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
288 $(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+
289 $(STRIP) $@
290
291Clients: setup libdns_sd ../Clients/build/dns-sd
292 @echo "Clients done"
293
294../Clients/build/dns-sd: ../Clients/dns-sd.c
295 $(MAKE) -C ../Clients DEBUG=$(DEBUG) SUPMAKE_CFLAGS="$(MDNSCFLAGS)"
296
297# nss_mdns target builds the Name Service Switch module
298nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)
299 @echo "Name Service Switch module done"
300
301$(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
302 $(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+
303 $(STRIP) $@
304
305#############################################################################
306
307# The Install targets place built stuff in their proper places
308InstalledDaemon: $(INSTBASE)/sbin/mdnsd
309 @echo $+ " installed"
310
311InstalledLib: $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
312 @echo $+ " installed"
313
314InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
315 @echo $+ " installed"
316
317InstalledManPages: $(MANPATH)/man8/mdnsd.8
318 @echo $+ " installed"
319
320InstalledClients: $(INSTBASE)/bin/dns-sd
321 @echo $+ " installed"
322
323InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
324 @echo $+ " installed"
325
326# Note: If daemon already installed, we make sure it's stopped before overwriting it
327$(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
328 if test -x $@; then $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) stop; fi
329 $(CP) $< $@
330 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) start
331
332$(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
333 $(CP) $< $@
334 $(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
335ifdef LDCONFIG
336 # -m means 'merge into existing database', -R means 'rescan directories'
337 $(LDCONFIG) -mR
338endif
339
340$(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
341 $(CP) $< $@
342
343$(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR)
344 $(CP) $< $@
345 chmod ugo+x $@
346ifdef RUNLEVELSCRIPTSDIR
347ifeq ($(wildcard $(RUNLEVELSCRIPTSDIR)/runlevels/default), $(RUNLEVELSCRIPTSDIR)/runlevels/default)
348 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/runlevels/default/mdns
349else
350 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc2.d/S52mdns
351 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc3.d/S52mdns
352 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc4.d/S52mdns
353 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc5.d/S52mdns
354 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc0.d/K16mdns
355 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc6.d/K16mdns
356endif
357endif
358
359$(MANPATH)/man5/%.5: %.5
360 cp $< $@
361 chmod 444 $@
362
363$(MANPATH)/man8/%.8: %.8
364 cp $< $@
365 chmod 444 $@
366
367$(MANPATH)/man8/mdnsd.8: $(SHAREDDIR)/mDNSResponder.8
368 cp $< $@
369 chmod 444 $@
370
371$(INSTBASE)/bin/dns-sd: ../Clients/build/dns-sd
372 $(CP) $< $@
373
374$(NSSINSTPATH)/$(NSSLINKNAME): $(NSSINSTPATH)/$(NSSLIBFILE)
375 $(LN) $< $@
376 ldconfig
377
378$(NSSINSTPATH)/$(NSSLIBFILE): $(BUILDDIR)/$(NSSLIBFILE)
379 $(CP) $< $@
380 chmod 444 $@
381
382/etc/nss_mdns.conf: nss_mdns.conf
383 $(CP) $< $@
384 chmod 444 $@
385# Check the nsswitch.conf file.
386# If 'mdns' does not already appear on the "hosts:" line, then add it right before 'dns'
387 cp -f /etc/nsswitch.conf /etc/nsswitch.conf.pre-mdns
388 sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' /etc/nsswitch.conf.pre-mdns > /etc/nsswitch.conf
389
390#############################################################################
391
392# The following targets build Java wrappers for the dns-sd.h API.
393# Note that the JavaForXcode targets are used when building the project for OS X using Xcode
394
395JAVAC = $(JDK)/bin/javac
396JAVAH = $(JDK)/bin/javah
397JAVADOC = $(JDK)/bin/javadoc
398JAR = $(JDK)/bin/jar
399JAVACFLAGS = $(MDNSCFLAGS) $(JAVACFLAGS_OS) -I$(JDK)/include
400
401JavaForXcode_: setup $(BUILDDIR)/dns_sd.jar $(PROJECT_DERIVED_FILE_DIR)/DNSSD.java.h
402 @echo $@ done
403
404$(PROJECT_DERIVED_FILE_DIR)/DNSSD.java.h: $(OBJDIR)/DNSSD.java.h
405 @if test ! -d $(PROJECT_DERIVED_FILE_DIR) ; then mkdir -p $(PROJECT_DERIVED_FILE_DIR) ; fi
406 $(CP) $< $@
407
408JavaForXcode_clean:
409 @if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
410 @if test -f $(PROJECT_DERIVED_FILE_DIR)/DNSSD.java.h ; then $(RM) $(PROJECT_DERIVED_FILE_DIR)/DNSSD.java.h ; fi
411 @if test -f $(BUILDDIR)/dns_sd.jar ; then $(RM) $(BUILDDIR)/dns_sd.jar ; fi
412 @echo $@ done
413
414JavaForXcode_installhdrs:
415 @echo $@ NOOP
416
417JavaForXcode_install: JavaForXcode_ $(DSTROOT)/$(SYSTEM_LIBRARY_DIR)/Java/Extensions/dns_sd.jar
418 @echo $@ done
419
420$(DSTROOT)/$(SYSTEM_LIBRARY_DIR)/Java/Extensions/dns_sd.jar: $(BUILDDIR)/dns_sd.jar
421 @if test ! -d $(DSTROOT)/$(SYSTEM_LIBRARY_DIR)/Java/Extensions ; then mkdir -p $(DSTROOT)/$(SYSTEM_LIBRARY_DIR)/Java/Extensions ; fi
422 $(CP) $< $@
423
424Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
425 @echo "Java wrappers done"
426
427JAVASRC = $(SHAREDDIR)/Java
428JARCONTENTS = $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
429 $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
430 $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
431 $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
432 $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
433 $(OBJDIR)/com/apple/dnssd/BaseListener.class \
434 $(OBJDIR)/com/apple/dnssd/BrowseListener.class \
435 $(OBJDIR)/com/apple/dnssd/ResolveListener.class \
436 $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
437 $(OBJDIR)/com/apple/dnssd/QueryListener.class \
438 $(OBJDIR)/com/apple/dnssd/DomainListener.class \
439 $(OBJDIR)/com/apple/dnssd/RegisterRecordListener.class \
440 $(OBJDIR)/com/apple/dnssd/DNSSDRecordRegistrar.class \
441 $(OBJDIR)/com/apple/dnssd/DNSSD.class
442
443$(BUILDDIR)/dns_sd.jar: $(JARCONTENTS) setup
444 $(JAR) -cf $@ -C $(OBJDIR) com
445
446$(BUILDDIR)/libjdns_sd.$(LDSUFFIX): $(JAVASRC)/JNISupport.c $(OBJDIR)/DNSSD.java.h setup libdns_sd
447 $(CC) -o $@ $< $(JAVACFLAGS) -I$(OBJDIR) -L$(BUILDDIR)
448
449$(OBJDIR)/com/apple/dnssd/%.class: $(JAVASRC)/%.java
450 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
451
452$(OBJDIR)/DNSSD.java.h: $(OBJDIR)/com/apple/dnssd/DNSSD.class
453 $(JAVAH) -force -classpath $(OBJDIR) -o $@ \
454 com.apple.dnssd.AppleDNSSD \
455 com.apple.dnssd.AppleBrowser \
456 com.apple.dnssd.AppleResolver \
457 com.apple.dnssd.AppleRegistration \
458 com.apple.dnssd.AppleQuery \
459 com.apple.dnssd.AppleDomainEnum \
460 com.apple.dnssd.AppleService \
461 com.apple.dnssd.AppleDNSRecord \
462 com.apple.dnssd.AppleRecordRegistrar
463
464#############################################################################
465
466# The following target builds documentation for the Java wrappers.
467
468JavaDoc: Java setup
469 $(JAVADOC) $(JAVASRC)/*.java -classpath $(OBJDIR) -d $(BUILDDIR) -public
470
471#############################################################################
472
473# The following targets build embedded example programs
474SPECIALOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o \
475 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/PlatformCommon.c.o \
476 $(OBJDIR)/dso.c.o $(OBJDIR)/dso-transport.c.o $(OBJDIR)/dnssd_clientshim.c.o
477COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
478APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
479
480SAClient: setup $(BUILDDIR)/mDNSClientPosix
481 @echo "Embedded Standalone Client done"
482
483SAResponder: setup $(BUILDDIR)/mDNSResponderPosix
484 @echo "Embedded Standalone Responder done"
485
486SAProxyResponder: setup $(BUILDDIR)/mDNSProxyResponderPosix
487 @echo "Embedded Standalone ProxyResponder done"
488
489NetMonitor: setup $(BUILDDIR)/mDNSNetMonitor
490 @echo "NetMonitor done"
491
492dnsextd: setup $(BUILDDIR)/dnsextd
493 @echo "dnsextd done"
494
495$(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
496 $(CC) $+ -o $@ $(LINKOPTS)
497
498$(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
499 $(CC) $+ -o $@ $(LINKOPTS)
500
501$(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o
502 $(CC) $+ -o $@ $(LINKOPTS)
503
504$(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
505 $(CC) $+ -o $@ $(LINKOPTS)
506
507$(OBJDIR)/NetMonitor.c.o: $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c
508
509$(BUILDDIR)/dnsextd: $(DNSEXTDOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o
510 $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD)
511
512#############################################################################
513
514# Implicit rules
515$(OBJDIR)/%.c.o: %.c
516 $(CC) $(MDNSCFLAGS) -c -o $@ $<
517
518$(OBJDIR)/%.c.o: $(COREDIR)/%.c
519 $(CC) $(MDNSCFLAGS) -c -o $@ $<
520
521$(OBJDIR)/%.c.o: $(SHAREDDIR)/%.c
522 $(CC) $(MDNSCFLAGS) -c -o $@ $<
523
524$(OBJDIR)/%.c.o: $(DSODIR)/%.c
525 $(CC) $(MDNSCFLAGS) -c -o $@ $<
526
527$(OBJDIR)/%.c.threadsafe.o: %.c
528 $(CC) $(MDNSCFLAGS) $(MDNSCFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
529
530$(OBJDIR)/%.c.threadsafe.o: $(SHAREDDIR)/%.c
531 $(CC) $(MDNSCFLAGS) $(MDNSCFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
532
533$(OBJDIR)/%.c.so.o: %.c
534 $(CC) $(MDNSCFLAGS) -c -fPIC -o $@ $<
535
536$(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
537 $(CC) $(MDNSCFLAGS) -c -fPIC -o $@ $<
538
539$(OBJDIR)/%.y.o: $(SHAREDDIR)/%.y
540 $(BISON) -o $(OBJDIR)/$*.c -d $<
541 $(CC) $(MDNSCFLAGS) -c -o $@ $(OBJDIR)/$*.c
542
543$(OBJDIR)/%.l.o: $(SHAREDDIR)/%.l
544 $(FLEX) $(FLEXFLAGS_OS) -i -o$(OBJDIR)/$*.l.c $<
545 $(CC) $(MDNSCFLAGS) -Wno-error -c -o $@ $(OBJDIR)/$*.l.c