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

automatic generation of linked-in module code



-----BEGIN PGP SIGNED MESSAGE-----

This patch makes the linked-in module boot code, and automatic autoload
code, be automatically generated.  It makes the Makefile a bit less
readable, and hopefully makes zsh a bit more maintainable.

This depends on several previous patches, including my recent patch that
added add_autobin().

 -zefram

      *** Src/Makefile.in	1996/12/24 17:07:26	1.24
      --- Src/Makefile.in	1996/12/24 20:14:18
      ***************
      *** 75,82 ****
        prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \
        libdir='$(libdir)' infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)'
        
      - MODBINS = modules-bltin
      - 
        KNR_OBJ=.o
        KNROBJ=._foo_
        
      --- 75,80 ----
      ***************
      *** 149,165 ****
        LIBZSH = libzsh.so.$(VERSION)
        NIBZSH =
        
      ! # default linked-in modules
      ! 
      ! XMODS = zle compctl
      ! XMODDEPS = compctl:zle
        
      ! DYNAMIC_XMODS =
      ! NYNAMIC_XMODS = $(XMODS)
        
      ! ZLE_OBJS = Zle/zle_bindings.o Zle/zle_hist.o Zle/zle_main.o Zle/zle_misc.o \
      ! Zle/zle_move.o Zle/zle_refresh.o Zle/zle_tricky.o Zle/zle_utils.o \
      ! Zle/zle_vi.o Zle/zle_word.o
        
        # ========= DEPENDENCIES FOR BUILDING ==========
        
      --- 147,159 ----
        LIBZSH = libzsh.so.$(VERSION)
        NIBZSH =
        
      ! # linked-in modules
        
      ! MODCF   = $(srcdir)/mods.conf
      ! XMODCF  = $(srcdir)/xmods.conf
      ! MODBINS = modules-bltin
        
      ! CFSED   = ':1;/\\$$/{N;s/\\\n//;b1;};s/	/ /g;/^ *$$/d'
        
        # ========= DEPENDENCIES FOR BUILDING ==========
        
      ***************
      *** 210,247 ****
        	    echo "Updated \`zshpaths.h'." ; \
        	fi
        
      ! bltinmods.list: $(MODBINS)
      ! 	( for mod in `cat $(MODBINS)`; do \
      ! 	    echo "DOMOD(\"$$mod\", boot_$$mod)"; \
      ! 	done ) > $@
        
      ! zshxmods.h: $(MODBINS)
        	@echo "Creating \`$@'."
        	@( \
      ! 	    modbins=" `cat $(MODBINS)` "; \
      ! 	    for mod in $(XMODS); do \
      ! 		case $$modbins in \
        		    *" $$mod "*) \
      - 			for dep in $(XMODDEPS); do \
      - 			    case $$dep in \
      - 				$$mod:*) \
      - 				    d=`echo $$dep | sed 's/.*://'`; \
      - 				    case $$modbins in \
      - 					*" $$d "*) ;; \
      - 					*)  rm -f $@; \
      - 					    echo >&2 "Linked-in module \`$$mod' depends on non-linked-in module \`$$d'!"; \
      - 					    exit 1 ;; \
      - 				    esac ;; \
      - 			    esac; \
      - 			done; \
        			echo "#define   LINKED_XMOD_$$mod 1" ;; \
        		    *)  echo "#define UNLINKED_XMOD_$$mod 1" ;; \
        		esac; \
        	    done; \
        	) > $@
        
        $(MODBINS):
      ! 	echo $(@D@YNAMIC_XMODS) > $@
        
        proto: $(PROTO) proto-recursive FORCE
        
      --- 204,280 ----
        	    echo "Updated \`zshpaths.h'." ; \
        	fi
        
      ! bltinmods.list: $(MODBINS) $(XMODCF)
      ! 	@echo "Creating \`$@'."
      ! 	@( \
      ! 	    binmods=`sed 's/^/ /;s/$$/ /' $(MODBINS)`; \
      ! 	    sed=$(CFSED)';/^[^#:>]*>[^#:>]*$$/{s/>.*//;p;}'; \
      ! 	    xmods=`sed -n -e "$$sed" $(XMODCF)`; \
      ! 	    for mod in $$xmods; do \
      ! 		case $$binmods in \
      ! 		    *" $$mod "*) ;; \
      ! 		    *)  echo "/* non-linked-in known module \`$$mod' */"; \
      ! 			sed=$(CFSED)';/^ *'$$mod' *>[^#:>]*$$/{s/.*>//;p;}'; \
      ! 			bins=`sed -n -e "$$sed" $(XMODCF)`; \
      ! 			for bin in $$bins; do \
      ! 			    echo "    add_autobin(\"$$bin\", \"$$mod\");"; \
      ! 			done; \
      ! 			sed=$(CFSED)';/^ *'$$mod' *:[^#:>]*$$/{s/.*://;p;}'; \
      ! 			deps=`sed -n -e "$$sed" $(XMODCF)`; \
      ! 			for dep in $$deps; do \
      ! 			    case $$binmods in \
      ! 				*" $$dep "*) \
      ! 				    echo "    /* depends on \`$$dep' */" ;; \
      ! 				*)  echo "    add_dep(\"$$mod\", \"$$dep\");" ;; \
      ! 			    esac; \
      ! 			done ;; \
      ! 		esac; \
      ! 	    done; \
      ! 	    echo; \
      ! 	    donemods=" "; \
      ! 	    for mod in $$binmods; do \
      ! 		echo "/* linked-in module \`$$mod' */"; \
      ! 		sed=$(CFSED)';/^ *'$$mod' *:[^#:>]*$$/{s/.*://;p;}'; \
      ! 		deps=`sed -n -e "$$sed" $(XMODCF)`; \
      ! 		for dep in $$deps; do \
      ! 		    case $$donemods in \
      ! 			*" $$dep "*) \
      ! 			    echo "    /* depends on \`$$dep' */" ;; \
      ! 			*)  echo >&2 "ERROR: linked-in module \`$$mod' depends on \`$$dep'"; \
      ! 			    rm -f $@; \
      ! 			    exit 1 ;; \
      ! 		    esac; \
      ! 		done; \
      ! 		echo "    mod.nam = \"$$mod\"; boot_$$mod(&mod);"; \
      ! 		donemods="$$donemods$$mod "; \
      ! 	    done; \
      ! 	) > $@
        
      ! zshxmods.h: $(MODBINS) $(XMODCF)
        	@echo "Creating \`$@'."
        	@( \
      ! 	    binmods=`sed 's/^/ /;s/$$/ /' $(MODBINS)`; \
      ! 	    sed=$(CFSED)';/^[^#:>]*>[^#:>]*$$/{s/>.*//;p;}'; \
      ! 	    xmods=`sed -n -e "$$sed" $(XMODCF)`; \
      ! 	    for mod in $$xmods; do \
      ! 		case $$binmods in \
        		    *" $$mod "*) \
        			echo "#define   LINKED_XMOD_$$mod 1" ;; \
        		    *)  echo "#define UNLINKED_XMOD_$$mod 1" ;; \
        		esac; \
        	    done; \
      + 	    echo; \
      + 	    for mod in $$binmods; do \
      + 		echo "int boot_$$mod _((Module));"; \
      + 	    done; \
        	) > $@
        
        $(MODBINS):
      ! 	if test @D@ = N; then \
      ! 	    sed -n -e $(CFSED) -e '/^[^#:>]*>[^#:>]*$$/{s/>.*//;p;}' $(XMODCF) > $@; \
      ! 	else \
      ! 	    echo > $@; \
      ! 	fi
        
        proto: $(PROTO) proto-recursive FORCE
        
      ***************
      *** 252,276 ****
        	test -f $(NSTMP) || dn=false; \
        	echo > $(NSTMP).tmp; \
        	for mod in `cat $(MODBINS)`; do \
      ! 	    case $$mod in \
      ! 		zle) objs="$(ZLE_OBJS)" ;; \
      ! 		*) \
      ! 		    for dir in $(MODULE_DIRS) NOWHERE; do \
      ! 			if test .$$dir = .NOWHERE; then \
      ! 			    echo >&2 \
      ! 			      "WARNING: don't know how to build module $$mod"; \
      ! 			    continue 2; \
      ! 			elif test -f $(srcdir)/$$dir/$$mod.c; then \
      ! 			    objs=$$dir/$$mod.o; \
      ! 			    break; \
      ! 			fi; \
      ! 		    done ;; \
      ! 	    esac; \
        	    $(MAKE) $(MAKEDEFS) $$objs || exit 1; \
      - 	    echo $$objs >> $(NSTMP).tmp; \
        	    for obj in $$objs; do \
        		test $$obj -nt $(NSTMP) && dn=false; \
        	    done; \
        	done; \
        	if $$dn && cmp -s $(NSTMP).tmp $(NSTMP); then \
        	    rm -f $(NSTMP).tmp; \
      --- 285,310 ----
        	test -f $(NSTMP) || dn=false; \
        	echo > $(NSTMP).tmp; \
        	for mod in `cat $(MODBINS)`; do \
      ! 	    sed=$(CFSED)';/^ *'$$mod' *:[^#:>]*$$/{s/.*://;p;}'; \
      ! 	    objs=`sed -n -e "$$sed" $(MODCF)`; \
      ! 	    if test -z "$$objs"; then \
      ! 		for dir in $(MODULE_DIRS); do \
      ! 		    if test -f $(srcdir)/$$dir/$$mod.c; then \
      ! 			objs=$$dir/$$mod.o; \
      ! 			break; \
      ! 		    fi; \
      ! 		done; \
      ! 		if test -z "$$objs"; then \
      ! 		    echo >&2 \
      ! 		      "ERROR: don't know how to build module $$mod"; \
      ! 		    exit 1; \
      ! 		fi; \
      ! 	    fi; \
        	    $(MAKE) $(MAKEDEFS) $$objs || exit 1; \
        	    for obj in $$objs; do \
        		test $$obj -nt $(NSTMP) && dn=false; \
        	    done; \
      + 	    echo $$objs >> $(NSTMP).tmp; \
        	done; \
        	if $$dn && cmp -s $(NSTMP).tmp $(NSTMP); then \
        	    rm -f $(NSTMP).tmp; \
      *** Src/init.c	1996/12/24 17:07:27	1.33
      --- Src/init.c	1996/12/24 20:27:27
      ***************
      *** 520,541 ****
            createnameddirtable();  /* create hash table for named directories */
            createparamtable();     /* create paramater hash table             */
        
      - #ifdef UNLINKED_XMOD_zle
      -     add_autobin("bindkey", "zle");
      -     add_autobin("vared", "zle");
      - #endif /* UNLINKED_XMOD_zle */
      - 
      - #ifdef LINKED_XMOD_zle
      - # define ZLE_DEP(mod)
      - #else
      - # define ZLE_DEP(mod) add_dep((mod), "zle")
      - #endif
      - 
      - #ifdef UNLINKED_XMOD_compctl
      -     add_autobin("compctl", "compctl");
      -     ZLE_DEP("compctl");
      - #endif /* UNLINKED_XMOD_compctl */
      - 
        #ifdef HAVE_GETRLIMIT
            for (i = 0; i != RLIM_NLIMITS; i++) {
        	getrlimit(i, current_limits + i);
      --- 520,525 ----
      ***************
      *** 768,785 ****
            source(buf);
        }
        
      - #define DOMOD(name, boot) int boot(Module);
      - #include "bltinmods.list"
      - #undef DOMOD
      - 
        /**/
        void
        init_bltinmods(void)
        {
            static struct module mod = { NULL, 0, NULL, NULL };
      - #define DOMOD(name, boot) mod.nam = name; boot(&mod);
        #include "bltinmods.list"
      ! #undef DOMOD
        }
        
        /* ZLE entry point pointers.  They are defined here because the initial *
      --- 752,764 ----
            source(buf);
        }
        
        /**/
        void
        init_bltinmods(void)
        {
            static struct module mod = { NULL, 0, NULL, NULL };
        #include "bltinmods.list"
      !     mod.nam = NULL;
        }
        
        /* ZLE entry point pointers.  They are defined here because the initial *
      *** ............./dev/null	Thu Sep  7 20:04:30 1995
      --- Src/mods.conf	Tue Dec 24 19:24:54 1996
      ***************
      *** 0 ****
      --- 1,29 ----
      + #
      + # $Id$
      + #
      + # mods.conf - configuration of modules for linking in
      + #
      + # This file lists the object files that must be included to link each module
      + # into the zsh executable.  This is only required for those modules that are
      + # not generated from a single .c file of the appropriate name in one of the
      + # module subdirectories.  However, it is faster if the objects are listed here,
      + # and I anticipate that a site-specific module directory might materialise at
      + # some point, so all the distributed modules are listed here.
      + #
      + # Each entry has the form:
      + #     module_name : Dir/object.o ...
      + #
      + # Lines containing `#' *anywhere* are ignored, as are blank lines.  Lines may
      + # be continued using the usual backslash/newline syntax.
      + #
      + # (This would be rather neater if we could rely on shell functions in sh.)
      + #
      + 
      + example:	Modules/example.o
      + files:		Modules/files.o
      + 
      + compctl:	Zle/compctl.o
      + deltochar:	Zle/deltochar.o
      + zle:		Zle/zle_bindings.o Zle/zle_hist.o Zle/zle_main.o \
      + 		Zle/zle_misc.o Zle/zle_move.o Zle/zle_refresh.o \
      + 		Zle/zle_tricky.o Zle/zle_utils.o Zle/zle_vi.o Zle/zle_word.o
      *** ............../dev/null	Thu Sep  7 20:04:30 1995
      --- Src/xmods.conf	Tue Dec 24 18:40:23 1996
      ***************
      *** 0 ****
      --- 1,30 ----
      + #
      + # $Id$
      + #
      + # xmods.conf - configuration of known modules
      + #
      + # This file includes two types of entries.  The first, defining a known module,
      + # looks like this:
      + #     module_name > builtin_name ...
      + # This makes the module module_name be linked in by default if dynamic linking
      + # is unavailable, and makes the specified builtins be autoloaded if the module
      + # is not linked in and dynamic linking is available.  Any more complicated
      + # code must be handled as a special case in init_bltinmods(), using the
      + # {UN,}LINKED_XMOD_* macros.
      + #
      + # The second type of entry, defining a dependency, looks like this:
      + #     module_name : module ...
      + # This declares that module_name depends on the other modules.  If module_name
      + # is linked in, the other modules must also be, and must be listed earlier in
      + # modules-bltin (and, consequently, here).
      + #
      + # Lines containing `#' *anywhere* are ignored, as are blank lines.  Lines may
      + # be continued using the usual backslash/newline syntax.
      + #
      + # (This would be rather neater if we could rely on shell functions in sh.)
      + #
      + 
      + zle> bindkey vared
      + 
      + compctl> compctl
      + compctl: zle

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMsA+GHD/+HJTpU/hAQFrVwQAk10SwI0nwPmBvRu7J4riqRExGIQSraRd
kV79cMHRjKMYZIPqCOP+Mg8iYpxzl3cYmyNUmOuNq+QwkWpvjQnxIgIQb7ICQ1Q5
wE88qRf/OG5rkA8wKS2Co4WJ6xh3P9LABdZDTl0z85iUVSAx20bRnGEcLstvvYAs
t68RRLglJMY=
=pxep
-----END PGP SIGNATURE-----



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