Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: pws-21: function installation in subdirectories



This is supposed to allow functions to be installed into subdirectories of
the installed function directory by --enable-function-subdirs.  The default
$fpath will also be set appropriately.

Would an --enable to specify the functions be better than having to set
FUNCTIONS_INSTALL directly?  Probably more consistent.

--- Completion/Makefile.in.fs	Mon Jun  7 12:18:38 1999
+++ Completion/Makefile.in	Sun Jun 13 17:26:47 1999
@@ -55,7 +55,14 @@
 	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
 	  for file in $(FUNCTIONS_INSTALL); do \
 	    if test -f $$file; then \
-	      $(INSTALL_DATA) $$file $(fndir) || exit 1; \
+	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
+	      x$(FUNCTIONS_SUBDIRS) != xno; then \
+	        subdir="`echo $$file | sed -e 's%/.*%%'`"; \
+	        $(sdir_top)/mkinstalldirs $(fndir)/$$subdir || exit 1; \
+	        $(INSTALL_DATA) $$file $(fndir)/$$subdir || exit 1; \
+	      else \
+	        $(INSTALL_DATA) $$file $(fndir) || exit 1; \
+	      fi; \
 	    fi; \
 	  done; \
 	fi; \
@@ -65,7 +72,12 @@
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
 	  for file in $(FUNCTIONS_INSTALL); do \
 	    if test -f $$file; then \
-	      rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
+	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
+              x$(FUNCTIONS_SUBDIRS) != xno; then \
+	        rm -f $(fndir)/$$file; \
+	      else \
+	        rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
+	      fi; \
 	    fi; \
 	  done; \
 	fi; \
--- Config/defs.mk.in.fs	Mon Jun  7 14:02:10 1999
+++ Config/defs.mk.in	Sun Jun 13 17:23:46 1999
@@ -68,6 +68,7 @@
 
 # variables used in determining what to install
 FUNCTIONS_INSTALL = @FUNCTIONS_INSTALL@
+FUNCTIONS_SUBDIRS = @FUNCTIONS_SUBDIRS@
 
 # flags passed to recursive makes in subdirectories
 MAKEDEFS = \
--- Functions/Makefile.in.fs	Mon Jun  7 12:18:55 1999
+++ Functions/Makefile.in	Sun Jun 13 17:26:30 1999
@@ -55,7 +55,14 @@
 	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
 	  for file in $(FUNCTIONS_INSTALL); do \
 	    if test -f $$file; then \
-	      $(INSTALL_DATA) $$file $(fndir) || exit 1; \
+	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
+	      x$(FUNCTIONS_SUBDIRS) != xno; then \
+	        subdir="`echo $$file | sed -e 's%/.*%%'`"; \
+	        $(sdir_top)/mkinstalldirs $(fndir)/$$subdir || exit 1; \
+	        $(INSTALL_DATA) $$file $(fndir)/$$subdir || exit 1; \
+	      else \
+	        $(INSTALL_DATA) $$file $(fndir) || exit 1; \
+	      fi; \
 	    fi; \
 	  done; \
 	fi; \
@@ -65,7 +72,12 @@
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
 	  for file in $(FUNCTIONS_INSTALL); do \
 	    if test -f $$file; then \
-	      rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
+	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
+	      x$(FUNCTIONS_SUBDIRS) != xno; then \
+	        rm -f $(fndir)/$$file; \
+	      else \
+	        rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
+	      fi; \
 	    fi; \
 	  done; \
 	fi; \
--- INSTALL.fs	Thu Jun 10 14:57:55 1999
+++ INSTALL	Mon Jun 14 17:52:15 1999
@@ -220,11 +220,12 @@
 for $fpath/$FPATH.
 
 You can control the functions which get installed by setting
-FUNCTIONS_INSTALL, either when running configure or when running `make
-install' or `make install.fns'.  It includes a list of files relative to
-either the Completion or Functions subdirectories.  By default, all the
-functions for the Completion system will be installed (see the zshcompsys
-manual page), i.e.
+FUNCTIONS_INSTALL, either when running configure (e.g.
+`FUNCTIONS_INSTALL="..." configure ...') or when running `make install' or
+`make install.fns'.  It includes a list of files relative to either the
+Completion or Functions subdirectories.  By default, all the functions for
+the Completion system will be installed (see the zshcompsys manual page),
+i.e.
   FUNCTIONS_INSTALL='Core/* Base/* Builtins/* User/* Commands/*'
 and if the --enable-dynamic option was given, the functions in
 Functions/Zftp, which require the zftp module to be available (see the
@@ -233,6 +234,11 @@
 of functions can be installed with
   FUNCTIONS_INSTALL='Core/* Base/* Builtins/* User/* Commands/* Misc/* Zftp/*'
 
+You can also set --enable-function-subdirs to allow shell
+functions to be installed into subdirectories of the function directory,
+i.e. `Core/*' files will be installed into `FNDIR/Core', and so on.
+This also initialises $fpath/$FPATH appropriately.
+
 Support for large files and integers
 ------------------------------------
 
@@ -305,6 +311,7 @@
      zlogin=pathname     # the full pathname of the global zlogin script
      zprofile=pathname   # the full pathname of the global zprofile script
      zlogout=pathname    # the full pathname of the global zlogout script
-     fns=directory       # the directory where shell functions will go
+     fndir=directory     # the directory where shell functions will go
+     function-subdirs    # if functions will be installed into subdirectories
      dynamic             # allow dynamically loaded binary modules
      lfs                 # allow configure check for large files
--- Src/init.c.fs	Mon Jun 14 17:10:16 1999
+++ Src/init.c	Mon Jun 14 17:39:43 1999
@@ -560,8 +560,20 @@
     cdpath   = mkarray(NULL);
     manpath  = mkarray(NULL);
     fignore  = mkarray(NULL);
-#ifdef FUNCTION_DIR
-    fpath    = mkarray(ztrdup(FUNCTION_DIR));
+#ifdef FPATH_DIR
+# ifdef FPATH_SUBDIRS
+    {
+	char *fpath_subdirs[] = FPATH_SUBDIRS;
+	int len = sizeof(fpath_subdirs)/sizeof(char *), j;
+
+	fpath = zalloc((len+1)*sizeof(char *));
+	for (j = 0; j < len; j++)
+	    fpath[j] = tricat(FPATH_DIR, "/", fpath_subdirs[j]);
+	fpath[len] = NULL;
+    }
+# else
+    fpath    = mkarray(ztrdup(FPATH_DIR));
+# endif
 #else
     fpath    = mkarray(NULL);
 #endif
--- Src/zsh.mdd.fs	Sun Jun  6 17:50:52 1999
+++ Src/zsh.mdd	Mon Jun 14 17:54:22 1999
@@ -31,7 +31,16 @@
 zshpaths.h: FORCE Makemod
 	@echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp
 	@if test x$(fndir) != xno; then \
-	  echo '#define FUNCTION_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \
+	  echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \
+	  if test x$(FUNCTIONS_SUBDIRS) != x -a \
+	  x$(FUNCTIONS_SUBDIRS) != xno; then \
+	    fpath_tmp="`for f in $$FUNCTIONS_INSTALL; do \
+	      echo $$f | sed s%/.*%%; \
+	    done | sort | uniq`"; \
+	    fpath_tmp="`echo $$fpath_tmp | sed 's/ /\", \"/g'`"; \
+	    echo "#define FPATH_SUBDIRS { \"$$fpath_tmp\" }" \
+	    >>zshpaths.h.tmp; \
+	  fi; \
 	fi
 	@if cmp -s zshpaths.h zshpaths.h.tmp; then \
 	    rm -f zshpaths.h.tmp; \
--- configure.in.fs	Thu Jun 10 14:43:47 1999
+++ configure.in	Mon Jun 14 17:20:20 1999
@@ -97,8 +97,7 @@
   AC_DEFINE(ZSH_HASH_DEBUG)
 fi])
 
-dnl Do you want large file support, if available (mostly Solaris)?
-dnl Currently this is only partially implemented.
+dnl Do you want large file support, if available?
 undefine([lfs])dnl
 AC_ARG_ENABLE(lfs,
 [  --enable-lfs               turn on support for large files])
@@ -210,15 +209,28 @@
   fndir="$enableval"
 fi], [fndir=${datadir}/zsh/functions])
 
-if test x${FUNCTIONS_INSTALL+set} != xset; then
+undefine([function_subdirs])
+AC_ARG_ENABLE(function-subdirs,
+[  --enable-function-subdirs  install functions in subdirectories])
+
+if test "x${FUNCTIONS_INSTALL+set}" != xset; then
   FUNCTIONS_INSTALL="Core/* Base/* Builtins/* User/* Commands/*"
   if test $dynamic != no; then
     FUNCTIONS_INSTALL="${FUNCTIONS_INSTALL} Zftp/*"
   fi
 fi
 
+if test "x${enable_function_subdirs}" != x -a \
+  "x${enable_function_subdirs}" != xno -a \
+  "x$FUNCTIONS_INSTALL" != x; then
+  FUNCTIONS_SUBDIRS=yes
+else
+  FUNCTIONS_SUBDIRS=no
+fi
+
 AC_SUBST(fndir)dnl
 AC_SUBST(FUNCTIONS_INSTALL)dnl
+AC_SUBST(FUNCTIONS_SUBDIRS)dnl
 
 dnl ------------------
 dnl CHECK THE COMPILER
@@ -229,7 +241,7 @@
 
 AC_PROG_CC
 
-dnl Check for large file support (Solaris).
+dnl Check for large file support.
 dnl This needs to be done early to get the stuff into the flags.
 if test "x$enable_lfs" != x; then
 zsh_LARGE_FILE_SUPPORT

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author