get tests running on MacOS X
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d3a357f..1ec860d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,7 +9,7 @@
 if PAM
 check_LTLIBRARIES = libtestpam_preload.la
 libtestpam_preload_la_SOURCES = testpam_preload.c
-libtestpam_preload_la_LDFLAGS = -module -no-undefined -avoid-version -rpath /foo
+libtestpam_preload_la_LDFLAGS = -no-undefined -avoid-version -rpath /foo
 
 check_PROGRAMS = testpam
 testpam_LDADD = -lpam
diff --git a/tests/login_duo-0.t b/tests/login_duo-0.t
index 42e467b..a22e56a 100644
--- a/tests/login_duo-0.t
+++ b/tests/login_duo-0.t
@@ -13,7 +13,7 @@
 
 Bad permissions on conf file
 
-  $ install -c -m 644 ${TESTDIR}/confs/duo.conf ${TMPDIR}
+  $ ${TESTDIR}/../autotools/install-sh -c -m 644 ${TESTDIR}/confs/duo.conf ${TMPDIR}
   $ ${BUILDDIR}/login_duo/login_duo -d -c ${TMPDIR}/duo.conf true
   */duo.conf must be readable only by user '*' (glob)
 
diff --git a/tests/pam_duo-0.t b/tests/pam_duo-0.t
index 782ecf4..9b58227 100644
--- a/tests/pam_duo-0.t
+++ b/tests/pam_duo-0.t
@@ -13,7 +13,7 @@
 
 Bad permissions on conf file
 
-  $ install -c -m 644 ${TESTDIR}/confs/duo.conf ${TMPDIR}
+  $ ${TESTDIR}/../autotools/install-sh -c -m 644 ${TESTDIR}/confs/duo.conf ${TMPDIR}
   $ ${TESTDIR}/testpam.py -d -c ${TMPDIR}/duo.conf true
   */duo.conf must be readable only by user '*' (glob)
   [1]
diff --git a/tests/testpam.py b/tests/testpam.py
index 311d282..125e323 100755
--- a/tests/testpam.py
+++ b/tests/testpam.py
@@ -41,14 +41,26 @@
     if opt_host:
         args.append(opt_host)
     
+    topbuilddir = os.path.realpath(build + '/..')
+
     f = tempfile.NamedTemporaryFile()
+    #f = open('/tmp/pam.conf', 'w')
+    if sys.platform == 'sunos5':
+        f.write('testpam ')
     f.write('auth  required  %s/pam_duo.so conf=%s debug' %
-            (os.path.realpath(build + '/../pam_duo/.libs'), opt_conf))
+            (topbuilddir + '/pam_duo/.libs', opt_conf))
     f.flush()
     
     env = os.environ.copy()
-    env['LD_PRELOAD'] = os.path.realpath(build + '/.libs/libtestpam_preload.so')
     env['PAM_CONF'] = f.name
+
+    if sys.platform == 'darwin':
+        env['DYLD_LIBRARY_PATH'] = topbuilddir + '/lib/.libs'
+        env['DYLD_INSERT_LIBRARIES'] = topbuilddir + '/tests/.libs/libtestpam_preload.dylib'
+        env['DYLD_FORCE_FLAT_NAMESPACE'] = '1'
+    else:
+        env['LD_PRELOAD'] = topbuilddir + '/tests/.libs/libtestpam_preload.so'
+        
     p = subprocess.Popen(args, env=env)
     p.wait()
     f.close()