Build script adjustments

Based on Apple's documentation (https://developer.apple.com/library/content/
documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html)
custom paths must not be used for binaries, as they are left unsigned by
codesign app.

Change-Id: I628a3a9da15dfdbbf515b4c16a3d38590ae433f5
diff --git a/make-osx-bundle.py b/make-osx-bundle.py
index 4a78a58..dfbbbe4 100755
--- a/make-osx-bundle.py
+++ b/make-osx-bundle.py
@@ -261,10 +261,20 @@
     print ' * Copying NDN dependencies'
 
     src = os.path.join(path, 'bin')
-    dst = os.path.join(self.bundle, 'Contents', 'Platform')
-    shutil.copytree(src, dst, symlinks=False)
+    dstBinary = os.path.join(self.bundle, 'Contents', 'Helpers')
+    dstResource = os.path.join(self.bundle, 'Contents', 'Resources', 'bin')
+    os.makedirs(dstBinary)
+    os.makedirs(dstResource)
 
-    for subdir, dirs, files in os.walk(dst):
+    for file in os.listdir(src):
+      ftype = Popen(['/usr/bin/file', '-b', "%s/%s" % (src, file)], stdout=PIPE).communicate()[0]
+      if "Mach-O" in ftype:
+        shutil.copy("%s/%s" % (src, file), "%s/%s" % (dstBinary, file))
+      else:
+        shutil.copy("%s/%s" % (src, file), "%s/%s" % (dstResource, file))
+        Popen(['/usr/bin/sed', '-i', '', '-e', 's|`dirname "$0"`/|`dirname "$0"`/../../Helpers/|', "%s/%s" % (dstResource, file)]).communicate()[0]
+
+    for subdir, dirs, files in os.walk(dstBinary):
       for file in files:
         abs = subdir + "/" + file
         self.handle_binary_libs(abs)