changeset 6950:4fa8d8a804fb

[project @ 2007-10-03 19:46:26 by dbateman]
author dbateman
date Wed, 03 Oct 2007 19:46:26 +0000
parents 88df962dc296
children f359defe99ff
files scripts/ChangeLog scripts/pkg/pkg.m
diffstat 2 files changed, 43 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Oct 03 17:59:03 2007 +0000
+++ b/scripts/ChangeLog	Wed Oct 03 19:46:26 2007 +0000
@@ -1,3 +1,13 @@
+2007-10-03  David Bateman  <dbateman@free.fr>
+
+	* pkg/pkg.m (is_architecture_dependent): New function to identify
+	if a file is architecture dependent based on a list of file
+	extensions.
+	(configure_make): Simplify the search for architecture dependent
+	files based on this function.
+	(load_pakages_and_dependencies): Also look for bin directory in
+	the architecture dependent directory.
+
 2007-10-03  John W. Eaton  <jwe@octave.org>
 
 	* miscellaneous/dir.m: Create empty struct with field names.
--- a/scripts/pkg/pkg.m	Wed Oct 03 17:59:03 2007 +0000
+++ b/scripts/pkg/pkg.m	Wed Oct 03 19:46:26 2007 +0000
@@ -1052,6 +1052,7 @@
     files = fullfile (src, "FILES");
     instdir = fullfile (packdir, "inst");
     archdir = fullfile (packdir, "inst", getarch ());
+
     ## Get file names
     if (exist (files, "file"))
       [fid, msg] = fopen (files, "r");
@@ -1073,15 +1074,6 @@
 	endif
       endfor
       filenames(delete_idx) = [];
-      idx1 = cellfun ("isempty", regexp (filenames, '^.*\.mex'));
-      idx2 = cellfun ("isempty", regexp (filenames, '^.*\.oct'));
-      mex = filenames;
-      mex(idx1 != 0) = [];
-      oct = filenames;
-      oct(idx2 != 0) = [];
-      archindependent = filenames;
-      archindependent(idx1 == 0 | idx2 == 0) = [];
-      archdependent = [oct, mex];
     else
       m = dir (fullfile (src, "*.m"));
       oct = dir (fullfile (src, "*.oct"));
@@ -1091,25 +1083,23 @@
       filenames = "";
       if (length (m) > 0)
 	filenames = sprintf (fullfile (src, "%s "), m.name);
-	archindependent = sprintf (fullfile (src, "%s "), m.name);
       endif
       if (length (oct) > 0)
 	filenames = strcat (filenames, " ", sprintf(fullfile(src, "%s "), ...
 						    oct.name));
-	archdependent = strcat (archdependent, " ", ...
-			 sprintf(fullfile(src, "%s "), oct.name));
       endif
       if (length (mex) > 0)
 	filenames = strcat (filenames, " ", sprintf(fullfile(src, "%s "), ...
 						    mex.name));
-	archdependent = strcat (archdependent, " ", ...
-			 sprintf(fullfile(src, "%s "), mex.name));
       endif
       filenames = split_by (filenames, " ");
-      archdependent = split_by (archdependent, " ");
-      archindependent = split_by (archindependent, " ");
     endif
 
+    ## Split into architecture dependent and independent files
+    idx = cellfun (@(x) is_architecture_dependent (x), filenames);
+    archdependent = filenames (idx);
+    archindependent = filenames (!idx);
+
     ## Copy the files
     if (! all (isspace (filenames)))
 	if (! exist (instdir, "dir")) 
@@ -1376,6 +1366,7 @@
   endif
 
   ## Is there a bin/ directory that needs to be installed
+  ## FIXME: Need to treat architecture dependent files in bin/
   bindir = fullfile (packdir, "bin");
   if (exist (bindir, "dir") && ! dirempty (bindir))
     [status, output] = copyfile (bindir, desc.dir);
@@ -2027,6 +2018,9 @@
     tmpdir = getarchdir (installed_pkgs_lst {i});
     if (exist (tmpdir, "dir"))
       dirs{end + 1} = tmpdir;
+      if (exist (fullfile (dirs{end}, "bin"), "dir"))
+        execpath = strcat (fullfile(dirs{end}, "bin"), ":", execpath);
+      endif
     endif
   endfor
 
@@ -2070,3 +2064,26 @@
     endif
   endfor
 endfunction
+
+function dep = is_architecture_dependent (nm)
+  persistent archdepsuffix = {".oct",".mex",".a",".so",".so.*",".dll","dylib"};
+
+  dep = false;
+  for i = 1 : length (archdepsuffix)
+    ext = archdepsuffix {i};
+    if (ext(end) == "*")
+      isglob = true;
+      ext(end) = [];
+    else
+      isglob = false;
+    endif
+    pos = findstr (nm, ext);
+    if (pos)
+      if (! isglob &&  (length(nm) - pos(end) != length(ext) - 1))
+	continue;
+      endif
+      dep = true;
+      break;
+    endif
+  endfor
+endfunction