--- /dev/null
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mDNSResponder
+PKG_VERSION:=107.6
+PKG_RELEASE:=1
+PKG_INSTALL:=1
+PKG_SOURCE:=mDNSResponder-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.opensource.apple.com/darwinsource/tarballs/other/
+PKG_MD5SUM:=aa4e0e5c57f94489463ea6576591ce9d
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/mDNSResponder-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/mdnsresponder
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=mDNSResponder
+ URL:=http://developer.apple.com/networking/bonjour/
+endef
+
+define Package/mdnsresponder/decription
+ Bonjour, also known as zero-configuration networking, enables
+ automatic discovery of computers, devices, and services on
+ IP networks.
+endef
+
+define Build/Configure
+ $(call Build/Configure/Default)
+endef
+
+# I have no idea why -lc is required, but without it, C library symbols are
+# not found:
+MAKE_FLAGS += \
+ LINKOPTS=-lc \
+ LDCONFIG= \
+ ETCBASE="$(PKG_INSTALL_DIR)/etc" \
+ INSTBASE="$(PKG_INSTALL_DIR)/usr" \
+ NSSINSTPATH="$(PKG_INSTALL_DIR)/lib" \
+ MANPATH="$(PKG_INSTALL_DIR)/usr/man" \
+ STARTUPSCRIPTDIR="$(PKG_INSTALL_DIR)/etc/init.d" \
+ RUNLEVELSCRIPTSDIR="$(PKG_INSTALL_DIR)/etc/rc.d" \
+ os=linux-uclibc
+MAKE_PATH = mDNSPosix
+
+define Build/Compile
+ $(call Build/Compile/Default)
+ # mDNSResponder's "make install" does not seem to create:
+ mkdir -p $(PKG_INSTALL_DIR)/lib/
+ mkdir -p $(PKG_INSTALL_DIR)/usr/bin/
+ mkdir -p $(PKG_INSTALL_DIR)/usr/sbin/
+ mkdir -p $(PKG_INSTALL_DIR)/usr/lib/
+ mkdir -p $(PKG_INSTALL_DIR)/usr/man/man5/
+ mkdir -p $(PKG_INSTALL_DIR)/usr/man/man8/
+ mkdir -p $(PKG_INSTALL_DIR)/usr/include/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/init.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/rc2.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/rc3.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/rc4.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/rc5.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/rc0.d/
+ mkdir -p $(PKG_INSTALL_DIR)/etc/rc.d/rc6.d/
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/
+ $(CP) $(PKG_BUILD_DIR)/mDNSShared/dns_sd.h $(1)/usr/include/
+ $(INSTALL_DIR) $(1)/usr/lib/
+ $(CP) \
+ $(PKG_BUILD_DIR)/mDNSPosix/build/prod/*.so* \
+ $(1)/usr/lib/
+ $(INSTALL_DIR) $(1)/usr/sbin/
+endef
+
+define Package/mdnsresponder/install
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/mDNSResponder.init $(1)/etc/init.d/mDNSResponder
+ $(INSTALL_DIR) $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libdns_sd.so.1 $(1)/usr/lib/
+ # Note: mDNSResponder's makefile creates the following link incorrectly:
+ ln -s libdns_sd.so.1 $(1)/usr/lib/libdns_sd.so
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(CP) $(PKG_BUILD_DIR)/mDNSPosix/build/prod/mdnsd $(1)/usr/sbin/
+ $(CP) $(PKG_BUILD_DIR)/mDNSPosix/build/prod/mDNSResponderPosix $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,mdnsresponder))
--- /dev/null
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2009 OpenWrt.org
+
+START=60
+
+start() {
+ /usr/sbin/mDNSResponderPosix -b -f /etc/mdns.conf
+ /usr/sbin/mdnsd
+}
+
+stop() {
+ killall mDNSResponderPosix 2> /dev/null
+ killall mdnsd 2> /dev/null
+}
--- /dev/null
+Only in mDNSResponder-107.6/Clients: build
+diff -u --recursive mDNSResponder-107.6-vanilla/Clients/Makefile mDNSResponder-107.6/Clients/Makefile
+--- mDNSResponder-107.6-vanilla/Clients/Makefile 2009-10-16 07:06:53.290266578 -0400
++++ mDNSResponder-107.6/Clients/Makefile 2009-10-17 04:28:28.447826030 -0400
+@@ -49,6 +49,8 @@
+
+ #############################################################################
+
++CC = @cc
++
+ # On OS X the dns_sd library functions are included in libSystem, which is implicitly linked with every executable
+ # 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
+ ifneq "$(wildcard /usr/lib/libSystem.dylib)" ""
+@@ -66,4 +68,4 @@
+ mkdir build
+
+ build/dns-sd: build dns-sd.c
+- cc $(filter %.c %.o, $+) $(LIBS) -I../mDNSShared -o $@
++ $(CC) $(filter %.c %.o, $+) $(LIBS) -I../mDNSShared -o $@
+diff -u --recursive mDNSResponder-107.6-vanilla/mDNSPosix/Makefile mDNSResponder-107.6/mDNSPosix/Makefile
+--- mDNSResponder-107.6-vanilla/mDNSPosix/Makefile 2009-10-16 07:06:53.303266301 -0400
++++ mDNSResponder-107.6/mDNSPosix/Makefile 2009-10-17 06:36:22.154299346 -0400
+@@ -267,8 +267,9 @@
+ SHAREDDIR = ../mDNSShared
+ JDK = /usr/jdk
+
+-CC = @cc
+-LD = ld -shared
++CC = @gcc
++LD = @ld
++SOOPTS = -shared
+ CP = cp
+ RM = rm
+ LN = ln -s -f
+@@ -293,7 +294,7 @@
+ CFLAGS_DEBUG = -Os -DMDNS_DEBUGMSGS=0
+ OBJDIR = objects/prod
+ BUILDDIR = build/prod
+-STRIP = strip -S
++STRIP = @strip -S
+ endif
+
+ # Configure per-OS peculiarities
+@@ -301,7 +302,7 @@
+ CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
+ -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME
+ CC = gcc
+-LD = gcc -shared
++LD = gcc
+ LINKOPTS = -lsocket -lnsl -lresolv
+ JAVACFLAGS_OS += -I$(JDK)/include/solaris
+ ifneq ($(DEBUG),1)
+@@ -347,7 +348,8 @@
+
+ ifeq ($(os),jaguar)
+ CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -DNOT_HAVE_SOCKLEN_T
+-LD = libtool -dynamic
++LD = libtool
++SOOPTS = -dynamic
+ LINKOPTS = -lSystem
+ LDSUFFIX = dylib
+ JDK = /System/Library/Frameworks/JavaVM.framework/Home
+@@ -356,7 +358,8 @@
+
+ ifeq ($(os),panther)
+ CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror
+-LD = libtool -dynamic
++LD = libtool
++SOOPTS = -dynamic
+ LINKOPTS = -lSystem
+ LDSUFFIX = dylib
+ JDK = /System/Library/Frameworks/JavaVM.framework/Home
+@@ -366,7 +369,8 @@
+ ifeq ($(os),tiger)
+ CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement #-Wunreachable-code
+ CC = @gcc-4.0
+-LD = $(CC) -dynamiclib
++LD = $(CC)
++SOOPTS = -dynamiclib
+ LINKOPTS = -lSystem
+ LDSUFFIX = dylib
+ JDK = /System/Library/Frameworks/JavaVM.framework/Home
+@@ -390,8 +394,9 @@
+ NSSLINKNAME := $(NSSLIBNAME).so.2
+ NSSINSTPATH := /lib
+
+-# If not otherwise defined, we install into /usr/lib and /usr/include
++# If not otherwise defined, we install into /usr/lib, /usr/include & /etc
+ # and our startup script is called mdns (e.g. /etc/init.d/mdns)
++ETCBASE?=/etc
+ INSTBASE?=/usr
+ STARTUPSCRIPTNAME?=mdns
+
+@@ -473,7 +478,7 @@
+ CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
+
+ $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
+- @$(LD) $(LINKOPTS) -o $@ $+
++ @$(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+
+ @$(STRIP) $@
+
+ Clients: setup libdns_sd ../Clients/build/dns-sd
+@@ -508,7 +513,7 @@
+ InstalledClients: $(INSTBASE)/bin/dns-sd
+ @echo $+ " installed"
+
+-InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
++InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) $(ETCBASE)/nss_mdns.conf $(MANPATH)/man5/nss_mdns.conf.5 $(MANPATH)/man8/libnss_mdns.8
+ @echo $+ " installed"
+
+ # Note: If daemon already installed, we make sure it's stopped before overwriting it
+@@ -563,19 +568,21 @@
+
+ $(NSSINSTPATH)/$(NSSLINKNAME): $(NSSINSTPATH)/$(NSSLIBFILE)
+ $(LN) $< $@
+- ldconfig
++ifdef LDCONFIG
++ $(LDCONFIG)
++endif
+
+ $(NSSINSTPATH)/$(NSSLIBFILE): $(BUILDDIR)/$(NSSLIBFILE)
+ $(CP) $< $@
+ chmod 444 $@
+
+-/etc/nss_mdns.conf: nss_mdns.conf
++$(ETCBASE)/nss_mdns.conf: nss_mdns.conf
+ $(CP) $< $@
+ chmod 444 $@
+ # Check the nsswitch.conf file.
+ # If 'mdns' does not already appear on the "hosts:" line, then add it right before 'dns'
+- cp -f /etc/nsswitch.conf /etc/nsswitch.conf.pre-mdns
+- sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' /etc/nsswitch.conf.pre-mdns > /etc/nsswitch.conf
++ -[ -f $(ETCBASE)/nsswitch.conf ] && cp -f $(ETCBASE)/nsswitch.conf $(ETCBASE)/nsswitch.conf.pre-mdns
++ -[ -f $(ETCBASE)/nsswitch.conf ] && sed -e '/mdns/!s/^\(hosts:.*\)dns\(.*\)/\1mdns dns\2/' $(ETCBASE)/nsswitch.conf.pre-mdns > $(ETCBASE)/nsswitch.conf
+
+ #############################################################################
+
--- /dev/null
+diff -u --recursive mDNSResponder-107.6-vanilla/mDNSPosix/Makefile mDNSResponder-107.6/mDNSPosix/Makefile
+--- mDNSResponder-107.6-vanilla/mDNSPosix/Makefile 1970-01-01 08:24:35.000000000 -0500
++++ mDNSResponder-107.6/mDNSPosix/Makefile 1970-01-01 08:32:57.000000000 -0500
+@@ -309,11 +309,15 @@
+ endif
+ else
+
+-ifeq ($(os),linux)
++# Any variant containing linux:
++ifeq ($(findstring linux,$(os)),linux)
+ CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX
+ JAVACFLAGS_OS += -I$(JDK)/include/linux
++# uClibc does not provide NSS, do not compile nss_mdns:
++ifneq ($(os),linux-uclibc)
+ OPTIONALTARG = nss_mdns
+ OPTINSTALL = InstalledNSS
++endif
+ else
+
+ ifeq ($(os),netbsd)