unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ben Key <bkey76@gmail.com>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, Emacs-devel@gnu.org
Subject: Re: Supporting parameters that include the = character in configure.bat
Date: Thu, 14 Apr 2011 19:56:03 -0500	[thread overview]
Message-ID: <BANLkTimLEWHL7wELQkHT3DNXbsR8Ckseig@mail.gmail.com> (raw)
In-Reply-To: <BANLkTikM5C9DkEcsR8nPnQdhUwSUxBMTjg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1420 bytes --]

Hello,

I have attached to this message a patch that modifies the code in
configure.bat that parses the --cflags and --ldflags options to support
parameters that include the = character.  Note that this functionality
depends on command extensions.  Configure.bat now attempts to enable command
extensions and displays a warning message if they could not be
enabled.  If configure.bat
could not enable command extensions the old parsing code is used that does
not support parameters that include the = character.

Note that the technique I used requires that any --cflags or --ldflags
parameter that includes the = character be enclosed in quotes to prevent the
= character from being interpreted as a separator.  The quotes are striped
when the parameter is processed.  Note the the parameter does not need to be
enclosed in quotes if it does not include the = character.

This patch includes changes to the nt/INSTALL file provided by Eli
Zaretskii.

I tested these changes on Windows 2000, Windows XP, and Windows 7.  I also
tested in the case in which command extensions are disabled via the registry
on Windows XP.  Note that in the case in which command extensions are
disabled the setlocal command successfully enabled them.  I do not know of a
case in which configure.bat will fall back to the old parsing code (perhaps
Windows NT, I do not know because I do not have a PC running Windows NT to
use for testing).

[-- Attachment #1.2: Type: text/html, Size: 1664 bytes --]

[-- Attachment #2: emacs-nt-configure.patch --]
[-- Type: application/octet-stream, Size: 4482 bytes --]

=== modified file 'nt/INSTALL'
--- nt/INSTALL	2011-01-26 08:36:39 +0000
+++ nt/INSTALL	2011-04-14 17:34:05 +0000
@@ -220,13 +220,23 @@
   absolutely sure the produced binaries will never need to be run under
   a debugger.
 
-  Because of limitations of the stock Windows command shell, certain
-  characters (quotes, backslashes and equal signs) can be problematic
-  and should not be used in arguments to configure.  That means that
-  forward slashes must be used in paths passed to the compiler and
-  linker via the --cflags and --ldflags options, and that it is
-  currently not possible to pass a macro like -DFOO=BAR (though -DFOO
-  is perfectly valid).
+  Because of limitations of the stock Windows command shells, special
+  care is needed to pass some characters in the arguments of the
+  --cflags and --ldflags options.  Backslashes should not be used in
+  file names passed to the compiler and linker via these options.  Use
+  forward slashes instead.  If the arguments to these two options
+  include the `=' character, like when passing a -DFOO=bar preprocessor
+  option, the argument with the `=' character should be enclosed in
+  quotes, like this:
+
+    configure --cflags "-DFOO=bar"
+
+  Support for options that include the `=' character require "command
+  extensions" to be enabled.  (They are enabled by default, but your
+  system administrator could have changed that.  See "cmd /?" for
+  details.)  If command extensions are disabled, a warning message might
+  be displayed informing you that "using parameters that include the =
+  character by enclosing them in quotes will not be supported."
 
   N.B.  It is normal to see a few error messages output while configure
   is running, when gcc support is being tested.  These cannot be

=== modified file 'nt/configure.bat'
--- nt/configure.bat	2011-01-29 12:36:11 +0000
+++ nt/configure.bat	2011-04-14 17:35:15 +0000
@@ -75,6 +75,19 @@
 
 :start
 rem ----------------------------------------------------------------------
+rem   Attempt to enable command extensions.  Set use_extensions to 1 if
+rem   they are available and 0 if they are not available.
+set use_extensions=1
+setlocal ENABLEEXTENSIONS
+if "%CMDEXTVERSION%" == "" set use_extensions=0
+if "%use_extensions%" == "1" goto afterext
+
+echo. Command extensions are not available.  Using parameters that include the =
+echo. character by enclosing them in quotes will not be supported.
+
+:afterext
+
+rem ----------------------------------------------------------------------
 rem   Default settings.
 set prefix=
 set nodebug=N
@@ -136,6 +149,20 @@
 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
+if "%use_extensions%" == "0" goto end
+echo.
+echo. The cflags and ldflags arguments support parameters that include the =
+echo. character.  However, since the = character is normally treated as a
+echo. separator character you will need to enclose any parameter that includes
+echo. the = character in quotes.  For example, to include
+echo. -DSITELOAD_PURESIZE_EXTRA=100000 as one of the cflags you would run
+echo. configure.bat as follows:
+echo. configure.bat --cflags "-DSITELOAD_PURESIZE_EXTRA=100000"
+echo.
+echo. Note that this capability of processing parameters that include the =
+echo. character depends on command extensions.  This batch file attempts to
+echo. enable command extensions.  If command extensions cannot be enabled, a
+echo. warning message will be displayed.
 goto end
 
 rem ----------------------------------------------------------------------
@@ -198,6 +225,17 @@
 rem ----------------------------------------------------------------------
 
 :usercflags
+if "%use_extensions%" == "1" goto ucflagex
+goto ucflagne
+
+:ucflagex
+shift
+set usercflags=%usercflags%%sep1%%~1
+set sep1= %nothing%
+shift
+goto again
+
+:ucflagne
 shift
 set usercflags=%usercflags%%sep1%%1
 set sep1= %nothing%
@@ -207,6 +245,17 @@
 rem ----------------------------------------------------------------------
 
 :userldflags
+if "%use_extensions%" == "1" goto ulflagex
+goto ulflagne
+
+:ulflagex
+shift
+set userldflags=%userldflags%%sep2%%~1
+set sep2= %nothing%
+shift
+goto again
+
+:ulflagne
 shift
 set userldflags=%userldflags%%sep2%%1
 set sep2= %nothing%


  reply	other threads:[~2011-04-15  0:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10  7:51 Supporting parameters that include the = character in configure.bat Ben Key
2011-04-10  8:14 ` Eli Zaretskii
2011-04-10  8:46   ` Ben Key
2011-04-10  9:49     ` Eli Zaretskii
     [not found]       ` <BANLkTi=QekwZQLVSoMFE0sTO+RRGAGackQ@mail.gmail.com>
2011-04-10 16:36         ` Eli Zaretskii
2011-04-12  0:17           ` Ben Key
2011-04-12  2:41             ` Ben Key
2011-04-12  5:08               ` Eli Zaretskii
2011-04-13 23:17                 ` Ben Key
2011-04-14  5:11                   ` Eli Zaretskii
2011-04-14 10:38                     ` Juanma Barranquero
2011-04-15  0:56                       ` Ben Key [this message]
2011-04-15  9:45                         ` Eli Zaretskii
2011-04-12  2:48             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTimLEWHL7wELQkHT3DNXbsR8Ckseig@mail.gmail.com \
    --to=bkey76@gmail.com \
    --cc=Emacs-devel@gnu.org \
    --cc=eliz@gnu.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).