From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28151 invoked from network); 22 Dec 1996 18:29:08 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 22 Dec 1996 18:29:08 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id NAA16844; Sun, 22 Dec 1996 13:19:15 -0500 (EST) Resent-Date: Sun, 22 Dec 1996 13:19:15 -0500 (EST) From: Zefram Message-Id: <768.199612221820@stone.dcs.warwick.ac.uk> Subject: linked-in modules To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Sun, 22 Dec 1996 18:20:17 +0000 (GMT) X-Patch: 144 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]8613.82 X-US-Congress: Moronic fuckers Content-Type: text Resent-Message-ID: <"WlQTN3.0.774.ZkNlo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2611 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- This patch makes the linked-in modules mechanism more general. It makes it available whether dynamic loading is available or not, the way I originally intended it. It also avoids a lot of special-casing in the Makefiles, so that the Makefile only needs to know specially about modules that have more than one source file (currently only zle). -zefram Index: Src/Makefile.in =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/Makefile.in,v retrieving revision 1.1.1.13 diff -c -r1.1.1.13 Makefile.in *** Src/Makefile.in 1996/12/22 01:13:16 1.1.1.13 --- Src/Makefile.in 1996/12/22 04:17:55 *************** *** 75,81 **** prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \ libdir='$(libdir)' infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)' ! MODBINS = $(srcdir)/modules-bltin DLEXT=.$(DL_EXT) NLEXT=._foobarbaz_ --- 75,81 ---- prefix='$(prefix)' exec_prefix='$(exec_prefix)' bindir='$(bindir)' \ libdir='$(libdir)' infodir='$(infodir)' mandir='$(mandir)' manext='$(manext)' ! MODBINS = modules-bltin DLEXT=.$(DL_EXT) NLEXT=._foobarbaz_ *************** *** 131,137 **** system.h zsh.h ztype.h Zle/zle.h # zsh headers necessary for compilation ! HDRS = $(DIST_HDRS) signames.h @RLIMITS_SRC_H@ ../config.h # zsh C source included in distribution DIST_SRCS = builtin.c compat.c cond.c exec.c glob.c hashtable.c hist.c \ --- 131,137 ---- system.h zsh.h ztype.h Zle/zle.h # zsh headers necessary for compilation ! HDRS = $(DIST_HDRS) signames.h zshxmods.h @RLIMITS_SRC_H@ ../config.h # zsh C source included in distribution DIST_SRCS = builtin.c compat.c cond.c exec.c glob.c hashtable.c hist.c \ *************** *** 142,167 **** Zle/zle_vi.c Zle/zle_word.c Zle/zle.h Zle/compctl.c $(DIST_HDRS) # generated prototypes - DYNAMIC_PROTO = - NYNAMIC_PROTO = Zle/zle_bindings.pro Zle/zle_hist.pro \ - Zle/zle_main.pro Zle/zle_misc.pro Zle/zle_move.pro Zle/zle_refresh.pro \ - Zle/zle_tricky.pro Zle/zle_utils.pro Zle/zle_vi.pro Zle/zle_word.pro \ - Zle/zle_deltochar.pro Zle/compctl.pro - PROTO = builtin.pro compat.pro cond.pro exec.pro glob.pro hashtable.pro \ hist.pro init.pro input.pro jobs.pro lex.pro linklist.pro loop.pro \ main.pro math.pro mem.pro module.pro params.pro parse.pro prompt.pro \ ! signals.pro subst.pro text.pro utils.pro watch.pro $(@D@YNAMIC_PROTO) # object files - DYNAMIC_OBJS = - NYNAMIC_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 Zle/compctl.o LIBOBJS = builtin.o compat.o cond.o exec.o glob.o hashtable.o \ hist.o init.o input.o jobs.o lex.o linklist.o loop.o math.o mem.o \ module.o params.o parse.o prompt.o signals.o subst.o text.o \ ! utils.o watch.o $(@D@YNAMIC_OBJS) # dynamically loadable modules MODULE_DIRS = Modules Zle --- 142,157 ---- Zle/zle_vi.c Zle/zle_word.c Zle/zle.h Zle/compctl.c $(DIST_HDRS) # generated prototypes PROTO = builtin.pro compat.pro cond.pro exec.pro glob.pro hashtable.pro \ hist.pro init.pro input.pro jobs.pro lex.pro linklist.pro loop.pro \ main.pro math.pro mem.pro module.pro params.pro parse.pro prompt.pro \ ! signals.pro subst.pro text.pro utils.pro watch.pro # object files LIBOBJS = builtin.o compat.o cond.o exec.o glob.o hashtable.o \ hist.o init.o input.o jobs.o lex.o linklist.o loop.o math.o mem.o \ module.o params.o parse.o prompt.o signals.o subst.o text.o \ ! utils.o watch.o # dynamically loadable modules MODULE_DIRS = Modules Zle *************** *** 169,191 **** LOBJS = main.o NOBJS = $(LIBOBJS) main.o OBJS = $(LIBOBJS) $(LOBJS) LIBZSH = libzsh.so.$(VERSION) NIBZSH = # ========= DEPENDENCIES FOR BUILDING ========== # default target ! all: zsh modules ! modules: $(PROTO) $(ANSI@U@KNR) $(MO@D@ULE_DIRS) ! zsh: $(PROTO) $(ANSI@U@KNR) $(@L@IBZSH) $(@L@OBJS) ! $(LINK) $(@L@OBJS) $(LIBS) ! $(LIBZSH): $(LIBOBJS) $(DLLD) $(LDFLAGS) $(DLLDFLAGS) -o $(LIBZSH) $(LIBOBJS) $(NLIST) ln -sf $(LIBZSH) libzsh.so --- 159,199 ---- LOBJS = main.o NOBJS = $(LIBOBJS) main.o + LSTMP = + LLIST = + NSTMP = stamp-modobjs + NLIST = `cat stamp-modobjs` OBJS = $(LIBOBJS) $(LOBJS) 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 ========== # default target ! all: bin modules ! ! modules: proto $(ANSI@U@KNR) $(MO@D@ULE_DIRS) ! bin: proto zsh ! zsh: $(ANSI@U@KNR) $(@L@IBZSH) $(@L@OBJS) $(@L@STMP) ! $(LINK) $(@L@OBJS) $(@L@LIST) $(LIBS) ! $(LIBZSH): $(LIBOBJS) $(NSTMP) $(DLLD) $(LDFLAGS) $(DLLDFLAGS) -o $(LIBZSH) $(LIBOBJS) $(NLIST) ln -sf $(LIBZSH) libzsh.so *************** *** 207,212 **** --- 215,222 ---- init.o: bltinmods.list zshpaths.h + module.o: zshxmods.h + $(MODULE_DIRS): FORCE @cd $@ && $(MAKE) $(MAKEDEFS) modules *************** *** 225,232 **** --- 235,308 ---- echo "DOMOD(boot_$$mod)"; \ done ) > $@ + zshxmods.h: $(MODBINS) + ( \ + 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) + @for dir in $(MODULE_DIRS); do \ + ( cd $$dir && $(MAKE) $(MAKEDEFS) proto ) || exit 1; \ + done + $(PROTO): makepro.sed + $(NSTMP): FORCE + @dn=true; \ + 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; \ + echo Making $${objs}:; \ + $(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; \ + echo "\`$(NSTMP)' is up to date."; \ + else \ + mv -f $(NSTMP).tmp $(NSTMP); \ + echo "Updated \`$(NSTMP)'."; \ + fi + FORCE: # ========== DEPENDENCIES FOR INSTALLING ========== *************** *** 269,275 **** clean: mostlyclean rm -f zsh ansi2knr $(@D@LCLEAN) signames.h rlimits.h \ ! zshpaths.h bltinmods.list *.*.c *.pro distclean: clean rm -f Makefile --- 345,351 ---- clean: mostlyclean rm -f zsh ansi2knr $(@D@LCLEAN) signames.h rlimits.h \ ! zshpaths.h bltinmods.list zshxmods.h *.*.c *.pro distclean: clean rm -f Makefile Index: Src/globals.h =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/globals.h,v retrieving revision 1.1.1.27 diff -c -r1.1.1.27 globals.h *** Src/globals.h 1996/12/22 01:13:23 1.1.1.27 --- Src/globals.h 1996/12/22 03:58:40 *************** *** 559,579 **** /* flag for whether terminal has automargin (wraparound) capability */ EXTERN int hasam; ! #ifdef ZLE_MODULE # ifdef GLOBALS void (*trashzleptr) _((void)) = noop_function; unsigned char * (*zlereadptr) _((char *lp, char *rp)) = load_zleread; void (*spaceinlineptr) _((int)) = noop_function_int; void (*gotwordptr) _((void)) = noop_function; void (*refreshptr) _((void)) = noop_function; ! # else extern void (*trashzleptr) _((void)); extern unsigned char * (*zlereadptr) _((char *lp, char *rp)); extern void (*spaceinlineptr) _((int)); extern void (*gotwordptr) _((void)); extern void (*refreshptr) _((void)); ! # endif ! #endif /* pid of process undergoing 'process substitution' */ --- 559,579 ---- /* flag for whether terminal has automargin (wraparound) capability */ EXTERN int hasam; ! #ifdef UNLINKED_XMOD_zle # ifdef GLOBALS void (*trashzleptr) _((void)) = noop_function; unsigned char * (*zlereadptr) _((char *lp, char *rp)) = load_zleread; void (*spaceinlineptr) _((int)) = noop_function_int; void (*gotwordptr) _((void)) = noop_function; void (*refreshptr) _((void)) = noop_function; ! # else /* !GLOBALS */ extern void (*trashzleptr) _((void)); extern unsigned char * (*zlereadptr) _((char *lp, char *rp)); extern void (*spaceinlineptr) _((int)); extern void (*gotwordptr) _((void)); extern void (*refreshptr) _((void)); ! # endif /* !GLOBALS */ ! #endif /* UNLINKED_XMOD_zle */ /* pid of process undergoing 'process substitution' */ Index: Src/init.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/init.c,v retrieving revision 1.1.1.28 diff -c -r1.1.1.28 init.c *** Src/init.c 1996/12/22 01:13:26 1.1.1.28 --- Src/init.c 1996/12/22 04:16:27 *************** *** 545,557 **** createnameddirtable(); /* create hash table for named directories */ createparamtable(); /* create paramater hash table */ ! #ifdef ZLE_MODULE ! add_dep("compctl", "zle"); addbuiltin("bindkey", 0, NULL, 0, -1, "zle"); addbuiltin("vared", 0, NULL, 1, 7, "zle"); ! addbuiltin("compctl", 0, NULL, 0, -1, "compctl"); #endif #ifdef HAVE_GETRLIMIT for (i = 0; i != RLIM_NLIMITS; i++) { getrlimit(i, current_limits + i); --- 545,566 ---- createnameddirtable(); /* create hash table for named directories */ createparamtable(); /* create paramater hash table */ ! #ifdef UNLINKED_XMOD_zle addbuiltin("bindkey", 0, NULL, 0, -1, "zle"); addbuiltin("vared", 0, NULL, 1, 7, "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 + addbuiltin("compctl", 0, NULL, 0, -1, "compctl"); + ZLE_DEP("compctl"); + #endif /* UNLINKED_XMOD_compctl */ + #ifdef HAVE_GETRLIMIT for (i = 0; i != RLIM_NLIMITS; i++) { getrlimit(i, current_limits + i); *************** *** 784,790 **** source(buf); } - #ifndef DYNAMIC #define DOMOD(boot) int boot(Module); #include "bltinmods.list" #undef DOMOD --- 793,798 ---- *************** *** 797,800 **** #include "bltinmods.list" #undef DOMOD } - #endif /*!DYNAMIC*/ --- 805,807 ---- Index: Src/main.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/main.c,v retrieving revision 1.1.1.2 diff -c -r1.1.1.2 main.c *** Src/main.c 1996/12/22 01:13:28 1.1.1.2 --- Src/main.c 1996/12/22 01:32:06 *************** *** 68,76 **** setupvals(); init_signals(); global_heapalloc(); - #ifndef DYNAMIC init_bltinmods(); - #endif run_init_scripts(); init_misc(); --- 68,74 ---- Index: Src/module.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/module.c,v retrieving revision 1.1.1.3 diff -c -r1.1.1.3 module.c *** Src/module.c 1996/12/22 01:13:30 1.1.1.3 --- Src/module.c 1996/12/22 04:16:34 *************** *** 410,416 **** return ret; } ! #ifdef ZLE_MODULE typedef void (*Voidfn) _((void)); static struct symbols { --- 410,416 ---- return ret; } ! #ifdef UNLINKED_XMOD_zle typedef void (*Voidfn) _((void)); static struct symbols { *************** *** 481,485 **** return (unsigned char *)shingetline(); } } ! #endif /* ZLE_MODULE */ #endif /* DYNAMIC */ --- 481,485 ---- return (unsigned char *)shingetline(); } } ! #endif /* UNLINKED_XMOD_zle */ #endif /* DYNAMIC */ Index: Src/zsh.h =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/zsh.h,v retrieving revision 1.1.1.26 diff -c -r1.1.1.26 zsh.h *** Src/zsh.h 1996/12/22 01:13:37 1.1.1.26 --- Src/zsh.h 1996/12/22 04:16:13 *************** *** 38,52 **** #include #include ! #ifdef DYNAMIC ! # ifndef MODULE ! # define ZLE_MODULE ! # define trashzle() trashzleptr() ! # define zleread(X,Y) zlereadptr(X,Y) ! # define spaceinline(X) spaceinlineptr(X) ! # define gotword() gotwordptr() ! # define refresh() refreshptr() ! # endif #endif /* A few typical macros */ --- 38,51 ---- #include #include ! #include "zshxmods.h" ! ! #if defined(UNLINKED_XMOD_zle) && !defined(IN_ZLE) ! # define trashzle() trashzleptr() ! # define zleread(X,Y) zlereadptr(X,Y) ! # define spaceinline(X) spaceinlineptr(X) ! # define gotword() gotwordptr() ! # define refresh() refreshptr() #endif /* A few typical macros */ *************** *** 1303,1309 **** #include "signals.h" #include "prototypes.h" #include "globals.h" ! #if !defined(ZLE_MODULE) && !defined(MODULE) # include "zle.h" #endif #include "hashtable.h" --- 1302,1308 ---- #include "signals.h" #include "prototypes.h" #include "globals.h" ! #if defined(LINKED_XMOD_zle) && !defined(MODULE) # include "zle.h" #endif #include "hashtable.h" Index: Src/Modules/Makefile.in =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/Modules/Makefile.in,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 Makefile.in *** Src/Modules/Makefile.in 1996/12/22 01:13:38 1.1.1.1 --- Src/Modules/Makefile.in 1996/12/22 02:34:47 *************** *** 96,102 **** # default target all: modules ! modules: $(PROTO) $(MODULES) # ========== DEPENDENCIES FOR INSTALLING ========== --- 96,106 ---- # default target all: modules ! modules: proto $(MODULES) ! ! proto: $(PROTO) ! ! $(PROTO): ../makepro.sed # ========== DEPENDENCIES FOR INSTALLING ========== Index: Src/Zle/Makefile.in =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/Zle/Makefile.in,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 Makefile.in *** Src/Zle/Makefile.in 1996/12/22 01:13:38 1.1.1.1 --- Src/Zle/Makefile.in 1996/12/22 02:34:24 *************** *** 105,116 **** # default target all: modules ! modules: $(PROTO) $(MODULES) zle.so: $(ZLEOBJS) $(LINK) $(ZLEOBJS) $(OBJS): $(HDRS) # ========== DEPENDENCIES FOR INSTALLING ========== --- 105,120 ---- # default target all: modules ! modules: proto $(MODULES) zle.so: $(ZLEOBJS) $(LINK) $(ZLEOBJS) $(OBJS): $(HDRS) + + proto: $(PROTO) + + $(PROTO): ../makepro.sed # ========== DEPENDENCIES FOR INSTALLING ========== Index: Src/Zle/zle.h =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/Zle/zle.h,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 zle.h *** Src/Zle/zle.h 1996/12/22 01:13:39 1.1.1.1 --- Src/Zle/zle.h 1996/12/22 03:13:55 *************** *** 32,37 **** --- 32,38 ---- #ifndef _ZLE_H #define _ZLE_H + #define IN_ZLE #include "zsh.h" #ifdef ZLEGLOBALS Index: Src/Zle/zle_main.c =================================================================== RCS file: /home/zefram/usr/cvsroot/zsh/Src/Zle/zle_main.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 zle_main.c *** Src/Zle/zle_main.c 1996/12/22 01:13:39 1.1.1.1 --- Src/Zle/zle_main.c 1996/12/22 03:53:01 *************** *** 1359,1365 **** /* Compctl Hash Table Functions */ /********************************/ ! #ifndef MODULE void printcompctlp _((HashNode hn, int printflags)); #endif --- 1359,1365 ---- /* Compctl Hash Table Functions */ /********************************/ ! #ifdef LINKED_XMOD_compctl void printcompctlp _((HashNode hn, int printflags)); #endif *************** *** 1379,1385 **** compctltab->disablenode = NULL; compctltab->enablenode = NULL; compctltab->freenode = freecompctlp; ! #ifdef MODULE compctltab->printnode = NULL; #else compctltab->printnode = printcompctlp; --- 1379,1385 ---- compctltab->disablenode = NULL; compctltab->enablenode = NULL; compctltab->freenode = freecompctlp; ! #ifndef LINKED_XMOD_compctl compctltab->printnode = NULL; #else compctltab->printnode = printcompctlp; -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBMrzFqnD/+HJTpU/hAQGnwQP/ZbFKW6dCj1aybJb/VwsK9KUO45eriqFM VNh+pem2w1DI2/7momuW9j0ED2LMc6ne9ds05tvwt/K9VE0N2njdopjMZM1YxKS4 3atsgvVvFs9oDxtyDxklpLLHU0GAgx4FUq6GJ3NCC6Dd4bro9zdnWNPKXKWudZvj 1XV2Htedx3s= =jHYT -----END PGP SIGNATURE-----