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