Added API and Makefile rules for share/ files
authorClifford Wolf <clifford@clifford.at>
Sun, 27 Oct 2013 08:33:26 +0000 (09:33 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 27 Oct 2013 08:33:26 +0000 (09:33 +0100)
.gitignore
Makefile
kernel/driver.cc
kernel/register.h

index 72c0f2f62346e9f629c4bd4c99847b4d889590dc..f251d2b6d7f2211d4bf509280f7fa11844499a29 100644 (file)
@@ -16,3 +16,4 @@
 /yosys-filterlib
 /yosys-svgviewer
 /kernel/version_*.cc
+/share
index 1af48d4e057eb82a49cc62354f5215f14e145e52..312225ef1dbe3ce2bd620f6a39d6070102de0350 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -106,6 +106,8 @@ test: yosys
 
 install: $(TARGETS)
        install $(TARGETS) /usr/local/bin/
+       mkdir -p /usr/local/share/yosys
+       cp -r share/. /usr/local/share/yosys/.
 
 install-abc:
        install yosys-abc /usr/local/bin/
@@ -114,6 +116,7 @@ manual:
        cd manual && bash make.sh
 
 clean:
+       rm -rf share
        rm -f $(OBJS) $(GENFILES) $(TARGETS)
        rm -f kernel/version_*.o kernel/version_*.cc
        rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d
index 8d8f29e772990088a8d712fa65024af5c715145a..d726639c4fafe6114e65771ad47b0305f84a053a 100644 (file)
@@ -421,6 +421,27 @@ std::string rewrite_yosys_exe(std::string exe)
        return exe;
 }
 
+std::string get_share_file_name(std::string file)
+{
+       char buffer[1024];
+       ssize_t buflen = readlink("/proc/self/exe", buffer, sizeof(buffer)-1);
+
+       if (buflen < 0)
+               log_error("Can't find file `%s': reading of /proc/self/exe failed!\n", file.c_str());
+
+       buffer[buflen] = 0;
+
+       std::string newfile_inplace = stringf("%s/share/%s", dirname(buffer), file.c_str());
+       if (access(newfile_inplace.c_str(), F_OK) == 0)
+               return newfile_inplace;
+
+       std::string newfile_system = stringf("%s/../share/yosys/%s", dirname(buffer), file.c_str());
+       if (access(newfile_system.c_str(), F_OK) == 0)
+               return newfile_system;
+
+       log_error("Can't find file `%s': no `%s' and no `%s' found!\n", file.c_str(), newfile_inplace.c_str(), newfile_system.c_str());
+}
+
 int main(int argc, char **argv)
 {
        std::string frontend_command = "auto";
index 5983211d18bb8332590028e045bf9981458fdeec..f66cbfd30e2a023cd056403aaef170181c9e98a8 100644 (file)
@@ -34,6 +34,7 @@ extern Tcl_Interp *yosys_get_tcl_interp();
 // implemented in driver.cc
 extern RTLIL::Design *yosys_get_design();
 std::string rewrite_yosys_exe(std::string exe);
+std::string get_share_file_name(std::string file);
 
 struct Pass
 {