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