--- setup.py.orig	2013-11-22 11:52:20.000000000 -0800
+++ setup.py	2018-04-14 15:08:56.000000000 -0700
@@ -65,7 +65,7 @@
         if rc != 0:
             print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
 
-AMALGAMATION_ROOT = "amalgamation/libspatialite-amalgamation-3.0.1"
+#AMALGAMATION_ROOT = "amalgamation/libspatialite-amalgamation-3.0.1"
 
 TRUTHY = ("yes", "true", "t", "1")
 
@@ -162,7 +162,10 @@
 
     def build_extension(self,ext):
         # Load includes from module directories first!
-        include_dirs = []
+        include_dirs = [
+		"%%PROJ4_PREFIX%%/include",
+		"%%PREFIX%%/include"
+	]
         include_dirs.extend(self.strip_includes(self.compiler.compiler))
         include_dirs.extend(self.strip_includes(self.compiler.compiler_so))
         include_dirs.extend(self.strip_includes(self.compiler.compiler_cxx))
@@ -258,21 +261,24 @@
                         "src/prepare_protocol.c",
                         "src/statement.c",
                         "src/util.c",
-                        "src/row.c",
-                        os.path.join(AMALGAMATION_ROOT, "sqlite3.c"),
-                        os.path.join(AMALGAMATION_ROOT, "spatialite.c")
+                        "src/row.c"#,
+                        #os.path.join(AMALGAMATION_ROOT, "sqlite3.c"),
+                        #os.path.join(AMALGAMATION_ROOT, "spatialite.c")
                     ],
                     include_dirs = [
-                        os.path.join(AMALGAMATION_ROOT,"headers")
+                        "%%PROJ4_PREFIX%%/include",
+                        "%%PREFIX%%/include"
                     ],
-                    library_dirs = [],
+                    library_dirs = [
+                        "%%PROJ4_PREFIX%%/lib"
+		    ],
                     runtime_library_dirs = [],
                     extra_objects = [],
                     define_macros = [
                         ("VERSION",'"%s"' % PYSPATIALITE_VERSION),
                         ("SQLITE_ENABLE_RTREE", "1"),   # build with fulltext search enabled
                         ("NDEBUG","1"),
-                        ("SPL_AMALGAMATION","1"),
+                        #("SPL_AMALGAMATION","1"),
                         ('MODULE_NAME', '\\"spatialite.dbapi2\\"') if sys.platform == "win32" else ('MODULE_NAME', '"spatialite.dbapi2"')
                     ],
                 )
