3 # Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # This Makefile builds a .jar file and accompanying JNI support library
18 # containing the DNSSD implementation for Java and support classes.
20 # Prior to building Java support, you must build DNSSD.dll.
22 # nmake with no arguments builds all production targets.
23 # 'nmake DEBUG=1' to build debugging targets.
24 # 'nmake clean' or 'nmake clean DEBUG=1' to delete prod/debug objects & targets
26 # To run nmake, you may need to set up your PATH correctly, using a script
27 # such as: "\Program Files\Microsoft Visual Studio .NET\Vc7\bin\vcvars32.bat"
29 # The default location of the JDK is \javasdk. You can override this on the
30 # command line (e.g. 'nmake JDK=\j2dk1.4.2_03').
32 ############################################################################
34 COREDIR = ..\..\mDNSCore
35 SHAREDDIR = ..\..\mDNSShared
45 JAVAC = $(JDK)\bin\javac
46 JAVAH = $(JDK)\bin\javah
48 CFLAGS_COMMON = -LD -DAUTO_CALLBACKS=0 -I. -I..\.. \
49 -I$(COREDIR) -I$(SHAREDDIR) -I$(JDK)\include -I$(JDK)\include\win32
51 # Set up diverging paths for debug vs. prod builds
54 CFLAGS_DEBUG = -Zi -DMDNS_DEBUGMSGS=2
55 OBJDIR = objects\debug\x64
56 BUILDDIR = build\debug\x64
57 INSTALLDIR = root\"Program Files"\Bonjour
58 LIBDIR = ..\DLL\x64\Debug
60 CFLAGS_DEBUG = -Os -DMDNS_DEBUGMSGS=0
61 OBJDIR = objects\prod\x64
62 BUILDDIR = build\prod\x64
63 INSTALLDIR = root\"Program Files"\Bonjour
64 LIBDIR = ..\DLL\x64\Release
67 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_DEBUG)
68 JAVACFLAGS = $(CFLAGS) $(JAVACFLAGS_OS)
70 #############################################################################
72 all: setup Java postbuild
74 # 'setup' sets up the build directory structure the way we want
76 @if not exist objects mkdir objects
77 @if not exist build mkdir build
78 @if not exist $(OBJDIR) mkdir $(OBJDIR)
79 @if not exist $(BUILDDIR) mkdir $(BUILDDIR)
82 @if not "%RC_XBS%"=="YES" GOTO CONT
83 @if not exist "$(DSTROOT)\WINDOWS\system32\x64" mkdir "$(DSTROOT)\WINDOWS\system32\x64"
84 @if not exist "$(DSTROOT)\Program Files\Bonjour\x64" mkdir "$(DSTROOT)\Program Files\Bonjour\x64"
85 @copy $(BUILDDIR)\jdns_sd.dll "$(DSTROOT)\WINDOWS\system32\x64"
86 @copy $(BUILDDIR)\dns_sd.jar "$(DSTROOT)\Program Files\Bonjour\x64"
88 @if not exist root mkdir root
89 @if not exist root\"Program Files" mkdir root\"Program Files"
90 @if not exist $(INSTALLDIR) mkdir $(INSTALLDIR)
91 copy $(BUILDDIR)\dns_sd.jar $(INSTALLDIR)
92 copy $(BUILDDIR)\jdns_sd.dll $(INSTALLDIR)
94 # clean removes targets and objects
96 @if exist $(OBJDIR) $(RMDIR) $(OBJDIR)
97 @if exist $(BUILDDIR) $(RMDIR) $(BUILDDIR)
99 #############################################################################
101 # The following targets build Java wrappers for the dns-sd.h API.
103 Java: setup $(BUILDDIR)\dns_sd.jar $(BUILDDIR)\jdns_sd.dll postbuild
104 @echo "Java wrappers done"
106 JAVASRC = $(SHAREDDIR)\Java
107 JARCONTENTS = $(OBJDIR)\com\apple\dnssd\DNSSDService.class \
108 $(OBJDIR)\com\apple\dnssd\DNSSDException.class \
109 $(OBJDIR)\com\apple\dnssd\DNSRecord.class \
110 $(OBJDIR)\com\apple\dnssd\TXTRecord.class \
111 $(OBJDIR)\com\apple\dnssd\DNSSDRegistration.class \
112 $(OBJDIR)\com\apple\dnssd\DNSSDRecordRegistrar.class \
113 $(OBJDIR)\com\apple\dnssd\BaseListener.class \
114 $(OBJDIR)\com\apple\dnssd\BrowseListener.class \
115 $(OBJDIR)\com\apple\dnssd\ResolveListener.class \
116 $(OBJDIR)\com\apple\dnssd\RegisterListener.class \
117 $(OBJDIR)\com\apple\dnssd\RegisterRecordListener.class \
118 $(OBJDIR)\com\apple\dnssd\QueryListener.class \
119 $(OBJDIR)\com\apple\dnssd\DomainListener.class \
120 $(OBJDIR)\com\apple\dnssd\DNSSD.class
122 $(BUILDDIR)\dns_sd.jar: $(JARCONTENTS)
123 $(JAR) -cf $@ -C $(OBJDIR) com
125 $(BUILDDIR)\jdns_sd.dll: $(JAVASRC)\JNISupport.c $(OBJDIR)\DNSSD.java.h $(OBJDIR)\jdns_sd.RES
126 $(CC) -Fe$@ $(JAVASRC)\JNISupport.c $(CFLAGS) -I$(OBJDIR) \
127 $(LIBDIR)\DNSSD.lib $(JDK)\lib\jvm.lib ws2_32.lib iphlpapi.lib $(OBJDIR)\jdns_sd.RES /link /NXCOMPAT /DYNAMICBASE
130 {$(JAVASRC)}.java{$(OBJDIR)\com\apple\dnssd}.class:
131 $(JAVAC) -d $(OBJDIR) -classpath $(OBJDIR) $<
133 $(OBJDIR)\DNSSD.java.h: $(OBJDIR)\com\apple\dnssd\DNSSD.class
134 $(JAVAH) -classpath $(OBJDIR) -o $@ \
135 com.apple.dnssd.AppleBrowser \
136 com.apple.dnssd.AppleResolver \
137 com.apple.dnssd.AppleRegistration \
138 com.apple.dnssd.AppleQuery \
139 com.apple.dnssd.AppleService
141 $(OBJDIR)\jdns_sd.RES: jdns_sd.rc