pylibfdt: Don't have setup.py depend on where it's invoked from

Currently setup.py depends on being invoked from the right directory
(specifically it needs to be run from the root of the project).  That's a
bit confusing.

This updates setup.py to no longer depend on the invoking directory by
instead having it change directory to the location of the script itself,
then using internal paths relative to that.

Signed-off-by: David Gibson <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index f0f0e10..bd8ccf8 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -16,18 +16,21 @@
 
 
 def get_version():
-    version_file = "version_gen.h"
+    version_file = "../version_gen.h"
     f = open(version_file, 'rt')
     m = re.match(VERSION_PATTERN, f.readline())
     return m.group(1)
 
+setupdir = os.path.dirname(os.path.abspath(sys.argv[0]))
+os.chdir(setupdir)
 
 libfdt_module = Extension(
     '_libfdt',
-    sources = ['pylibfdt/libfdt.i'],
-    include_dirs = ['libfdt'],
+    sources = ['libfdt.i'],
+    include_dirs = ['../libfdt'],
     libraries = ['fdt'],
-    library_dirs = ['libfdt'],
+    library_dirs = ['../libfdt'],
+    swig_opts = ['-I../libfdt'],
 )
 
 setup(
@@ -36,5 +39,5 @@
     author='Simon Glass <[email protected]>',
     description='Python binding for libfdt',
     ext_modules=[libfdt_module],
-    py_modules=['pylibfdt/libfdt'],
+    py_modules=['libfdt'],
 )