zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: dynamic loading on Cygwin
@ 2000-08-02 14:12 Andrej Borsenkow
  0 siblings, 0 replies; only message in thread
From: Andrej Borsenkow @ 2000-08-02 14:12 UTC (permalink / raw)
  To: ZSH workers mailing list

[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]

This was easier as I expected. Patch is pretty small and main change is in
mkmakemod.sh.

Changes:

- configure values are hardcoded, like for AIX. They are based on my
experience :-)

- mod_export is defined as ``__attribute__((__dllexport__))'' to make such
objects automatically exported.

- imported objects generally need ``__attribute__((__dllimport__))''. Because
it is not possible to take address of such objects in static context, and it
is often used for imported functions, I added two declarators:
mod_import_function and mod_import_variable. mod_import_function is empty and
mod_import_variable is normally defined as aboce on Cygwin. They appear only
in epro files; mkproto.awk generates them appropriate declarator  from
mod_export.

- if module depends on another module, it has to be linked with it's DLL. So,
the major change was in mkmakemod.sh to generate dependencies and proper link
commands. Actually, this contains the majority of Cygwin dependencies.

- this installs libzsh.dll into bindir. No fancy installation, because it
currently fails as long as Zsh runs anyway

- I had to put code from main() into init.c to avoid mod_export'ing everything
that is needed. So, main() now is really dummy.

- libzsh is linked against $(LIBS); this should not be a problem (I hope) as
any other module does it already.

- there were a couple of missing mod_export's

I'm using this version on both Unix and Cygwin; on Cygwin the failed tests
are:

- special files (there is no on Cygwin)
- process substitution (no FIFO or /dev/fd support)
- cd with chase_links; this looks like a bug in current Cygwin version (it was
O.K. before)
- all tests that use zpty. This is next on TODO list :-)

I could not test it on Unix that needs extra libzsh.so (I do not have it).

As mentioned, on Cygwin you need at least binutils-20000722-1. Version,
distributed in June, 2000, has problems with dllwrap; and older versions
porbably cannot link directly with DLL. I tested it with Cygwin-1.1.3-1
(prerelease).

cheers

-andrej

Have a nice DOS!
B >>

[-- Attachment #2: zsh-cygwin.diff --]
[-- Type: application/octet-stream, Size: 20518 bytes --]

Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.16
diff -u -r1.16 configure.in
--- configure.in	2000/08/02 13:54:17	1.16
+++ configure.in	2000/08/02 14:07:39
@@ -1467,6 +1467,18 @@
   zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}"
   zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}"
   zsh_cv_sys_dynamic_broken="${zsh_cv_sys_dynamic_broken=no}"
+elif test "x$ac_cv_cygwin" = xyes; then
+  DL_EXT="${DL_EXT=dll}"
+  DLLD="${DLLD=dllwrap}"
+  zsh_cv_func_dlsym_needs_underscore=no
+  DLLDFLAGS=${DLLDFLAGS=}
+  EXTRA_LDFLAGS=${EXTRA_LDFLAGS=}
+  zsh_cv_sys_dynamic_clash_ok="${zsh_cv_sys_dynamic_clash_ok=no}"
+  zsh_cv_sys_dynamic_rtld_global="${zsh_cv_sys_dynamic_rtld_global=yes}"
+  zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=no}"
+  zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}"
+  zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}"
+  zsh_cv_sys_dynamic_broken="${zsh_cv_sys_dynamic_broken=no}"
 elif test "x$dynamic" = xyes; then
   AC_CACHE_CHECK(if your system use ELF binaries,
    zsh_cv_sys_elf,
@@ -1653,6 +1665,16 @@
   SHORTBOOTNAMES=no
 fi
 AC_SUBST(SHORTBOOTNAMES)
+
+if test "x$ac_cv_cygwin" = xyes; then
+  INSTLIB="install.cygwin-lib"
+  UNINSTLIB="uninstall.cygwin-lib"
+else
+  INSTLIB="install.bin-\$(L)"
+  UNINSTLIB="uninstall.bin-\$(L)"
+fi
+AC_SUBST(INSTLIB)dnl
+AC_SUBST(UNINSTLIB)dnl
 
 AC_DEFINE_UNQUOTED(DL_EXT, "$DL_EXT")dnl
 AC_SUBST(D)dnl
Index: Etc/MACHINES
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/MACHINES,v
retrieving revision 1.5
diff -u -r1.5 MACHINES
--- Etc/MACHINES	2000/05/30 09:14:17	1.5
+++ Etc/MACHINES	2000/08/02 14:07:40
@@ -30,13 +30,18 @@
 	be on a file system mounted as binary (the mount command shows
 	`binmode').
 
-	Dynamic loading does not work (this is automatically detected),
-	though libraries not compiled by default will work (see the file
-	INSTALL for how to add these to the base executable).  In
+	Dynamic loading works as of cygwin-1.1.3 and binutils-20000722-1.
+	It was not tested for earlier versions. This does not imply
+	that every module will work. New completion and in
 	particular zsh/zftp and zsh/mathfunc are known to work.
 
 	Some of the tests in the Test subdirectory are known to fail:
 	this is because the UNIX environment is not completely implemented.
+
+	Cygwin allows mount without existing mount point (e.g.
+	"mount //server/path /usr/src" where /usr/src does not exist).
+	Path completion will fail inside these mounts; make sure that
+	every mount point really exists.
 
 Data General: DG/UX 5.4R3.10 MU01 (various AViiONs)
 	Should build `out-of-the-box'.
Index: Src/Makefile.in
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Makefile.in,v
retrieving revision 1.4
diff -u -r1.4 Makefile.in
--- Src/Makefile.in	2000/06/04 04:06:57	1.4
+++ Src/Makefile.in	2000/08/02 14:07:41
@@ -58,6 +58,8 @@
 
 MAIN_OBJS = main.o
 
+L = @L@
+
 LSTMP =
 LLIST =
 NSTMP = stamp-modobjs
@@ -65,6 +67,8 @@
 
 LIBZSH = libzsh-$(VERSION).$(DL_EXT)
 NIBZSH =
+INSTLIB = @INSTLIB@
+UNINSTLIB = @UNINSTLIB@
 
 ZSH_EXPORT = $(EXPOPT)zsh.export
 ZSH_NXPORT =
@@ -80,7 +84,7 @@
 
 $(LIBZSH): $(LIBOBJS) $(NSTMP)
 	rm -f $@
-	$(DLLINK) $(LIBOBJS) $(NLIST)
+	$(DLLINK) $(LIBOBJS) $(NLIST) $(LIBS)
 
 stamp-modobjs: modobjs
 	@if cmp -s stamp-modobjs.tmp stamp-modobjs; then \
@@ -176,7 +180,7 @@
 .PHONY: install.bin uninstall.bin
 
 # install binary, creating install directory if necessary
-install.bin-here: zsh$(EXEEXT) install.bin-@L@
+install.bin-here: zsh$(EXEEXT) $(INSTLIB)
 	$(sdir_top)/mkinstalldirs $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) $(STRIPFLAGS) zsh$(EXEEXT) $(DESTDIR)$(bindir)/$(tzsh)-$(VERSION)$(EXEEXT)
 	if test -f $(DESTDIR)$(bindir)/$(tzsh)$(EXEEXT); then \
@@ -192,17 +196,21 @@
 install.bin-L: $(LIBZSH)
 	$(sdir_top)/mkinstalldirs $(DESTDIR)$(libdir)/$(tzsh)
 	$(INSTALL_PROGRAM) $(LIBZSH) $(DESTDIR)$(libdir)/$(tzsh)/$(LIBZSH)
-.PHONY: install.bin-N install.bin-L
+install.cygwin-lib: $(LIBZSH)
+	$(INSTALL_PROGRAM) $(LIBZSH) $(DESTDIR)$(bindir)/$(LIBZSH)
+.PHONY: install.bin-N install.bin-L install.cygwin-lib
 
 # uninstall binary
-uninstall.bin-here: uninstall.bin-@L@
+uninstall.bin-here: $(UNINSTLIB)
 	rm -f $(DESTDIR)$(bindir)/$(tzsh)-$(VERSION) $(DESTDIR)$(bindir)/$(tzsh)$(EXEEXT)
 .PHONY: uninstall.bin-here uninstall.bin-@L@
 
 uninstall.bin-N:
 uninstall.bin-L:
 	rm -f $(DESTDIR)$(libdir)/$(tzsh)/$(LIBZSH)
-.PHONY: uninstall.bin-N uninstall.bin-L
+uninstall.cygwin-lib:
+	rm -f $(DESTDIR)$(bindir)/$(LIBZSH)
+.PHONY: uninstall.bin-N uninstall.bin-L uninstall.cygwin-lib
 
 # ========== DEPENDENCIES FOR CLEANUP ==========
 
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.9
diff -u -r1.9 init.c
--- Src/init.c	2000/07/30 19:18:13	1.9
+++ Src/init.c	2000/08/02 14:07:44
@@ -1123,3 +1123,97 @@
 	    NULL, 0);
     return 1;
 }
+
+/*
+ * This is real main entry point. This has to be mod_export'ed
+ * so zsh.exe can found it on Cygwin
+ */
+
+/**/
+mod_export int
+zsh_main(int argc, char **argv)
+{
+    char **t;
+    int t0;
+#ifdef USE_LOCALE
+    setlocale(LC_ALL, "");
+#endif
+
+    init_hackzero(argv, environ);
+
+    /*
+     * Provisionally set up the type table to allow metafication.
+     * This will be done properly when we have decided if we are
+     * interactive
+     */
+    typtab['\0'] |= IMETA;
+    typtab[STOUC(Meta)  ] |= IMETA;
+    typtab[STOUC(Marker)] |= IMETA;
+    for (t0 = (int)STOUC(Pound); t0 <= (int)STOUC(Nularg); t0++)
+	typtab[t0] |= ITOK | IMETA;
+
+    for (t = argv; *t; *t = metafy(*t, -1, META_ALLOC), t++);
+
+    zsh_name = argv[0];
+    do {
+      char *arg0 = zsh_name;
+      if (!(zsh_name = strrchr(arg0, '/')))
+	  zsh_name = arg0;
+      else
+	  zsh_name++;
+      if (*zsh_name == '-')
+	  zsh_name++;
+      if (strcmp(zsh_name, "su") == 0) {
+	  char *sh = zgetenv("SHELL");
+	  if (sh && *sh && arg0 != sh)
+	      zsh_name = sh;
+	  else
+	      break;
+      } else
+	  break;
+    } while (zsh_name);
+
+    fdtable_size = OPEN_MAX;
+    fdtable = zcalloc(fdtable_size);
+
+    createoptiontable();
+    emulate(zsh_name, 1);   /* initialises most options */
+    opts[LOGINSHELL] = (**argv == '-');
+    opts[MONITOR] = 1;   /* may be unset in init_io() */
+    opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid());
+    opts[USEZLE] = 1;   /* may be unset in init_io() */
+    parseargs(argv);   /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */
+
+    SHTTY = -1;
+    init_io();
+    setupvals();
+    init_signals();
+    init_bltinmods();
+    run_init_scripts();
+    init_misc();
+
+    for (;;) {
+	do
+	    loop(1,0);
+	while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
+	if (tok == LEXERR) {
+	    stopmsg = 1;
+	    zexit(lastval, 0);
+	}
+	if (!(isset(IGNOREEOF) && interact)) {
+#if 0
+	    if (interact)
+		fputs(islogin ? "logout\n" : "exit\n", shout);
+#endif
+	    zexit(lastval, 0);
+	    continue;
+	}
+	noexitct++;
+	if (noexitct >= 10) {
+	    stopmsg = 1;
+	    zexit(lastval, 0);
+	}
+	zerrnam("zsh", (!islogin) ? "use 'exit' to exit."
+		: "use 'logout' to logout.", NULL, 0);
+    }
+}
Index: Src/main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/main.c,v
retrieving revision 1.2
diff -u -r1.2 main.c
--- Src/main.c	2000/06/08 09:59:00	1.2
+++ Src/main.c	2000/08/02 14:07:44
@@ -34,87 +34,5 @@
 int
 main(int argc, char **argv)
 {
-    char **t;
-    int t0;
-#ifdef USE_LOCALE
-    setlocale(LC_ALL, "");
-#endif
-
-    init_hackzero(argv, environ);
-
-    /*
-     * Provisionally set up the type table to allow metafication.
-     * This will be done properly when we have decided if we are
-     * interactive
-     */
-    typtab['\0'] |= IMETA;
-    typtab[STOUC(Meta)  ] |= IMETA;
-    typtab[STOUC(Marker)] |= IMETA;
-    for (t0 = (int)STOUC(Pound); t0 <= (int)STOUC(Nularg); t0++)
-	typtab[t0] |= ITOK | IMETA;
-
-    for (t = argv; *t; *t = metafy(*t, -1, META_ALLOC), t++);
-
-    zsh_name = argv[0];
-    do {
-      char *arg0 = zsh_name;
-      if (!(zsh_name = strrchr(arg0, '/')))
-	  zsh_name = arg0;
-      else
-	  zsh_name++;
-      if (*zsh_name == '-')
-	  zsh_name++;
-      if (strcmp(zsh_name, "su") == 0) {
-	  char *sh = zgetenv("SHELL");
-	  if (sh && *sh && arg0 != sh)
-	      zsh_name = sh;
-	  else
-	      break;
-      } else
-	  break;
-    } while (zsh_name);
-
-    fdtable_size = OPEN_MAX;
-    fdtable = zcalloc(fdtable_size);
-
-    createoptiontable();
-    emulate(zsh_name, 1);   /* initialises most options */
-    opts[LOGINSHELL] = (**argv == '-');
-    opts[MONITOR] = 1;   /* may be unset in init_io() */
-    opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid());
-    opts[USEZLE] = 1;   /* may be unset in init_io() */
-    parseargs(argv);   /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */
-
-    SHTTY = -1;
-    init_io();
-    setupvals();
-    init_signals();
-    init_bltinmods();
-    run_init_scripts();
-    init_misc();
-
-    for (;;) {
-	do
-	    loop(1,0);
-	while (tok != ENDINPUT && (tok != LEXERR || isset(SHINSTDIN)));
-	if (tok == LEXERR) {
-	    stopmsg = 1;
-	    zexit(lastval, 0);
-	}
-	if (!(isset(IGNOREEOF) && interact)) {
-#if 0
-	    if (interact)
-		fputs(islogin ? "logout\n" : "exit\n", shout);
-#endif
-	    zexit(lastval, 0);
-	    continue;
-	}
-	noexitct++;
-	if (noexitct >= 10) {
-	    stopmsg = 1;
-	    zexit(lastval, 0);
-	}
-	zerrnam("zsh", (!islogin) ? "use 'exit' to exit."
-		: "use 'logout' to logout.", NULL, 0);
-    }
+    return (zsh_main(argc, argv));
 }
Index: Src/makepro.awk
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/makepro.awk,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 makepro.awk
--- Src/makepro.awk	1999/12/16 14:26:32	1.1.1.9
+++ Src/makepro.awk	2000/08/02 14:07:45
@@ -117,6 +117,10 @@
 	dcl = dtype " " dcltor ";"
 	if(locality ~ /E/)
 	    dcl = "extern " dcl
+	if(isfunc)
+	    gsub(/ mod_export /, " mod_import_function ", dcl)
+	else
+	    gsub(/ mod_export /, " mod_import_variable ", dcl)
 	gsub(/@[+-]/, "", dcl)
 	gsub(/ +/, " ", dcl)
 	while(match(dcl, /[^_0-9A-Za-z] ./) || match(dcl, /. [^_0-9A-Za-z]/))
Index: Src/mkmakemod.sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/mkmakemod.sh,v
retrieving revision 1.1.1.12
diff -u -r1.1.1.12 mkmakemod.sh
--- Src/mkmakemod.sh	2000/01/06 16:19:25	1.1.1.12
+++ Src/mkmakemod.sh	2000/08/02 14:07:47
@@ -73,6 +73,15 @@
     s,\(.\)/$,\1,
 '
 
+CYGWIN=no
+if uname -s > /dev/null 2>&1; then
+    case `uname -s` in
+	CYGWIN* )
+	    CYGWIN=yes
+	;;
+    esac
+fi
+
 # decide which stages to process
 first_stage=true
 second_stage=true
@@ -173,6 +182,8 @@
     remote_mdhs=
     other_exports=
     remote_exports=
+    other_modules=
+    remote_modules=
     for mddname in $here_mddnames; do
 
 	unset name moddeps nozshdep alwayslink hasexport
@@ -187,18 +198,37 @@
 
 	dobjects=`echo $objects '' | sed 's,\.o ,..o ,g'`
 	modhdeps=
+	mododeps=
 	exportdeps=
 	imports=
 	q_moddeps=
+	dllname=
 	for dep in $moddeps; do
 	    q_dep=`echo $dep | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
 	    q_moddeps="$q_moddeps $q_dep"
 	    eval "depfile=\$modfile_$q_dep"
 	    eval `echo $depfile | sed 's,/\([^/]*\)\.mdd$,;depbase=\1,;s,^,loc=,'`
+	    case "$binmod" in
+		*" $dep "* )
+		    dep=zsh/main
+		;;
+	    esac
+
 	    case $the_subdir in
 		$loc)
 		    mdh="${depbase}.mdh"
 		    export="${depbase}.export"
+		    case "$dep" in
+			zsh/main )
+			    mdll="\$(dir_top)/Src/libzsh-\$(VERSION).\$(DL_EXT) "
+			;;
+			zsh/$mddname )
+			    mdll=
+			;;
+			* )
+			    mdll="${depbase}.\$(DL_EXT) "
+			;;
+		    esac
 		    ;;
 		$loc/*)
 		    mdh="\$(dir_top)/$loc/${depbase}.mdh"
@@ -211,6 +241,21 @@
 			*" $export "*) ;;
 			*) other_exports="$other_exports $export" ;;
 		    esac
+		    case "$dep" in
+			zsh/main )
+			    mdll="\$(dir_top)/Src/libzsh-\$(VERSION).\$(DL_EXT) "
+			;;
+			zsh/$mddname )
+			    mdll=
+			;;
+			* )
+			    mdll="\$(dir_top)/$loc/${depbase}.\$(DL_EXT) "
+			;;
+		    esac
+		    case "$other_modules " in
+			*" $mdll "*) ;;
+			*) other_modules="$other_modules $mdll" ;;
+		    esac
 		    ;;
 		*)
 		    mdh="\$(dir_top)/$loc/${depbase}.mdh"
@@ -223,12 +268,40 @@
 			*" $export "*) ;;
 			*) remote_exports="$remote_exports $export" ;;
 		    esac
+		    case "$dep" in
+			zsh/main )
+			    mdll="\$(dir_top)/Src/libzsh-\$(VERSION).\$(DL_EXT) "
+			;;
+			zsh/$mddname )
+			    mdll=
+			;;
+			* )
+			    mdll="\$(dir_top)/$loc/${depbase}.\$(DL_EXT) "
+			;;
+		    esac
+		    case "$remote_modules " in
+			*" $mdll "*) ;;
+			*) remote_modules="$remote_modules $mdll" ;;
+		    esac
 		    ;;
 	    esac
 	    modhdeps="$modhdeps $mdh"
 	    exportdeps="$exportdeps $export"
 	    imports="$imports \$(IMPOPT)$export"
+	    if test $CYGWIN = yes -a -n "$mdll"; then
+		case "$mododeps" in
+		    *" $mdll "* )
+			:
+		    ;;
+		    * )
+			mododeps="$mododeps $mdll"
+		    ;;
+		esac
+	    fi
 	done
+	if test $CYGWIN = yes; then
+		dllname="--dllname $q_name"
+	fi
 
 	echo "##### ===== DEPENDENCIES GENERATED FROM ${mddname}.mdd ===== #####"
 	echo
@@ -239,6 +312,8 @@
 	echo "INCS_${mddname} = \$(EPRO_${mddname}) $otherincs"
 	echo "EXPIMP_${mddname} = $imports \$(EXPOPT)$mddname.export"
 	echo "NXPIMP_${mddname} ="
+	echo "DEPMODS_${mddname} = $mododeps"
+	echo "DLLNAME_${mddname} = $dllname"
 	echo
 	echo "proto.${mddname}: \$(EPRO_${mddname})"
 	echo "\$(SYMS_${mddname}): \$(PROTODEPS)"
@@ -263,9 +338,9 @@
 	    echo "uninstall.modules.${mddname}:"
 	    echo "	rm -f \$(DESTDIR)\$(MODDIR)/${name}.\$(DL_EXT)"
 	    echo
-	    echo "${mddname}.\$(DL_EXT): \$(MODDOBJS_${mddname}) ${mddname}.export $exportdeps"
+	    echo "${mddname}.\$(DL_EXT): \$(MODDOBJS_${mddname}) ${mddname}.export $exportdeps \$(DEPMODS_${mddname})"
 	    echo '	rm -f $@'
-	    echo "	\$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(LIBS)"
+	    echo "	\$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(DLLNAME_${mddname}) \$(MODDOBJS_${mddname}) \$(DEPMODS_${mddname}) \$(LIBS) "
 	    echo
 	fi
 	echo "${mddname}.mdhi: ${mddname}.mdhs \$(INCS_${mddname})"
@@ -293,16 +368,30 @@
 	echo "	    echo '#define have_${q_name}_module'; \\"
 	echo "	    echo; \\"
 	echo "	    echo '# ifndef IMPORTING_MODULE_${q_name}'; \\"
-	echo "	    if test @SHORTBOOTNAMES@ = yes; then \\"
-	echo "		echo '#  ifndef MODULE'; \\"
-	echo "	    fi; \\"
-	echo "	    echo '#   define boot_ boot_${q_name}'; \\"
-	echo "	    echo '#   define cleanup_ cleanup_${q_name}'; \\"
-	echo "	    echo '#   define setup_ setup_${q_name}'; \\"
-	echo "	    echo '#   define finish_ finish_${q_name}'; \\"
-	echo "	    if test @SHORTBOOTNAMES@ = yes; then \\"
-	echo "		echo '#  endif /* !MODULE */'; \\"
-	echo "	    fi; \\"
+	if test $CYGWIN = yes; then
+	    echo "	    echo '#  ifdef MODULE'; \\"
+	    echo "	    echo '#   define boot_ __attribute__((__dllexport__)) boot_${q_name}'; \\"
+	    echo "	    echo '#   define cleanup_ __attribute__((__dllexport__)) cleanup_${q_name}'; \\"
+	    echo "	    echo '#   define setup_ __attribute__((__dllexport__)) setup_${q_name}'; \\"
+	    echo "	    echo '#   define finish_ __attribute__((__dllexport__)) finish_${q_name}'; \\"
+	    echo "	    echo '#  else /* MODULE */'; \\"
+	    echo "	    echo '#   define boot_ boot_${q_name}'; \\"
+	    echo "	    echo '#   define cleanup_ cleanup_${q_name}'; \\"
+	    echo "	    echo '#   define setup_ setup_${q_name}'; \\"
+	    echo "	    echo '#   define finish_ finish_${q_name}'; \\"
+	    echo "	    echo '#  endif /* MODULE */'; \\"
+	else
+	    echo "	    if test @SHORTBOOTNAMES@ = yes; then \\"
+	    echo "		echo '#  ifndef MODULE'; \\"
+	    echo "	    fi; \\"
+	    echo "	    echo '#   define boot_ boot_${q_name}'; \\"
+	    echo "	    echo '#   define cleanup_ cleanup_${q_name}'; \\"
+	    echo "	    echo '#   define setup_ setup_${q_name}'; \\"
+	    echo "	    echo '#   define finish_ finish_${q_name}'; \\"
+	    echo "	    if test @SHORTBOOTNAMES@ = yes; then \\"
+	    echo "		echo '#  endif /* !MODULE */'; \\"
+	    echo "	    fi; \\"
+	fi
 	echo "	    echo '# endif /* !IMPORTING_MODULE_${q_name} */'; \\"
 	echo "	    echo; \\"
 	if test -n "$moddeps"; then (
@@ -327,9 +416,21 @@
 	    echo "	    echo; \\"
 	fi
 	if test -n "$proto"; then
+	    if test "$CYGWIN" = yes; then
+		echo "	    echo '# ifndef IMPORTING_MODULE_${q_name} '; \\"
+		echo "	    echo '#  undef mod_import_variable'; \\"
+		echo "	    echo '#  define mod_import_variable'; \\"
+		echo "	    echo '# endif /* IMPORTING_MODULE_${q_name} */'; \\"
+	    fi
 	    echo "	    for epro in \$(EPRO_${mddname}); do \\"
 	    echo "		echo '# include \"'\$\$epro'\"'; \\"
 	    echo "	    done; \\"
+	    if test "$CYGWIN" = yes; then
+		echo "	    echo '# ifndef IMPORTING_MODULE_${q_name} '; \\"
+		echo "	    echo '#  undef mod_import_variable'; \\"
+		echo "	    echo '#  define mod_import_variable __attribute__((__dllimport__))'; \\"
+		echo "	    echo '# endif /* IMPORTING_MODULE_${q_name} */'; \\"
+	    fi
 	    echo "	    echo; \\"
 	fi
 	echo "	    echo '#endif /* !have_${q_name}_module */'; \\"
@@ -343,7 +444,7 @@
 
     done
 
-    if test -n "$remote_mdhs$other_mdhs$remote_exports$other_exports"; then
+    if test -n "$remote_mdhs$other_mdhs$remote_exports$other_exports$remote_modules$other_modules"; then
 	echo "##### ===== DEPENDENCIES FOR REMOTE MODULES ===== #####"
 	echo
 	for mdh in $remote_mdhs; do
@@ -365,6 +466,18 @@
 	    echo "${other_exports}:" | sed 's,^ ,,'
 	    echo "	false # should only happen with make -n"
 	    echo
+	fi
+	if test "$CYGWIN" = yes; then
+	    for mdll in $remote_modules; do
+		echo "$mdll: FORCE"
+		echo "	@cd @%@ && \$(MAKE) \$(MAKEDEFS) @%@$mdll"
+		echo
+	    done | sed 's,^\(.*\)@%@\(.*\)@%@\(.*\)/\([^/]*\)$,\1\3\2\4,'
+	    if test -n "$other_modules"; then
+		echo "${other_modules}:" | sed 's,^ ,,'
+		echo "	false # should only happen with make -n"
+		echo
+	    fi
 	fi
     fi
 
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.12
diff -u -r1.12 parse.c
--- Src/parse.c	2000/07/21 07:50:08	1.12
+++ Src/parse.c	2000/08/02 14:07:50
@@ -3070,7 +3070,8 @@
 {
 }
 
-void
+/**/
+mod_export void
 closedumps(void)
 {
 }
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.17
diff -u -r1.17 zsh.h
--- Src/zsh.h	2000/07/30 17:03:53	1.17
+++ Src/zsh.h	2000/08/02 14:07:51
@@ -1681,7 +1681,15 @@
 /* Pseudo-keyword to mark exportedness */
 /***************************************/
 
+#ifdef __CYGWIN__
+#define mod_export __attribute__((__dllexport__))
+#define mod_import_variable __attribute__((__dllimport__))
+#define mod_import_function
+#else
 #define mod_export
+#define mod_import_variable
+#define mod_import_function
+#endif
 
 /***************************************/
 /* Hooks in core.                      */
Index: Src/Zle/zle_utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v
retrieving revision 1.4
diff -u -r1.4 zle_utils.c
--- Src/Zle/zle_utils.c	2000/07/04 15:04:17	1.4
+++ Src/Zle/zle_utils.c	2000/08/02 14:07:53
@@ -379,7 +379,7 @@
  * The message must be metafied.                              */
 
 /**/
-void
+void mod_export
 showmsg(char const *msg)
 {
     char const *p;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-08-02 14:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-02 14:12 PATCH: dynamic loading on Cygwin Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).