From: Ruben Undheim <ruben.undheim@gmail.com>
Date: Tue, 14 Jun 2016 18:46:08 +0200
Subject: Install the python programs and the iceboxdb module in
 /usr/share/fpga-icestorm/python,
 instead of in /usr/bin where upstream wants to put them.

The rationale for this is that icebox imports iceboxdb, so iceboxdb needs
to be findable by the python importer, but iceboxdb is not useful for any
program other than icebox, so it should not be in the normal system-wide
python include path.
---
 icebox/Makefile    | 26 +++++++++++++-------------
 icetime/icetime.cc | 21 +--------------------
 2 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/icebox/Makefile b/icebox/Makefile
index 43d4664..83796a1 100644
--- a/icebox/Makefile
+++ b/icebox/Makefile
@@ -15,19 +15,19 @@ clean:
 	rm -f icebox.pyc iceboxdb.pyc
 
 install: all
-	mkdir -p $(DESTDIR)$(PREFIX)/share/icebox
-	mkdir -p $(DESTDIR)$(PREFIX)/bin
-	cp chipdb-1k.txt     $(DESTDIR)$(PREFIX)/share/icebox/
-	cp chipdb-8k.txt     $(DESTDIR)$(PREFIX)/share/icebox/
-	cp icebox.py         $(DESTDIR)$(PREFIX)/bin/icebox.py
-	cp iceboxdb.py       $(DESTDIR)$(PREFIX)/bin/iceboxdb.py
-	cp icebox_chipdb.py  $(DESTDIR)$(PREFIX)/bin/icebox_chipdb
-	cp icebox_diff.py    $(DESTDIR)$(PREFIX)/bin/icebox_diff
-	cp icebox_explain.py $(DESTDIR)$(PREFIX)/bin/icebox_explain
-	cp icebox_colbuf.py  $(DESTDIR)$(PREFIX)/bin/icebox_colbuf
-	cp icebox_html.py    $(DESTDIR)$(PREFIX)/bin/icebox_html
-	cp icebox_maps.py    $(DESTDIR)$(PREFIX)/bin/icebox_maps
-	cp icebox_vlog.py    $(DESTDIR)$(PREFIX)/bin/icebox_vlog
+	mkdir -p $(DESTDIR)$(PREFIX)/share/fpga-icestorm/chipdb
+	mkdir -p $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python
+	cp chipdb-1k.txt     $(DESTDIR)$(PREFIX)/share/fpga-icestorm/chipdb/
+	cp chipdb-8k.txt     $(DESTDIR)$(PREFIX)/share/fpga-icestorm/chipdb/
+	cp icebox.py         $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox.py
+	cp iceboxdb.py       $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/iceboxdb.py
+	cp icebox_chipdb.py  $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_chipdb
+	cp icebox_diff.py    $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_diff
+	cp icebox_explain.py $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_explain
+	cp icebox_colbuf.py  $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_colbuf
+	cp icebox_html.py    $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_html
+	cp icebox_maps.py    $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_maps
+	cp icebox_vlog.py    $(DESTDIR)$(PREFIX)/share/fpga-icestorm/python/icebox_vlog
 
 uninstall:
 	rm -f $(DESTDIR)$(PREFIX)/bin/icebox.py
diff --git a/icetime/icetime.cc b/icetime/icetime.cc
index 252d820..c68b997 100644
--- a/icetime/icetime.cc
+++ b/icetime/icetime.cc
@@ -276,26 +276,7 @@ void read_chipdb()
 {
 	char buffer[1024];
 
-	if (PREFIX[0] == '~' && PREFIX[1] == '/') {
-		std::string homedir;
-#ifdef _WIN32
-		if (getenv("USERPROFILE") != nullptr) {
-			homedir += getenv("USERPROFILE");
-		}
-		else {
-			if (getenv("HOMEDRIVE") != nullptr &&
-			    getenv("HOMEPATH") != nullptr) {
-				homedir += getenv("HOMEDRIVE");
-				homedir += getenv("HOMEPATH");
-			}
-		}
-#else
-		homedir += getenv("HOME");
-#endif
-		snprintf(buffer, 1024, "%s%s/share/icebox/chipdb-%s.txt", homedir.c_str(), PREFIX+1, config_device.c_str());
-	}
-	else
-		snprintf(buffer, 1024, "%s/share/icebox/chipdb-%s.txt", PREFIX, config_device.c_str());
+	snprintf(buffer, 1024, "/usr/share/fpga-icestorm/chipdb/chipdb-%s.txt", config_device.c_str());
 
 	FILE *fdb = fopen(buffer, "r");
 	if (fdb == nullptr) {
