Subject: bug#6602: closed (Re: bug#6602: [PATCH] make dist target for Windows)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 24 Jul 2010 13:30:03 +0000

Your bug report

#6602: [PATCH] make dist target for Windows

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
6602: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6602
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#6602: [PATCH] make dist target for Windows
From: Juanma Barranquero <[email-masked]>
To: Christoph <[email-masked]>
Cc: [email-masked]
Date: Sat, 24 Jul 2010 15:28:41 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Sat, Jul 24, 2010 at 05:18, Christoph <[email-masked]> wrote:

> Find attached the new patch for the `make dist' target.
>
> I added a Changelog and NEWS entry and removed README.W32 and makedist.bat
> files from the nt/ directory.

OK, thaks a lot.

A few comments (nitpicks, mostly):

 - You've added the ChangeLog entry to the root directory's ChangeLog,
instead of nt/ChangeLog. Also, it lacks an entry in admin/ChangeLog
about the changes in that directory (you've documented most of them in
the other ChangeLog, though). In some cases, as when moving files, it
is customary to put a "Moved to X/" entry in the old directory's
ChangeLog, and ad "Moved from Y/" in the new's.

- Changes to documentation files, like etc/NEWS and nt/INSTALL, must
also be documented in ChangeLog entries.

- If you're going to move a file, like README.W32, instead of

    cd admin/nt
    copy README.W32 ../../nt
    del README.W32

  or

    move admin/nt/README.W32 nt/

  please do

    bzr mv admin/nt/README.W32 nt/

  so Bazaar knows that it is the same file.

- It's best if you do these changes in a branch, and then submit a
bundle. For example, applying your patch creates a file
nt/zipdist.bat, but it has to be "bzr add"ed manually.

- Try not to introduce trailing whitespace in files you modify. Not
earth-shaking, but ugly if you have `show-trailing-whitespace' set to
t (which I recommend).

That said, I'm committing your change right now. Great work. Thanks!

    Juanma

Subject: [PATCH] make dist target for Windows
From: Christoph <[email-masked]>
To: [email-masked]
Cc: Eli Zaretskii <[email-masked]>
Date: Sat, 10 Jul 2010 08:00:25 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Glenn Morris wrote:

 > Also, I keep saying this, but I strongly advise people to post patches
 > like this to the bug list, since then they are much less likely to get
 > forgotten / overlooked. I used to forward things there, but have given
 > up. If you post things here, you basically rely on people keeping
 > things in their inbox until dealt with.

Following Glenn's advice I repost my patch to this list.

Initial discussion of this patch:
http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01461.html

Thanks,
Christoph

-------- Original Message --------
Subject: Re: make dist target for Windows
Date: Sat, 03 Jul 2010 11:08:03 -0600
From: Christoph <[email-masked]>
To: Eli Zaretskii <[email-masked]>
CC: Christoph <[email-masked]>, [email-masked]

On 4/8/2010 11:51 AM, Eli Zaretskii wrote:

> Well, do you have assignment to FSF on record?  I cannot see it.  If
> you don't, please talk to Stefan and Yidong to start the paperwork.
>
> Once that is done, someone will install this for you.

I finally got my confirmation email from the FSF, that my paperwork has
been processed.

Find attached the patch to implement the make dist target for Windows.

Thanks,
Christoph

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [email-masked]
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
# testament_sha1: 1bceda0ab603efcc57222ea2a7aadc6be15a1092
# timestamp: 2010-07-03 11:03:06 -0600
# base_revision_id: [email-masked]
# 
# Begin patch
=== modified file 'admin/admin.el'
--- admin/admin.el	2010-05-15 21:12:44 +0000
+++ admin/admin.el	2010-07-03 17:02:02 +0000
@@ -95,6 +95,9 @@
   (set-version-in-file root "lib-src/makefile.w32-in" version
 		       (rx (and "VERSION" (0+ space) "=" (0+ space)
 				(submatch (1+ (in "0-9."))))))
+  (set-version-in-file root "nt/makefile.w32-in" version
+		       (rx (and "VERSION" (0+ space) "=" (0+ space)
+				(submatch (1+ (in "0-9."))))))
   ;; nt/emacs.rc also contains the version number, but in an awkward
   ;; format. It must contain four components, separated by commas, and
   ;; in two places those commas are followed by space, in two other

=== modified file 'nt/INSTALL'
--- nt/INSTALL	2010-01-13 08:35:10 +0000
+++ nt/INSTALL	2010-04-03 17:01:17 +0000
@@ -403,6 +403,9 @@
   Removes the installed files in the bin subdirectory in addition to
   the files removed by make cleanall.
 
+  make dist
+  Builds Emacs from the available sources and pre-compiled lisp files.
+  Packages Emacs binaries as full distribution and barebin distribution.
 
   The following targets are intended only for use with the Bazaar sources.
 
@@ -425,7 +428,33 @@
   bootstrap to rebuild.  Occasionally it may be necessary to run this
   target after an update.
 
-
+* Creating binary distributions
+  
+  Binary distributions (full and barebin distributions) can be 
+  automatically built and packaged from source tarballs or a bzr
+  checkout. 
+  
+  When building Emacs binary distributions, the --distfiles argument
+  to configure.bat specifies files to be included in the bin directory
+  of the binary distributions. This is intended for libraries that are 
+  not built as part of Emacs, e.g. image libraries.
+  
+  For example, specifying 
+  
+	--distfiles D:\distfiles\libXpm.dll
+
+  results in libXpm.dll being copied from D:\distfiles to the 
+  bin directory before packaging starts.
+  
+  Multiple files can be specified using multiple --distfiles arguments:
+  
+	--distfiles D:\distfiles\libXpm.dll --distfiles C:\jpeglib\jpeg.dll
+    
+  For packaging the binary distributions, the 'dist' make target uses
+  7-Zip (http://www.7-zip.org), which must be installed and available
+  on the Windows Path.
+
+  
 * Trouble-shooting
 
   The main problems that are likely to be encountered when building

=== added file 'nt/README.W32'
--- nt/README.W32	1970-01-01 00:00:00 +0000
+++ nt/README.W32	2010-03-31 02:27:15 +0000
@@ -0,0 +1,264 @@
+Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
+See the end of the file for license conditions.
+
+			   Emacs for Windows
+
+  This README file describes how to set up and run a precompiled
+  version of GNU Emacs for Windows.  This distribution can be found on
+  the ftp.gnu.org server and its mirrors:
+
+	ftp://ftp.gnu.org/gnu/emacs/windows/
+
+  This server contains other distributions, including the full Emacs
+  source distribution and a barebin distribution which can be installed
+  over it, as well as older releases of Emacs for Windows.
+
+  Answers to frequently asked questions, and further information about
+  this port of GNU Emacs and related software packages can be found via
+  http:
+
+	http://www.gnu.org/software/emacs/windows/
+
+* Preliminaries
+
+  Along with this file should be six subdirectories (bin, etc, info,
+  lisp, leim, site-lisp).  If you have downloaded the barebin
+  distribution, then it will contain only the bin directory and the
+  built in documentation in etc/DOC-X, the rest of the subdirectories
+  are in the src distribution, which the barebin distribution is
+  designed to be used with.
+
+* Setting up Emacs
+
+  To install Emacs, simply unpack all the files into a directory of
+  your choice, but note that you might encounter minor problems if
+  there is a space anywhere in the directory name.  To complete the
+  installation process, you can optionally run the program addpm.exe
+  in the bin subdirectory.  This will put an icon for Emacs in the
+  Start Menu under "Start -> Programs -> Gnu Emacs".
+
+  Some users have reported that the Start Menu item is not created for
+  them.  If this happens, just create your own shortcut to runemacs.exe,
+  eg. by dragging it on to the desktop or the Start button.
+
+  Note that running addpm is now an optional step; Emacs is able to
+  locate all of its files without needing any information to be set in
+  the environment or the registry, although such settings will still
+  be obeyed if present.  This is convenient for running Emacs on a
+  machine which disallows registry changes, or on which software
+  should not be installed.  For instance, you can now run Emacs
+  directly from a CD or USB flash drive without copying or installing
+  anything on the machine itself.
+
+* Starting Emacs
+
+  To run Emacs, simply select Emacs from the Start Menu, or invoke
+  runemacs.exe directly from Explorer or from a command prompt.  This
+  will start Emacs in its default GUI mode, ready to use.  If you have
+  never used Emacs before, you should follow the tutorial at this
+  point (select Emacs Tutorial from the Help menu), since Emacs is
+  quite different from ordinary Windows applications in many respects.
+
+  If you want to use Emacs in tty or character mode within a command
+  window, you can start it by typing "emacs -nw" at the command prompt.
+  (Obviously, you need to ensure that the Emacs bin subdirectory is in
+  your PATH first, or specify the path to emacs.exe.)  The -nw
+  (non-windowed) mode of operation is most useful if you have a telnet
+  server on your machine, allowing you to run Emacs remotely.
+
+* EXE files included
+
+  Emacs comes with the following executable files in the bin directory.
+
+  + emacs.exe - The main Emacs executable.  As this is designed to run
+    as both a text-mode application (emacs -nw) and as a GUI application,
+    it will pop up a command prompt window if run directly from Explorer.
+
+  + runemacs.exe - A wrapper for running Emacs as a GUI application
+    without popping up a command prompt window.
+
+  + emacsclient.exe - A command-line client program that can
+    communicate with a running Emacs process.  See the `Emacs Server'
+    node of the Emacs manual.
+
+  + emacsclientw.exe - A version of emacsclient that does not open
+    a command-line window.
+
+  + addpm.exe - A basic installer that creates Start Menu icons for Emacs.
+    Running this is optional.
+
+  + cmdproxy.exe - Used internally by Emacs to work around problems with
+    the native shells in various versions of Windows.
+
+  + ctags.exe, etags.exe - Tools for generating tag files.  See the
+    `Tags' node of the Emacs manual.
+
+  + ebrowse.exe - A tool for generating C++ browse information.  See the
+    `Ebrowse' manual.
+
+  + ddeclient.exe - A tool for interacting with DDE servers.
+
+  + hexl.exe - A tool for converting files to hex dumps.  See the
+    `Editing Binary Files' node of the Emacs manual.
+
+  + movemail.exe - A helper application for safely moving mail from
+    a mail spool or POP server to a local user mailbox.  See the
+    `Movemail' node of the Emacs manual.
+
+  + digest-doc.exe, sorted-doc.exe - Tools for rebuilding the
+    built-in documentation.
+
+* Image support
+
+  Emacs has built in support for XBM and PPM/PGM/PBM images, and the
+  libXpm library is bundled, providing XPM support (required for color
+  toolbar icons and splash screen).  Source for libXpm should be available
+  on the same place as you got this binary distribution from.  The version
+  of libXpm bundled with this version of Emacs is 3.5.7, based on x.org's
+  libXpm library from X11R7.3.
+
+  Emacs can also support some other image formats with appropriate
+  libraries.  These libraries are all available as part of GTK, or from
+  gnuwin32.sourceforge.net.  Emacs will find them if the directory they
+  are installed in is on the PATH.
+
+      PNG: requires the PNG reference library 1.2 or later, which will
+      be named libpng13d.dll, libpng13.dll, libpng12d.dll, libpng12.dll
+      or libpng.dll.  LibPNG requires zlib, which should come from the same
+      source as you got libpng.
+
+      JPEG: requires the Independant JPEG Group's libjpeg 6b or later,
+      which will be called jpeg62.dll, libjpeg.dll, jpeg-62.dll or jpeg.dll.
+
+      TIFF: requires libTIFF 3.0 or later, which will be called libtiff3.dll
+      or libtiff.dll.
+
+      GIF: requires libungif or giflib 4.1 or later, which will be
+      called giflib4.dll, libungif4.dll or libungif.dll.
+
+   In addition, Emacs can be compiled to support SVG.  This precompiled
+   distribution has not been compiled that way, since the SVG library
+   or one or more of its extensive dependencies appear to be
+   unreliable under Windows.  See nt/INSTALL in the src distribution if
+   you wish to compile Emacs with SVG support.
+
+* Uninstalling Emacs
+
+  If you should need to uninstall Emacs, simply delete all the files
+  and subdirectories from the directory where it was unpacked (Emacs
+  does not install or update any files in system directories or
+  anywhere else).  If you ran the addpm.exe program to create the
+  registry entries and the Start menu icon, then you can remove the
+  registry entries using regedit.  All of the settings are written
+  under the Software\GNU\Emacs key in HKEY_LOCAL_MACHINE, or if you
+  didn't have administrator privileges when you installed, the same
+  key in HKEY_CURRENT_USER.  Just delete the whole Software\GNU\Emacs
+  key.
+
+  The Start menu entry can be removed by right-clicking on the Task bar
+  and selecting Properties, then using the Remove option on the Start
+  Menu Programs page.  (If you installed under an account with
+  administrator privileges, then you need to click the Advanced button
+  and look for the Gnu Emacs menu item under All Users.)
+
+* Troubleshooting
+
+  Unpacking the distributions
+
+  If you encounter trouble trying to run Emacs, there are a number of
+  possible causes.  Check the following for indications that the
+  distribution was not corrupted by the tools used to unpack it:
+
+    * Be sure to disable CR/LF translation or the executables will
+      be unusable.  Older versions of WinZipNT would enable this
+      translation by default.  If you are using WinZipNT, disable it.
+      (I don't have WinZipNT myself, and I do not know the specific
+      commands necessary to disable it.)
+
+    * Check that filenames were not truncated to 8.3.  For example,
+      there should be a file lisp\abbrevlist.elc; if this has been
+      truncated to abbrevli.elc, your distribution has been corrupted
+      while unpacking and Emacs will not start.
+
+  If you believe you have unpacked the distributions correctly and are
+  still encountering problems, see the section on Further Information
+  below.
+
+  Virus scanners
+
+  Some virus scanners interfere with Emacs' use of subprocesses.  If you
+  are unable to use subprocesses and you use Dr. Solomon's WinGuard or
+  McAfee's Vshield, turn off "Scan all files" (WinGuard) or "boot sector
+  scanning" (McAfee exclusion properties).
+
+* Further information
+
+  If you have access to the World Wide Web, I would recommend pointing
+  your favorite web browser to the following document (if you haven't
+  already):
+
+	http://www.gnu.org/software/emacs/windows/
+
+  This document serves as an FAQ and a source for further information
+  about the Windows port and related software packages.
+
+  In addition to the FAQ, there is a mailing list for discussing issues
+  related to the Windows port of Emacs.  For information about the
+  list, see this Web page:
+
+	http://lists.gnu.org/mailman/listinfo/help-emacs-windows
+
+  To ask questions on the mailing list, send email to
+  [email-masked].  (You don't need to subscribe for that.)
+  To subscribe to the list or unsubscribe from it, fill the form you
+  find at http://lists.gnu.org/mailman/listinfo/help-emacs-windows as
+  explained there.
+
+  Another valuable source of information and help which should not be
+  overlooked is the various Usenet news groups dedicated to Emacs.
+  These are particularly good for help with general issues which aren't
+  specific to the Windows port of Emacs.  The main news groups to use
+  for seeking help are:
+
+	gnu.emacs.help
+	comp.emacs
+
+  There are also fairly regular postings and announcements of new or
+  updated Emacs packages on this group:
+
+	gnu.emacs.sources
+
+* Reporting bugs
+
+  If you encounter a bug in this port of Emacs, we would like to hear
+  about it.  First check the FAQ on the web page above to see if the bug
+  is already known and if there are any workarounds.  Then check whether
+  the bug has something to do with code in your .emacs file, e.g. by
+  invoking Emacs with the "-Q" option.
+
+  If you decide that it is a bug in Emacs, use the built in bug
+  reporting facility to report it (from the menu; Help -> Send Bug Report).
+  If you have not yet configured Emacs for mail, then when you press
+  C-c C-c to send the report, it will ask you to paste the text of the
+  report into your mail client.  If the bug is related to subprocesses,
+  also specify which shell you are using (e.g., include the values of
+  `shell-file-name' and `explicit-shell-file-name' in your message).
+
+  Enjoy!
+
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

=== modified file 'nt/configure.bat'
--- nt/configure.bat	2010-01-13 08:35:10 +0000
+++ nt/configure.bat	2010-04-06 02:16:41 +0000
@@ -89,6 +89,8 @@
 set doldflags=
 set sep1=
 set sep2=
+set sep3=
+set distfiles=
 
 rem ----------------------------------------------------------------------
 rem   Handle arguments.
@@ -110,6 +112,7 @@
 if "%1" == "--without-tiff" goto withouttiff
 if "%1" == "--without-xpm" goto withoutxpm
 if "%1" == "--with-svg" goto withsvg
+if "%1" == "--distfiles" goto distfiles
 if "%1" == "" goto checkutils
 :usage
 echo Usage: configure [options]
@@ -129,6 +132,7 @@
 echo.   --without-tiff          do not use TIFF library even if it is installed
 echo.   --without-xpm           do not use XPM library even if it is installed
 echo.   --with-svg              use the RSVG library (experimental)
+echo.   --distfiles             path to files for make dist, e.g. libXpm.dll
 goto end
 rem ----------------------------------------------------------------------
 :setprefix
@@ -226,6 +230,16 @@
 goto again
 
 rem ----------------------------------------------------------------------
+
+:distfiles
+set HAVE_DISTFILES=1
+shift
+set distfiles=%distfiles%%sep3%%1
+set sep3= %nothing%
+shift
+goto again
+
+rem ----------------------------------------------------------------------
 rem    Check that necessary utilities (cp and rm) are present.
 :checkutils
 echo Checking for 'cp'...
@@ -513,6 +527,35 @@
 :svgDone
 rm -f junk.c junk.obj junk.err junk.out
 
+rem Any distfiles provided for building distribution? If no, we're done.
+if "(%HAVE_DISTFILES%)"=="()" goto :distFilesDone
+
+rem Any arguments to --distfiles specified? If no, we're done.
+if not "%distfiles%"=="" goto :checkDistFiles
+set distFilesOk=0
+echo No arguments specified for option --distfiles!
+goto distfilesDone
+
+:checkDistFiles
+echo Checking for distfiles...
+rem Check if all specified distfiles exist
+set fileNotFound=
+for %%d in (%distfiles%) do if not exist %%d set fileNotFound=%%d
+if not "%fileNotFound%"=="" goto distFilesNotFound
+
+set distFilesOK=1
+echo ...all distfiles found.
+goto :distFilesDone
+
+:distFilesNotFound
+set distFilesOk=0
+echo ...%fileNotFound% not found.
+set distfiles=
+goto :distfilesDone
+
+:distFilesDone
+set fileNotFound=
+
 rem ----------------------------------------------------------------------
 :genmakefiles
 echo Generating makefiles
@@ -532,6 +575,7 @@
 if (%profile%) == (Y) echo PROFILE=1 >>config.settings
 if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings
 if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settings
+if not "(%distfiles%)" == "()" echo DIST_FILES=%distfiles%>>config.settings
 rem We go thru docflags because usercflags could be "-DFOO=bar" -something
 rem and the if command cannot cope with this
 for %%v in (%usercflags%) do if not (%%v)==() set docflags=Y
@@ -633,12 +677,19 @@
  echo   Install libtiff development files or use --without-tiff
 
 :checkgif
-if not "(%HAVE_GIF%)" == "()" goto donelibchecks
-if (%gifsupport%) == (N) goto donelibchecks
+if not "(%HAVE_GIF%)" == "()" goto checkdistfiles
+if (%gifsupport%) == (N) goto checkdistfiles
  set libsOK=0
  echo GIF support is missing.
  echo   Install giflib or libungif development files or use --without-gif
 
+:checkdistfiles
+if "(%HAVE_DISTFILES%)" == "()" goto donelibchecks
+if (%distFilesOk%) == (1) goto donelibchecks
+echo.
+echo Files specified with option --distfiles could not be found.
+echo   Fix these issues before running make dist
+
 :donelibchecks
 if (%libsOK%) == (1) goto success
 echo.
@@ -670,6 +721,9 @@
 set doldflags=
 set mingwflag=
 set mf=
+set distfiles=
+set HAVE_DISTFILES=
+set distFilesOk=
 
 goto skipArchTag
    arch-tag: 300d20a4-1675-4e75-b615-7ce1a8c5376c

=== modified file 'nt/makefile.w32-in'
--- nt/makefile.w32-in	2010-01-13 08:35:10 +0000
+++ nt/makefile.w32-in	2010-04-07 17:02:07 +0000
@@ -23,6 +23,8 @@
 # FIXME: This file uses DOS EOLs.  Convert to Unix after 22.1 is out
 #        (and remove or replace this comment).
 
+VERSION		= 24.0.50
+
 TRES		= $(BLD)/emacs.res
 CLIENTRES	= $(BLD)/emacsclient.res
 
@@ -197,12 +199,15 @@
 #
 # Build and install emacs in INSTALL_DIR
 #
-install: all $(INSTALL_DIR)/bin install-other-dirs-$(MAKETYPE)
+.PHONY: install-bin install-shortcuts
+
+install: install-bin install-shortcuts
+
+install-bin: all $(INSTALL_DIR)/bin install-other-dirs-$(MAKETYPE)
 	- $(CP) $(BLD)/addpm.exe $(INSTALL_DIR)/bin
 	- $(CP) $(BLD)/ddeclient.exe $(INSTALL_DIR)/bin
 	- $(CP) $(BLD)/cmdproxy.exe $(INSTALL_DIR)/bin
 	- $(CP) $(BLD)/runemacs.exe $(INSTALL_DIR)/bin
-	- "$(INSTALL_DIR)/bin/addpm" -q
 	- $(DEL) ../same-dir.tst
 	- $(DEL) $(INSTALL_DIR)/same-dir.tst
 	echo SameDirTest > "$(INSTALL_DIR)/same-dir.tst"
@@ -238,6 +243,14 @@
 	$(MAKE) $(MFLAGS) $(XMFLAGS) -C ../lisp install
 	$(MAKE) $(MFLAGS) $(XMFLAGS) -C ../leim install
 
+install-shortcuts:
+	"$(INSTALL_DIR)/bin/addpm" -q
+
+dist: install-bin 
+	$(CP) $(DIST_FILES) $(INSTALL_DIR)/bin
+	$(CP) README.W32 $(INSTALL_DIR)
+	$(COMSPEC)$(ComSpec) /c $(ARGQUOTE)zipdist.bat $(INSTALL_DIR) $(VERSION)$(ARGQUOTE)
+
 force-info:
 # Note that doc/emacs/makefile knows how to
 # put the info files in $(infodir),

=== added file 'nt/zipdist.bat'
--- nt/zipdist.bat	1970-01-01 00:00:00 +0000
+++ nt/zipdist.bat	2010-04-01 01:40:58 +0000
@@ -0,0 +1,66 @@
+@echo off
+rem Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+rem   Free Software Foundation, Inc.
+
+rem Author: Christoph Scholtes cschol2112 at gmail.com
+
+rem This file is part of GNU Emacs.
+
+rem GNU Emacs is free software: you can redistribute it and/or modify
+rem it under the terms of the GNU General Public License as published by
+rem the Free Software Foundation, either version 3 of the License, or
+rem (at your option) any later version.
+
+rem GNU Emacs is distributed in the hope that it will be useful,
+rem but WITHOUT ANY WARRANTY; without even the implied warranty of
+rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+rem GNU General Public License for more details.
+
+rem You should have received a copy of the GNU General Public License
+rem along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.
+
+SETLOCAL
+rem arg 1: full path to Emacs root directory
+set ARG_PATH="%~f1"
+rem Path separator cannot be parsed correctly, substitute
+set ARG_PATH=%ARG_PATH:\=;%
+
+rem arg 2: Emacs version number
+set EMACS_VER=%2
+
+rem Parse out last directory from passed in full path (arg 1)
+for /f "tokens=* delims=;" %%G in (%ARG_PATH%) do call :PARSE_PATH %%G
+goto :EXIT
+
+:PARSE_PATH
+if "%1"=="" (
+  goto :ZIP_CHECK
+)
+set ROOT_DIR=%1
+SHIFT
+goto :PARSE_PATH
+
+rem Check, if 7zip is installed and available on path
+:ZIP_CHECK
+7z
+if %ERRORLEVEL% NEQ 0 goto :ZIP_ERROR
+goto ZIP_DIST
+
+:ZIP_ERROR
+echo.
+echo ERROR: Make sure 7zip is installed and available on the Windows Path!
+goto EXIT
+
+rem Build distributions
+:ZIP_DIST
+pushd ..\..
+rem Build and verify full distribution
+7z a -bd -tZIP -mx=9 -x!.bzrignore -x!.gitignore -xr!emacs.mdp -xr!*.pdb -xr!*.opt -xr!*~ -xr!CVS -xr!.arch-inventory emacs-%EMACS_VER%-bin-i386.zip %ROOT_DIR%/BUGS %ROOT_DIR%/COPYING %ROOT_DIR%/README %ROOT_DIR%/README.W32 %ROOT_DIR%/INSTALL %ROOT_DIR%/bin %ROOT_DIR%/etc %ROOT_DIR%/info %ROOT_DIR%/lisp %ROOT_DIR%/leim %ROOT_DIR%/site-lisp
+7z t emacs-%EMACS_VER%-bin-i386.zip
+rem Build and verify binary only distribution
+7z a -bd -tZIP -mx=9 emacs-%EMACS_VER%-barebin-i386.zip %ROOT_DIR%/README.W32 %ROOT_DIR%/bin %ROOT_DIR%/etc/DOC-X %ROOT_DIR%/COPYING
+7z t emacs-%EMACS_VER%-barebin-i386.zip
+popd
+goto EXIT
+
+:EXIT

# Begin bundle