]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSPosix/Makefile
mDNSResponder-66.3.tar.gz
[apple/mdnsresponder.git] / mDNSPosix / Makefile
1 # Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
2 #
3 # @APPLE_LICENSE_HEADER_START@
4 #
5 # This file contains Original Code and/or Modifications of Original Code
6 # as defined in and that are subject to the Apple Public Source License
7 # Version 2.0 (the 'License'). You may not use this file except in
8 # compliance with the License. Please obtain a copy of the License at
9 # http://www.opensource.apple.com/apsl/ and read it before using this
10 # file.
11 #
12 # The Original Code and all software distributed under the License are
13 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
17 # Please see the License for the specific language governing rights and
18 # limitations under the License.
19 #
20 # @APPLE_LICENSE_HEADER_END@
21 #
22 # $Log: Makefile,v $
23 # Revision 1.34 2004/05/25 18:29:33 cheshire
24 # Move DNSServiceConstructFullName() from dnssd_clientstub.c to dnssd_clientlib.c,
25 # so that it's also accessible to dnssd_clientshim.c (single address space) clients.
26 #
27 # Revision 1.33 2004/04/30 16:46:32 rpantos
28 # Add support for building Java libraries.
29 #
30 # Revision 1.32 2004/04/14 23:09:29 ksekar
31 # Support for TSIG signed dynamic updates.
32 #
33 # Revision 1.31 2004/03/15 19:07:06 cheshire
34 # Fix error message
35 #
36 # Revision 1.30 2004/03/11 18:58:29 rpantos
37 # Fix Kill /etc/rc scripts so they run at halt & reboot.
38 #
39 # Revision 1.29 2004/03/04 23:35:41 cheshire
40 # Instead of using a dummy target to generate an error message, use "$(error text...)"
41 #
42 # Revision 1.28 2004/03/04 23:33:42 cheshire
43 # Fixes from Alfred Perlstein for FreeBSD's benefit
44 #
45 # Revision 1.27 2004/02/11 21:00:21 cheshire
46 # Update URL for GNU Make manual page
47 #
48 # Revision 1.26 2004/02/05 21:28:30 cheshire
49 # Fixes so that "sudo make install" works on *BSD
50 #
51 # Revision 1.25 2004/02/05 20:00:22 cheshire
52 # Define mdnsd's PID file to be /var/run/mdnsd.pid on Posix builds
53 #
54 # Revision 1.24 2004/02/05 01:00:01 rpantos
55 # Fix some issues that turned up when building for FreeBSD.
56 #
57 # Revision 1.23 2004/02/04 01:50:54 cheshire
58 # Make InstalledStartup conditional, so it automatically installs into
59 # either /etc/init.d/ or /etc/rc.d/init.d/ as appropriate
60 #
61 # Revision 1.22 2004/01/20 01:41:21 rpantos
62 # Define USES_NETLINK for Linux builds.
63 #
64 # Revision 1.21 2003/12/17 00:51:22 cheshire
65 # Changed mDNSNetMonitor and mDNSIdentify to link the object files
66 # instead of #including the "DNSCommon.c" "uDNS.c" and source files
67 #
68 # Revision 1.20 2003/12/13 03:05:28 ksekar
69 # Bug #: <rdar://problem/3192548>: DynDNS: Unicast query of service records
70 #
71 # Revision 1.19 2003/12/11 19:42:13 cheshire
72 # Change name "mDNSResponderd" to "mdnsd" for consistency with standard Linux (Unix) naming conventions
73 #
74 # Revision 1.18 2003/12/11 19:38:34 cheshire
75 # Add APSL
76 #
77 # Revision 1.17 2003/12/11 03:16:49 rpantos
78 # One more change for OS X build: make install work a little better.
79 #
80 # Revision 1.16 2003/12/11 03:03:51 rpantos
81 # Clean up mDNSPosix so that it builds on OS X again.
82 #
83 # Revision 1.15 2003/12/08 20:47:02 rpantos
84 # Add support for mDNSResponder on Linux.
85 #
86 # Revision 1.14 2003/11/14 20:59:09 cheshire
87 # Clients can't use AssignDomainName macro because mDNSPlatformMemCopy is defined in mDNSPlatformFunctions.h.
88 # Best solution is just to combine mDNSClientAPI.h and mDNSPlatformFunctions.h into a single file.
89 #
90 # Revision 1.13 2003/08/06 18:20:51 cheshire
91 # Makefile cleanup
92 #
93 # Revision 1.12 2003/08/01 02:20:02 cheshire
94 # Add mDNSIdentify tool, used to discover what version of mDNSResponder a particular host is running
95 #
96 # Revision 1.11 2003/07/14 18:11:54 cheshire
97 # Fix stricter compiler warnings
98 #
99 # Revision 1.10 2003/06/18 05:47:41 cheshire
100 # Enable stricter warnings on Jaguar and Panther builds
101 #
102 # Revision 1.9 2003/06/04 18:34:45 ksekar
103 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
104 # Changed build targets "osx10.2" and "osx10.3" to "jaguar" and "panther".
105 #
106 # Revision 1.8 2003/06/04 00:23:12 ksekar
107 # Bug #: <rdar://problem/3218120>: mDNSPosix does not build on Panther that has socklen_t
108 # Created separate target OS's for 10.2 and 10.3.
109 #
110 # Revision 1.7 2003/04/16 02:11:37 cheshire
111 # Remove unnecessary $(CFLAGS) from linking rules
112 #
113 # Revision 1.6 2003/04/04 01:37:14 cheshire
114 # Added NetMonitor.c
115 #
116
117 # This Makefile builds an mDNSResponder daemon and a libmdns.so shared library
118 # for Linux. It also builds several example programs for embedded systems.
119 #
120 # Make with no arguments to build all production targets.
121 # 'make DEBUG=1' to build debugging targets.
122 # 'make clean' or 'make clean DEBUG=1' to delete prod/debug objects & targets
123 # 'sudo make install [DEBUG=1]' to install mdnsd daemon and libmdns.
124 #
125 # Notes:
126 # $@ means "The file name of the target of the rule"
127 # $< means "The name of the first prerequisite"
128 # $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
129 # For more magic automatic variables, see
130 # <http://www.gnu.org/software/make/manual/html_chapter/make_10.html#SEC111>
131
132 #############################################################################
133
134 LIBVERS = 1
135
136 COREDIR = ../mDNSCore
137 SHAREDDIR = ../mDNSShared
138 JDK = /usr/jdk
139
140 CC = cc
141 LD = ld
142 CP = cp
143 RM = rm
144 LN = ln -s -f
145 CFLAGS_COMMON = -I. -I$(COREDIR) -I$(SHAREDDIR) -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\"
146 LDFLAGS = -shared
147 LDSUFFIX = so
148 JAVACFLAGS_OS = -fPIC -shared -lmdns
149
150 # Set up diverging paths for debug vs. prod builds
151 DEBUG=0
152 ifeq ($(DEBUG),1)
153 CFLAGS_DEBUG = -g -DMDNS_DEBUGMSGS=2
154 OBJDIR = objects/debug
155 BUILDDIR = build/debug
156 STRIP = echo
157 else
158 CFLAGS_DEBUG = -Os -DMDNS_DEBUGMSGS=0
159 OBJDIR = objects/prod
160 BUILDDIR = build/prod
161 STRIP = strip -S
162 endif
163
164 # Configure per-OS peculiarities
165 ifeq ($(os),solaris)
166 CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME -lsocket -lnsl
167 else
168 ifeq ($(os),linux)
169 CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK
170 JAVACFLAGS_OS += -I$(JDK)/include/linux
171 else
172 ifeq ($(os),netbsd)
173 CFLAGS_OS =
174 LDCONFIG = ldconfig
175 else
176 ifeq ($(os),freebsd)
177 # If not already defined, set LOCALBASE to /usr/local
178 # FreeBSD requires the startup script to end in ".sh"
179 LOCALBASE?=/usr/local
180 INSTBASE=$(LOCALBASE)
181 STARTUPSCRIPTNAME=mdns.sh
182 CFLAGS_OS =
183 LDCONFIG = ldconfig
184 else
185 ifeq ($(os),openbsd)
186 CFLAGS_OS = -DHAVE_BROKEN_RECVDSTADDR
187 LDCONFIG = ldconfig
188 else
189 ifeq ($(os),jaguar)
190 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -DNOT_HAVE_SOCKLEN_T
191 LD = libtool
192 LDFLAGS = -dynamic -lSystem
193 LDSUFFIX = dylib
194 JDK = /System/Library/Frameworks/JavaVM.framework/Home
195 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
196 else
197 ifeq ($(os),panther)
198 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp
199 LD = libtool
200 LDFLAGS = -dynamic -lSystem
201 LDSUFFIX = dylib
202 JDK = /System/Library/Frameworks/JavaVM.framework/Home
203 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
204 else
205 $(error ERROR: Must specify target OS on command-line: "make os={jaguar,panther,linux,netbsd,freebsd,openbsd,solaris} [target]")
206 endif
207 endif
208 endif
209 endif
210 endif
211 endif
212 endif
213
214 # If not otherwise defined, we install into /usr/lib and /usr/include
215 # and our startup script is called mdns (e.g. /etc/init.d/mdns)
216 INSTBASE?=/usr
217 STARTUPSCRIPTNAME?=mdns
218
219 ifeq ($(HAVE_IPV6),1)
220 CFLAGS_OS += -DHAVE_IPV6=1
221 else
222 ifeq ($(HAVE_IPV6),0)
223 CFLAGS_OS += -DHAVE_IPV6=0
224 endif
225 endif
226
227 # If directory /etc/rc.d/init.d/ exists, then we install into that (old Linux)
228 ifeq ($(wildcard /etc/rc.d/init.d/), /etc/rc.d/init.d/)
229 STARTUPSCRIPTDIR = /etc/rc.d/init.d
230 RUNLEVELSCRIPTSDIR = /etc/rc.d
231 else
232 # else if directory /etc/init.d/ exists, then we install into that (new Linux)
233 ifeq ($(wildcard /etc/init.d/), /etc/init.d/)
234 STARTUPSCRIPTDIR = /etc/init.d
235 RUNLEVELSCRIPTSDIR = /etc
236 else
237 # else install into /etc/rc.d/ (*BSD)
238 STARTUPSCRIPTDIR = $(INSTBASE)/etc/rc.d
239 endif
240 endif
241
242 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUG)
243
244 #############################################################################
245
246 all: setup Daemon libmdns Client Responder ProxyResponder Identify NetMonitor
247
248 install: setup InstalledDaemon InstalledLib InstalledStartup
249
250 # 'setup' sets up the build directory structure the way we want
251 setup:
252 @if test ! -d objects ; then mkdir objects ; fi
253 @if test ! -d build ; then mkdir build ; fi
254 @if test ! -d $(OBJDIR) ; then mkdir $(OBJDIR) ; fi
255 @if test ! -d $(BUILDDIR) ; then mkdir $(BUILDDIR) ; fi
256
257 # clean removes targets and objects
258 clean:
259 if test -d $(OBJDIR) ; then rm -r $(OBJDIR) ; fi
260 if test -d $(BUILDDIR) ; then rm -r $(BUILDDIR) ; fi
261
262 #############################################################################
263
264 # daemon target builds the daemon
265 DAEMONOBJS = $(OBJDIR)/PosixDaemon.c.o $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNS.c.o \
266 $(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/uds_daemon.c.o \
267 $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/dnssd_ipc.c.o $(OBJDIR)/GenLinkedList.c.o
268
269 Daemon: setup $(BUILDDIR)/mdnsd
270 @echo "Responder daemon done"
271
272 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
273 $(CC) -o $@ $+
274 $(STRIP) $@
275
276 # libmdns target builds the client library
277 libmdns: setup $(BUILDDIR)/libmdns.$(LDSUFFIX)
278 @echo "Client library done"
279
280 $(BUILDDIR)/libmdns.$(LDSUFFIX): $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
281 $(LD) $(LDFLAGS) -o $@ $+
282 $(STRIP) $@
283
284 #############################################################################
285
286 # The Install targets place built stuff in their proper places
287 InstalledDaemon: $(INSTBASE)/sbin/mdnsd
288 @echo $< " installed"
289
290 InstalledLib: $(INSTBASE)/lib/libmdns.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
291 @echo $< " installed"
292
293 InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
294 @echo $< " installed"
295
296 $(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd
297 $(CP) $< $@
298
299 $(INSTBASE)/lib/libmdns.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libmdns.$(LDSUFFIX)
300 $(CP) $< $@
301 $(LN) $@ $(INSTBASE)/lib/libmdns.$(LDSUFFIX)
302 ifdef LDCONFIG
303 # -m means 'merge into existing database', -R means 'rescan directories'
304 $(LDCONFIG) -mR
305 endif
306
307 $(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
308 $(CP) $< $@
309
310 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR)
311 $(CP) $< $@
312 chmod ugo+x $@
313 ifdef RUNLEVELSCRIPTSDIR
314 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc2.d/S52mdns
315 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc3.d/S52mdns
316 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc4.d/S52mdns
317 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc5.d/S52mdns
318 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc0.d/K16mdns
319 $(LN) $@ $(RUNLEVELSCRIPTSDIR)/rc6.d/K16mdns
320 endif
321
322 #############################################################################
323
324 # The following targets build Java wrappers for the dns-sd.h API.
325
326 JAVAC = $(JDK)/bin/javac
327 JAVAH = $(JDK)/bin/javah
328 JAVADOC = $(JDK)/bin/javadoc
329 JAR = $(JDK)/bin/jar
330 JAVACFLAGS = $(CFLAGS) $(JAVACFLAGS_OS) -I$(JDK)/include
331
332 Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
333 @echo "Java wrappers done"
334
335 JAVASRC = $(SHAREDDIR)/Java
336 JARCONTENTS = $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
337 $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
338 $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
339 $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
340 $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
341 $(OBJDIR)/com/apple/dnssd/BaseListener.class \
342 $(OBJDIR)/com/apple/dnssd/BrowseListener.class \
343 $(OBJDIR)/com/apple/dnssd/ResolveListener.class \
344 $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
345 $(OBJDIR)/com/apple/dnssd/QueryListener.class \
346 $(OBJDIR)/com/apple/dnssd/DomainListener.class \
347 $(OBJDIR)/com/apple/dnssd/DNSSD.class
348
349 $(BUILDDIR)/dns_sd.jar: $(JARCONTENTS)
350 $(JAR) -cf $@ -C $(OBJDIR) com
351
352 $(BUILDDIR)/libjdns_sd.$(LDSUFFIX): $(JAVASRC)/JNISupport.c $(OBJDIR)/DNSSD.java.h
353 $(CC) -o $@ $< $(JAVACFLAGS) -I$(OBJDIR)
354
355 $(OBJDIR)/com/apple/dnssd/%.class: $(JAVASRC)/%.java
356 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
357
358 $(OBJDIR)/DNSSD.java.h: $(OBJDIR)/com/apple/dnssd/DNSSD.class
359 $(JAVAH) -force -classpath $(OBJDIR) -o $@ \
360 com.apple.dnssd.AppleDNSSD \
361 com.apple.dnssd.AppleBrowser \
362 com.apple.dnssd.AppleResolver \
363 com.apple.dnssd.AppleRegistration \
364 com.apple.dnssd.AppleQuery \
365 com.apple.dnssd.AppleDomainEnum \
366 com.apple.dnssd.AppleService
367
368 #############################################################################
369
370 # The following target builds documentation for the Java wrappers.
371
372 JavaDoc: setup Java
373 $(JAVADOC) $(JAVASRC)/*.java -classpath $(OBJDIR) -d $(BUILDDIR) -public
374
375 #############################################################################
376
377 # The following targets build embedded example programs
378 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
379 COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
380 APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
381
382 Client: setup $(BUILDDIR)/mDNSClientPosix
383 @echo "Embedded Standalone Client done"
384
385 Responder: setup $(BUILDDIR)/mDNSResponderPosix
386 @echo "Embedded Standalone Responder done"
387
388 ProxyResponder: setup $(BUILDDIR)/mDNSProxyResponderPosix
389 @echo "Embedded Standalone ProxyResponder done"
390
391 Identify: setup $(BUILDDIR)/mDNSIdentify
392 @echo "Identify done"
393
394 NetMonitor: setup $(BUILDDIR)/mDNSNetMonitor
395 @echo "NetMonitor done"
396
397 $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
398 $(CC) $+ -o $@
399
400 $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
401 $(CC) $+ -o $@
402
403 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o
404 $(CC) $+ -o $@
405
406 $(BUILDDIR)/mDNSIdentify: $(SPECIALOBJ) $(OBJDIR)/Identify.c.o
407 $(CC) $+ -o $@
408
409 $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
410 $(CC) $+ -o $@
411
412 #############################################################################
413
414 # Implicit rules
415 $(OBJDIR)/%.c.o: %.c
416 $(CC) $(CFLAGS) -c -o $@ $<
417
418 $(OBJDIR)/%.c.o: $(COREDIR)/%.c
419 $(CC) $(CFLAGS) -c -o $@ $<
420
421 $(OBJDIR)/%.c.o: $(SHAREDDIR)/%.c
422 $(CC) $(CFLAGS) -c -o $@ $<
423
424 $(OBJDIR)/%.c.so.o: %.c
425 $(CC) $(CFLAGS) -c -fPIC -o $@ $<
426
427 $(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
428 $(CC) $(CFLAGS) -c -fPIC -o $@ $<