import of dnsmasq-2.41.tar.gz
diff --git a/bld/Makefile b/bld/Makefile
index c072a9a..e622296 100644
--- a/bld/Makefile
+++ b/bld/Makefile
@@ -1,16 +1,14 @@
-CFLAGS ?= -O2
-PKG_CONFIG ?= pkg-config
-
+CFLAGS = -Wall -W -O2
 
 OBJS = cache.o rfc1035.o util.o option.o forward.o isc.o network.o \
        dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
        helper.o tftp.o log.o
 
 .c.o:
-	$(CC) $(CFLAGS) $(COPTS) $(I18N) `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1` $(RPM_OPT_FLAGS) -Wall -W -c $<
+	$(CC) $(CFLAGS) $(COPTS) $(DBUS_MINOR) $(I18N) $(DBUS_CFLAGS) $(SUNOS_VER) $(RPM_OPT_FLAGS) -c $<
 
 dnsmasq : $(OBJS)
-	$(CC) $(LDFLAGS) -o $@  $(OBJS) `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1` $(LIBS) 
+	$(CC) $(LDFLAGS) -o $@  $(OBJS) $(DBUS_LIBS) $(SUNOS_LIBS) $(LIBS) 
  
 dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
 	xgettext -d dnsmasq --foreign-user --keyword=_ -o dnsmasq.pot -i $(OBJS:.o=.c)
diff --git a/bld/install-man b/bld/install-man
index c569f85..f6dea75 100755
--- a/bld/install-man
+++ b/bld/install-man
@@ -2,7 +2,7 @@
 
 for f in *; do
   if [ -d $f ]; then
-     install -d $1/$f/man8 
+     install -m 755 -d $1/$f/man8 
      install -m 644 $f/dnsmasq.8 $1/$f/man8
      echo installing $1/$f/man8/dnsmasq.8
   fi
diff --git a/bld/install-mo b/bld/install-mo
index 725aa81..e6d462a 100755
--- a/bld/install-mo
+++ b/bld/install-mo
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 for f in *.mo; do
-  install -d $1/${f%.mo}/LC_MESSAGES
+  install -m 755 -d $1/${f%.mo}/LC_MESSAGES
   install -m 644 $f $1/${f%.mo}/LC_MESSAGES/dnsmasq.mo
   echo installing $1/${f%.mo}/LC_MESSAGES/dnsmasq.mo
 done
diff --git a/bld/pkg-wrapper b/bld/pkg-wrapper
index 55efced..66859e2 100755
--- a/bld/pkg-wrapper
+++ b/bld/pkg-wrapper
@@ -1,6 +1,7 @@
 #!/bin/sh
 
-if grep -q "^\#.*define.*HAVE_DBUS" config.h || grep -q HAVE_DBUS ; then
+if grep "^\#.*define.*HAVE_DBUS" config.h 2>&1 >/dev/null || \
+   grep HAVE_DBUS 2>&1 >/dev/null ; then
   exec $*
 fi