diff options
-rw-r--r-- | Config/defs.mk.in | 1 | ||||
-rw-r--r-- | Config/funcinst.mk | 4 | ||||
-rwxr-xr-x | Config/installfns.sh | 17 | ||||
-rwxr-xr-x | Config/uninstallfns.sh | 34 | ||||
-rw-r--r-- | INSTALL | 18 | ||||
-rw-r--r-- | Makefile.in | 8 | ||||
-rw-r--r-- | Src/init.c | 48 | ||||
-rw-r--r-- | Src/zsh.mdd | 3 | ||||
-rw-r--r-- | configure.in | 12 |
9 files changed, 87 insertions, 58 deletions
diff --git a/Config/defs.mk.in b/Config/defs.mk.in index 14f79d581..f19a40b21 100644 --- a/Config/defs.mk.in +++ b/Config/defs.mk.in @@ -41,6 +41,7 @@ infodir = @infodir@ mandir = @mandir@ datadir = @datadir@ fndir = @fndir@ +sitefndir = @sitefndir@ htmldir = $(datadir)/$(tzsh)/htmldoc # compilation diff --git a/Config/funcinst.mk b/Config/funcinst.mk index 82f0c16a5..4642de6a5 100644 --- a/Config/funcinst.mk +++ b/Config/funcinst.mk @@ -33,7 +33,7 @@ install.fns: FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \ FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \ INSTALL_DATA="$(INSTALL_DATA)" \ - DESTDIR="$(DESTDIR)" \ + DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \ $(SHELL) $(sdir_top)/Config/installfns.sh || exit 1; \ fi; \ exit 0 @@ -43,7 +43,7 @@ uninstall.fns: fndir="$(fndir)" sdir="$(sdir)" \ FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \ FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \ - DESTDIR="$(DESTDIR)" \ + DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \ $(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \ fi; \ exit 0 diff --git a/Config/installfns.sh b/Config/installfns.sh index 21147dea4..ec738e2d7 100755 --- a/Config/installfns.sh +++ b/Config/installfns.sh @@ -2,10 +2,6 @@ fndir=$DESTDIR$fndir -if test -d $fndir.old; then - add_old=1 -fi - $sdir_top/mkinstalldirs $fndir || exit 1; # If the source directory is somewhere else, we need to force @@ -24,27 +20,14 @@ for file in $install; do if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then subfile="$file" subdir="`echo $file | sed -e 's%/[^/]*$%%'`" - olddir="$fndir.old/$subdir" instdir="$fndir/$subdir" else subfile="`echo $file | sed -e 's%^.*/%%'`" - olddir="$fndir.old" instdir="$fndir" fi - if test -f $fndir/$subfile; then - if cmp $fndir/$subfile $sdir/$file >/dev/null; then :; else - $sdir_top/mkinstalldirs $olddir - mv $fndir/$subfile $olddir - : ${add_old:=1} - fi - fi $sdir_top/mkinstalldirs $instdir || exit 1 $INSTALL_DATA $sdir/$file $instdir || exit 1 fi done -if test x$add_old != x1; then - rm -rf $fndir.old -fi - exit 0 diff --git a/Config/uninstallfns.sh b/Config/uninstallfns.sh index 97a35c0f7..1f7e0c54b 100755 --- a/Config/uninstallfns.sh +++ b/Config/uninstallfns.sh @@ -14,20 +14,26 @@ done fndir=$DESTDIR$fndir for file in $install; do - if test -f $sdir/$file; then - if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then - rm -f $fndir/$file; - if test -f $fndir.old/$file; then - mv $fndir.old/$file $fndir/$file - fi - else - bfile="`echo $file | sed -e 's%^.*/%%'`" - rm -f "$fndir/$bfile"; \ - if test -f $fndir.old/$bfile; then - mv $fndir.old/$bfile $fndir/$bfile - fi - fi - fi + case $fndir in + *$VERSION*) + # Version specific function directory, safe to remove completely. + # However, we don't remove the top-level version directory since + # it could have other things than functions in it. We could + # do that instead in the top-level Makefile on a full uninstall, + # if we wanted. + rm -rf $fndir + ;; + *) + if test -f $sdir/$file; then + if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then + rm -f $fndir/$file; + else + bfile="`echo $file | sed -e 's%^.*/%%'`" + rm -f "$fndir/$bfile"; \ + fi + fi + ;; + esac done exit 0 diff --git a/INSTALL b/INSTALL index 55b1ea11a..b807c4abb 100644 --- a/INSTALL +++ b/INSTALL @@ -283,16 +283,13 @@ 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. -On installation, any completion function which already exists but is -different from the new version will be moved to a corresponding place in -FNDIR.old; for example, if a different version of User/_rcs exists when -installing into /usr/local/share/zsh/functions/User, the old one will be -moved into /usr/local/share/zsh/functions.old/User. The installer is -responsible for recovering or deleting old functions which have been moved -in this way. On uninstallation, any newly installed functions (including -those which existed before but were unchanged) will be deleted and the -files in the FNDIR.old hierarchy moved back into FNDIR. To preserve the -entire old hierarchy, you should move or copy it before installation. +The option --enable-site-fndir controls whether to create and initialise +$fpath to include a directory for site-specific functions. By default this +is created in the location ${datadir}/zsh/site-functions, i.e. parallel to +the version-specific functions directory, and inserted at the start of the +$fpath array on shell startup. This directory will not be affected by +`make uninstall' or `make uninstall.fns', although the version-specific +directory and its contents will be deleted. Support for large files and integers ------------------------------------ @@ -366,6 +363,7 @@ Features: zprofile=pathname # the full pathname of the global zprofile script zlogout=pathname # the full pathname of the global zlogout script fndir=directory # the directory where shell functions will go + site-fndir=directory# the directory where site-specific functions can go function-subdirs # if functions will be installed into subdirectories dynamic # allow dynamically loaded binary modules lfs # allow configure check for large files diff --git a/Makefile.in b/Makefile.in index 482f5d547..7fb77b16b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -76,7 +76,13 @@ install.man uninstall.man: @cd Doc && $(MAKE) $(MAKEDEFS) $@ # install/uninstall just the shell functions -install.fns uninstall.fns: +install.fns: + test x$(sitefndir) != xno && $(sdir_top)/mkinstalldirs $(sitefndir) + @cd Completion && $(MAKE) $(MAKEDEFS) $@ + @cd Functions && $(MAKE) $(MAKEDEFS) $@ + +uninstall.fns: + # never attempt to remove $(sitefndir) @cd Completion && $(MAKE) $(MAKEDEFS) $@ @cd Functions && $(MAKE) $(MAKEDEFS) $@ diff --git a/Src/init.c b/Src/init.c index 11d9ab65c..e213db0cb 100644 --- a/Src/init.c +++ b/Src/init.c @@ -547,6 +547,18 @@ setupvals(void) #ifdef HAVE_GETRLIMIT int i; #endif +#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) + char **fpathptr; +# if defined(FPATH_DIR) && defined(FPATH_SUBDIRS) + char *fpath_subdirs[] = FPATH_SUBDIRS; + int j; +# endif +# ifdef SITEPATH_DIR + int fpathlen = 1; +# else + int fpathlen = 0; +# endif +#endif getkeyptr = NULL; @@ -581,23 +593,33 @@ setupvals(void) cdpath = mkarray(NULL); manpath = mkarray(NULL); fignore = mkarray(NULL); -#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)); + +#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) +# ifdef FPATH_DIR +# ifdef FPATH_SUBDIRS + fpathlen += sizeof(fpath_subdirs)/sizeof(char *); +# else + fpathlen++; +# endif +# endif + fpath = fpathptr = (char **)zalloc((fpathlen+1)*sizeof(char *)); +# ifdef SITEFPATH_DIR + *fpathptr++ = ztrdup(SITEFPATH_DIR); + fpathlen--; # endif +# ifdef FPATH_DIR +# ifdef FPATH_SUBDIRS + for (j = 0; j < fpathlen; j++) + *fpathptr++ = tricat(FPATH_DIR, "/", fpath_subdirs[j]); +# else + *fpathptr++ = ztrdup(FPATH_DIR); +# endif +# endif + *fpathptr = NULL; #else fpath = mkarray(NULL); #endif + mailpath = mkarray(NULL); watch = mkarray(NULL); psvar = mkarray(NULL); diff --git a/Src/zsh.mdd b/Src/zsh.mdd index cca6ec8f9..f78e0694e 100644 --- a/Src/zsh.mdd +++ b/Src/zsh.mdd @@ -34,6 +34,9 @@ version.h: $(sdir_top)/Config/version.mk zshpaths.h: Makemod $(CONFIG_INCS) @echo '#define MODULE_DIR "'$(MODDIR)'"' > zshpaths.h.tmp + @if test x$(sitefndir) != xno; then \ + echo '#define SITEFPATH_DIR "'$(sitefndir)'"' >> zshpaths.h.tmp; \ + fi @if test x$(fndir) != xno; then \ echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \ if test x$(FUNCTIONS_SUBDIRS) != x -a \ diff --git a/configure.in b/configure.in index bcf34458e..bc53d99bb 100644 --- a/configure.in +++ b/configure.in @@ -212,7 +212,7 @@ AC_DEFINE(CONFIG_LOCALE) undefine([fndir])dnl AC_ARG_ENABLE(fndir, -[ --enable-fndir=DIR where functions go (default DATADIR/zsh/functions)], +[ --enable-fndir=DIR where functions go], dnl ${VERSION} to be determined at compile time. [if test $enableval = yes; then fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions @@ -220,6 +220,15 @@ else fndir="$enableval" fi], [fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions]) +undefine([sitefndir])dnl +AC_ARG_ENABLE(sitefndir, +[ --enable-site-fndir=DIR where site functions (not version specific) go], +[if test $enableval = yes; then + sitefndir=${datadir}/${tzsh_name}/site-functions +else + sitefndir="$enableval" +fi], [sitefndir=${datadir}/${tzsh_name}/site-functions]) + undefine([function_subdirs]) AC_ARG_ENABLE(function-subdirs, [ --enable-function-subdirs install functions in subdirectories]) @@ -240,6 +249,7 @@ else fi AC_SUBST(fndir)dnl +AC_SUBST(sitefndir)dnl AC_SUBST(FUNCTIONS_INSTALL)dnl AC_SUBST(FUNCTIONS_SUBDIRS)dnl |