--- src/Dirstructure.cpp.orig	2018-02-17 23:54:32.000000000 +0900
+++ src/Dirstructure.cpp	2018-05-31 23:28:55.000000000 +0900
@@ -249,7 +249,20 @@
   else
   {
     wxFileName maximaName(result);
-    maximaName.RemoveLastDir();
+    if(maximaName.GetDirCount() > 1)
+    {
+      maximaName.RemoveLastDir();
+    }
+    else
+    {
+      wxArrayString output;
+      wxExecute(wxT("which maxima"), output, (wxEXEC_SYNC | wxEXEC_NOEVENTS));
+      if(output.GetCount() > 0)
+      {
+        wxFileName fullpath(output[0] ,wxPATH_NATIVE);
+        return fullpath.GetPath();
+      }
+    }
     return maximaName.GetPath();
   }
 }
@@ -279,10 +292,8 @@
     command = wxT("/Applications/Maxima.app");
   if (wxFileExists("/Applications/maxima.app"))
     command = wxT("/Applications/maxima.app");
-  else if (wxFileExists("/usr/local/bin/maxima"))
-    command = wxT("/usr/local/bin/maxima");
-  else if (wxFileExists("/usr/bin/maxima"))
-    command = wxT("/usr/bin/maxima");
+  else if (wxFileExists("@@PREFIX@@/bin/maxima"))
+    command = wxT("@@PREFIX@@/bin/maxima");
   else
     command = wxT("maxima");
   return command;