1# -*- tab-width: 4 -*-
2#
3# Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
4#
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
8# 
9#     http://www.apache.org/licenses/LICENSE-2.0
10# 
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.
16#
17# Notes:
18# $@ means "The file name of the target of the rule"
19# $< means "The name of the first prerequisite"
20# $+ means "The names of all the prerequisites, with spaces between them, exactly as given"
21# For more magic automatic variables, see
22# <http://www.gnu.org/software/make/manual/html_chapter/make_10.html#SEC111>
23
24#############################################################################
25
26# On OS X the dns_sd library functions are included in libSystem, which is implicitly linked with every executable
27# If /usr/lib/libSystem.dylib exists, then we're on OS X, so we don't need also to link the "dns_sd" shared library
28ifneq "$(wildcard /usr/lib/libSystem.dylib)" ""
29TARGETS = build/dns-sd build/dns-sd64
30LIBS =
31else
32TARGETS = build/dns-sd
33LIBS = -L../mDNSPosix/build/prod/ -ldns_sd
34endif
35
36all: $(TARGETS)
37
38clean:
39	rm -rf build
40
41build:
42	mkdir build
43
44build/dns-sd: build dns-sd.c ClientCommon.c
45	cc $(filter %.c %.o, $+) $(LIBS) -I../mDNSShared -Wall -o $@
46
47build/dns-sd64: build dns-sd.c ClientCommon.c
48	cc $(filter %.c %.o, $+) $(LIBS) -I../mDNSShared -Wall -o $@ -m64
49
50# Note, we can make a 'fat' version of dns-sd using 'lipo', as shown below, but we
51# don't, because we don't want or need a 'fat' version of dns-sd, because it will
52# never need to access more than 4GB of data. We build the 64-bit version purely so
53# we have a test tool for making sure that the APIs work properly from 64-bit clients.
54# lipo -create dns-sd dns-sd64 -output dns-sd-fat
55