Importing the skeleton of system tray implementation and making sure it compiles and works

There was an interesting "problem" due to automatic reference counting
(-fobjc-arc flag).  XCode includes this flag by default, so making sure
that wscript is doing the same thing.
diff --git a/wscript b/wscript
index 6f0c6b9..53d044b 100644
--- a/wscript
+++ b/wscript
@@ -16,10 +16,18 @@
         return -1
 
     if Utils.unversioned_sys_platform () == "darwin":
-        conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', compile_filename='test.mm')
-        conf.check_cxx(framework_name='AppKit',     uselib_store='OSX_APPKIT',     compile_filename='test.mm')
-        conf.check_cxx(framework_name='Cocoa',      uselib_store='OSX_COCOA',     compile_filename='test.mm')
+        conf.find_program('ibtool', var='IBTOOL', mandatory=False)
 
+        conf.check_cxx(framework_name='Foundation', uselib_store='FOUNDATION', compile_filename='test.mm')
+        conf.check_cxx(framework_name='AppKit',     uselib_store='APPKIT',     compile_filename='test.mm')
+        conf.check_cxx(framework_name='Cocoa',      uselib_store='COCOA',      compile_filename='test.mm')
+
+        conf.env.ARCH_OSX = 'x86_64'
+        conf.env.CXXFLAGS_OSX += ['-fobjc-arc', '-mmacosx-version-min=10.8']
+        conf.env.LINKFLAGS_OSX += ['-mmacosx-version-min=10.8']
+        
+        conf.env.MACOSX_DEPLOYMENT_TARGET = '10.8'
+        
         conf.load('sparkle')
 
 def build (bld):
@@ -32,17 +40,50 @@
             target = "NDNx Control Center",
             features=['cxxprogram', 'cxx'],
             includes = "osx",
-            mac_app = "NDNx Control Center.app",
-            source = bld.path.ant_glob ('osx/**/*.mm'),
-            use = "OSX_FOUNDATION OSX_APPKIT OSX_COCOA OSX_SPARKLE",
+            source = bld.path.ant_glob (['osx/**/*.mm', 'osx/MainMenu.xib']),
+            
+            mac_app = True,
+            use = "OSX COCOA FOUNDATION APPKIT SPARKLE",
 
-            mac_plist = bld.path.find_resource('osx/Info.plist').read (),
-            mac_resources = 'osx/ndnx-main.icns osx/ndnx-tray.icns',
+            mac_plist = 'osx/Info.plist',
+            mac_resources = 'osx/Resources/ndnx-main.icns osx/Resources/ndnx-tray.icns',
             mac_frameworks = "osx/Frameworks/Sparkle.framework",
             )
 
+        
 from waflib import TaskGen
 @TaskGen.extension('.mm')
 def m_hook(self, node):
     """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
     return self.create_compiled_task('cxx', node)
+
+@TaskGen.extension('.m')
+def m_hook(self, node):
+    """Alias .m files to be compiled the same as .c files, gcc/clang will do the right thing."""
+    return self.create_compiled_task('c', node)
+
+
+def bundle_name_for_output(name):
+	k = name.rfind('.')
+	if k >= 0:
+		name = name[:k] + '.app'
+	else:
+		name = name + '.app'
+	return name
+
+@TaskGen.extension('.xib')
+def xib(self,node):
+    out = node.change_ext ('.nib')
+
+    name = self.path.get_bld ().find_or_declare (bundle_name_for_output(self.target))
+    resources = name.find_or_declare(['Contents', 'Resources'])
+    resources.mkdir()
+    real_out = resources.make_node (out.name)
+
+    self.create_task('xib', node, real_out)
+    inst_to = getattr(self, 'install_path', '/Applications') + '/%s/Resources' % name
+    self.bld.install_as (inst_to + '/%s' % real_out.name, real_out)
+        
+class xib(Task.Task):
+    color='PINK'
+    run_str = '${IBTOOL} --errors --warnings --notices --minimum-deployment-target 10.8 --output-format human-readable-text  --compile ${TGT} ${SRC}'