changeset 686:0faebdd7df57

[project @ 1994-09-09 21:09:24 by jwe]
author jwe
date Fri, 09 Sep 1994 21:10:43 +0000
parents eb88bf09a645
children cba3b57a82db
files scripts/Makefile.in scripts/image/Makefile.in scripts/image/image.m scripts/image/loadimage.m scripts/image/saveimage.m src/Makefile.in src/octave.cc src/user-prefs.cc src/user-prefs.h src/utils.cc src/utils.h src/variables.cc src/variables.h
diffstat 13 files changed, 141 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/Makefile.in	Fri Sep 09 19:08:15 1994 +0000
+++ b/scripts/Makefile.in	Fri Sep 09 21:10:43 1994 +0000
@@ -8,6 +8,8 @@
 
 TOPDIR = ..
 
+script_sub_dir = .
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -22,54 +24,66 @@
 
 DISTFILES = Makefile.in $(SOURCES)
 
-# Complete directory trees to distribute.
-DISTDIRS = amr-image
+SUBDIRS = control general image linear-algebra miscellaneous plot \
+	polynomial set signal special-matrix statistics
+
+DISTSUBDIRS = $(SUBDIRS)
 
 FCN_FILES = $(wildcard $(srcdir)/*.m)
 FCN_FILES_NO_DIR = $(notdir $(FCN_FILES))
 
 all:
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
 .PHONY: all
 
 install: all
-	if test -d $(fcnfiledir) ; then true ; \
-	else $(TOPDIR)/mkpath $(fcnfiledir) ; fi
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
+	if test -d $(fcnfiledir)/$(script_sub_dir) ; then true ; \
+	else $(TOPDIR)/mkpath $(fcnfiledir)/$(script_sub_dir) ; fi
 	for f in $(FCN_FILES_NO_DIR) ; do \
-	  rm -f $(fcnfiledir)/$$f ; \
-	  $(INSTALL_DATA) $(srcdir)/$$f $(fcnfiledir)/$$f ; \
+	  rm -f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
+	  $(INSTALL_DATA) $(srcdir)/$$f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
 	done
 .PHONY: install
 
 uninstall:
-	for f in $(FCN_FILES_NO_DIR) ; do rm -f $(fcnfiledir)/$$f ; done
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
+	for f in $(FCN_FILES_NO_DIR) ; \
+	  do rm -f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
+	done
 .PHONY: uninstall
 
 clean:
 .PHONY: clean
 
 tags: $(SOURCES)
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
 	ctags $(SOURCES)
 
 TAGS: $(SOURCES)
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
 	etags $(SOURCES)
 
 mostlyclean: clean
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
 .PHONY: mostlyclean
 
 distclean: clean
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
 	rm -f Makefile
 .PHONY: distclean
 
 realclean: distclean
+	for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $@; cd ..; done
 	rm -f tags TAGS
 .PHONY: realclean
 
 local-dist:
 	ln $(DISTFILES) ../`cat ../.fname`/scripts
-	for dir in $(DISTDIRS); do ln -s ../../scripts/$$dir ../`cat ../.fname`/scripts ; done
+	for dir in $(DISTSUBDIRS); do mkdir `cat .fname`/$$dir; cd $$dir; $(MAKE) $@; cd ..; done
 .PHONY: local-dist
 
 dist:
 	ln $(DISTFILES) ../`cat ../.fname`/scripts
-	for dir in $(DISTDIRS); do ln -s ../../scripts/$$dir ../`cat ../.fname`/scripts ; done
+	for dir in $(DISTSUBDIRS); do mkdir `cat .fname`/$$dir; cd $$dir; $(MAKE) $@; cd ..; done
 .PHONY: dist
--- a/scripts/image/Makefile.in	Fri Sep 09 19:08:15 1994 +0000
+++ b/scripts/image/Makefile.in	Fri Sep 09 21:10:43 1994 +0000
@@ -27,11 +27,14 @@
 FCN_FILES = $(wildcard $(srcdir)/*.m)
 FCN_FILES_NO_DIR = $(notdir $(FCN_FILES))
 
+IMAGE_FILES = $(wildcard $(srcdir)/*.img)
+IMAGE_FILES_NO_DIR = $(notdir $(IMAGE_FILES))
+
 all: octtopnm
 .PHONY: all
 
 octtopnm: octtopnm.o
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o octave
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) octtopnm.o -o octtopnm
 
 install: all
 	if test -d $(fcnfiledir)/$(script_sub_dir) ; then true ; \
@@ -40,6 +43,12 @@
 	  rm -f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
 	  $(INSTALL_DATA) $(srcdir)/$$f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
 	done
+	if test -d $(fcnfiledir)/imagelib ; then true ; \
+	else $(TOPDIR)/mkpath $(fcnfiledir)/imagelib ; fi
+	for f in $(IMAGE_FILES_NO_DIR) ; do \
+	  rm -f $(fcnfiledir)/imagelib/$$f ; \
+	  $(INSTALL_DATA) $(srcdir)/$$f $(fcnfiledir)/imagelib/$$f ; \
+	done
 	if test -d $(archlibdir) ; then true ; \
 	else $(TOPDIR)/mkpath $(archlibdir) ; fi
 	$(INSTALL_PROGRAM) octtopnm $(archlibdir)/octtopnm
@@ -49,6 +58,9 @@
 	for f in $(FCN_FILES_NO_DIR) ; \
 	  do rm -f $(fcnfiledir)/$(script_sub_dir)/$$f ; \
 	done
+	for f in $(IMAGE_FILES_NO_DIR) ; \
+	  do rm -f $(fcnfiledir)/imagelib/$$f ; \
+	done
 	rm -f $(archlibdir)/octtopnm
 .PHONY: uninstall
 
--- a/scripts/image/image.m	Fri Sep 09 19:08:15 1994 +0000
+++ b/scripts/image/image.m	Fri Sep 09 21:10:43 1994 +0000
@@ -20,11 +20,9 @@
 # July 1994
 # (Modifications based on suggestions from John Eaton.)
 
-  global IMAGEDIR
- 
   if (nargin == 0)
     # Load Bobbie Jo Richardson (Born 3/16/94)
-    x = loadimage([IMAGEDIR,"/default.img"]);
+    x = loadimage("default.img");
     zoom = 2;
   elseif(nargin == 1)
     zoom = 4;
--- a/scripts/image/loadimage.m	Fri Sep 09 19:08:15 1994 +0000
+++ b/scripts/image/loadimage.m	Fri Sep 09 21:10:43 1994 +0000
@@ -7,6 +7,18 @@
 #
 #SEE ALSO: saveimage, load, save
 
-  eval(['load ', filename]);
+  if (nargin == 0)
+    error ("usage: loadimage (filename)");
+  endif
+
+  file = file_in_path (IMAGEPATH, filename);
+
+  if (isempty (file))
+    error ("loadimage: unable to find image file");
+  endif
+
+# XXX FIXME XXX -- file is assumed to have variables X and map.
+  
+  eval(['load ', file]);
 
 endfunction
--- a/scripts/image/saveimage.m	Fri Sep 09 19:08:15 1994 +0000
+++ b/scripts/image/saveimage.m	Fri Sep 09 21:10:43 1994 +0000
@@ -25,8 +25,6 @@
 #
 #SEE ALSO: loadimage, save, load, colormap
 
-  global IMAGEDIR
-
   if(nargin < 2)
     error("usage: saveimage(filename,matrix,[format, [colormap]])");
   elseif(nargin == 2)
@@ -59,12 +57,12 @@
 
   # Convert to another format if requested.
   if (strcmp(img_form,"ppm") == 1)
-    octtopnm = sprintf([IMAGEDIR,"/octtopnm %s > %s"],oct_file,filename);
+    octtopnm = sprintf("octtopnm %s > %s",oct_file,filename);
     rm = sprintf("rm -f %s",oct_file);
     shell_cmd(octtopnm);
     shell_cmd(rm);
   elseif (strcmp(img_form,"ps") == 1)
-    octtopnm = sprintf([IMAGEDIR,"/octtopnm %s"],oct_file);
+    octtopnm = sprintf("octtopnm %s",oct_file);
     ppmtops = sprintf("pnmtops > %s 2> /dev/null", filename);
     octtops = [ octtopnm, " | ", ppmtops ];
     rm = sprintf("rm -f %s",oct_file);
--- a/src/Makefile.in	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/Makefile.in	Fri Sep 09 21:10:43 1994 +0000
@@ -206,6 +206,7 @@
 	  -e "s;%OCTAVE_OCTFILEDIR%;\"${octfiledir}\";" \
 	  -e "s;%OCTAVE_LOCALOCTFILEPATH%;\"${localoctfilepath}\";" \
 	  -e "s;%OCTAVE_FCNFILEPATH%;\"${fcnfilepath}\";" \
+	  -e "s;%OCTAVE_IMAGEPATH%;\"${imagepath}\";" \
 	  -e "s;%TARGET_HOST_TYPE%;\"${target_host_type}\";")
 	@$(top_srcdir)/move-if-change $@.tmp $@
 
--- a/src/octave.cc	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/octave.cc	Fri Sep 09 21:10:43 1994 +0000
@@ -205,6 +205,19 @@
   else
     home_directory = strsave ("I have no home!");
 
+  char *shell_path = getenv ("PATH");
+  char *arch_dir = octave_arch_lib_dir ();
+  char *tmp = strconcat (shell_path, ":");
+
+  shell_path = shell_path ? strconcat (tmp, arch_dir)
+    : strsave (arch_dir);
+
+  delete [] tmp;
+
+  char *putenv_command = strconcat ("PATH=", shell_path);
+
+  putenv (putenv_command);
+
   raw_prog_name = strsave (name);
   prog_name = strsave ("octave");
 
--- a/src/user-prefs.cc	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/user-prefs.cc	Fri Sep 09 21:10:43 1994 +0000
@@ -552,6 +552,26 @@
 }
 
 int
+sv_imagepath (void)
+{
+  int status = 0;
+
+  char *s = builtin_string_variable ("IMAGEPATH");
+  if (s)
+    {
+      delete [] user_pref.imagepath;
+      user_pref.imagepath = s;
+    }
+  else
+    {
+      warning ("invalid value specified for IMAGEPATH");
+      status = -1;
+    }
+
+  return status;
+}
+
+int
 sv_info_file (void)
 {
   int status = 0;
--- a/src/user-prefs.h	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/user-prefs.h	Fri Sep 09 21:10:43 1994 +0000
@@ -54,6 +54,7 @@
   char *default_save_format;
   char *editor;
   char *gnuplot_binary;
+  char *imagepath;
   char *info_file;
   char *loadpath;
   char *pager_binary;
@@ -93,6 +94,7 @@
 extern int sv_default_save_format (void);
 extern int sv_editor (void);
 extern int sv_gnuplot_binary (void);
+extern int sv_imagepath (void);
 extern int sv_info_file (void);
 extern int sv_loadpath (void);
 extern int sv_pager_binary (void);
--- a/src/utils.cc	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/utils.cc	Fri Sep 09 21:10:43 1994 +0000
@@ -89,7 +89,9 @@
 #include "user-prefs.h"
 #include "variables.h"
 #include "dirfns.h"
+#include "defun.h"
 #include "error.h"
+#include "help.h"
 #include "gripes.h"
 #include "pager.h"
 #include "utils.h"
@@ -616,11 +618,53 @@
 // See if the given file is in the path.
 
 char *
+search_path_for_file (const char *path, const char *name)
+{
+  char *retval = 0;
+
+  char *tmp = kpse_path_search (path, name, kpathsea_true);
+
+  if (tmp)
+    {
+      retval = make_absolute (tmp, the_current_working_directory);
+      free (tmp);
+    }
+
+  return retval;
+}
+
+DEFUN ("file_in_path", Ffile_in_pat, Sfile_in_path, 3, 1,
+  "file_in_path (PATH, NAME)")
+{
+  Octave_object retval;
+
+  DEFINE_ARGV("file_in_path");
+
+  if (argc == 3)
+    {
+      char *fname = search_path_for_file (argv[1], argv[2]);
+
+      if (fname)
+	retval = fname;
+      else
+	retval = Matrix ();
+    }
+  else
+    print_usage ("file_in_path");
+
+  DELETE_ARGV;
+
+  return retval;
+}
+
+
+char *
 file_in_path (const char *name, const char *suffix)
 {
   char *retval = 0;
 
   char *nm = strsave (name);
+
   if (suffix)
     {
       char *tmp = nm;
@@ -631,14 +675,9 @@
   if (! the_current_working_directory)
     get_working_directory ("file_in_path");
 
-  char *tmp = kpse_path_search (user_pref.loadpath, nm, kpathsea_true);
+  retval = search_path_for_file (user_pref.loadpath, nm);
 
-  if (tmp)
-    {
-      retval = make_absolute (tmp, the_current_working_directory);
-      free (tmp);
-      delete [] nm;
-    }
+  delete [] nm;
 
   return retval;
 }
--- a/src/utils.h	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/utils.h	Fri Sep 09 21:10:43 1994 +0000
@@ -45,6 +45,7 @@
 extern char *read_until (istream&, char);
 #endif
 
+extern char *search_path_for_file (const char *, const char *);
 extern char *file_in_path (const char *, const char *);
 extern char *fcn_file_in_path (const char *);
 extern char *oct_file_in_path (const char *);
--- a/src/variables.cc	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/variables.cc	Fri Sep 09 21:10:43 1994 +0000
@@ -333,7 +333,7 @@
   return retval;
 }
 
-static char *
+char *
 octave_arch_lib_dir (void)
 {
   static char *retval = subst_octave_home (OCTAVE_ARCHLIBDIR);
@@ -1342,6 +1342,10 @@
   DEFVAR ("LOADPATH", SBV_LOADPATH, load_path, 0, 0, 1, sv_loadpath,
     "colon separated list of directories to search for scripts");
 
+  DEFVAR ("IMAGEPATH", SBV_IMAGEPATH, OCTAVE_IMAGEPATH, 0, 0, 1,
+	  sv_imagepath,
+    "colon separated list of directories to search for image files");
+
   DEFVAR ("OCTAVE_VERSION", SBV_version, version_string, 0, 1, 1, 0,
     "Octave version");
 
--- a/src/variables.h	Fri Sep 09 19:08:15 1994 +0000
+++ b/src/variables.h	Fri Sep 09 21:10:43 1994 +0000
@@ -112,6 +112,7 @@
 extern void install_builtin_variables (void);
 
 extern char *octave_lib_dir (void);
+extern char *octave_arch_lib_dir (void);
 extern char *default_path (void);
 extern char *default_info_file (void);
 extern char *default_editor (void);