unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch make configure.bat support --cflags and --ldflags options that include quotes
@ 2011-04-29  0:00 Ben Key
  2011-04-29  7:30 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Key @ 2011-04-29  0:00 UTC (permalink / raw)
  To: Emacs-devel


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

Hello,

I am working on a patch that will configure.bat support --cflags and
--ldflags options that include quotes.  For example this patch makes it
possible to configure Emacs as follows

configure.bat --without-png --without-jpeg --without-gif --without-tiff
 --without-xpm --prefix=C:\emacs-24-test
 --cflags=-I"C:/Program Files/GnuTLS-2.10.1/include"
 --ldflags=-L"C:/Program Files/GnuTLS-2.10.1/lib" --lib gnutls --lib gcrypt

to build Emacs with GnuTLS support when the GnuTLS files are installed
in ""C:/Program
Files/GnuTLS-2.10.1."

This patch makes use of some more command extensions magic, as documented at
http://stackoverflow.com/questions/562038/escaping-double-quotes-in-batch-script.
I made the changes in such a way that configure.bat falls back to the old
behavior if command extensions are not available.

The patch is as follows (it is also attached to this message).

<patch>
=== modified file 'nt/configure.bat'
--- nt/configure.bat    2011-04-25 01:29:31 +0000
+++ nt/configure.bat    2011-04-28 23:31:18 +0000
@@ -97,8 +97,10 @@
 set nocygwin=N
 set COMPILER=
 set usercflags=
+set fusercflags=
 set docflags=
 set userldflags=
+set fuserldflags=
 set extrauserlibs=
 set doldflags=
 set doextralibs=
@@ -238,6 +240,7 @@
 :ucflagex
 shift
 set usercflags=%usercflags%%sep1%%~1
+set fusercflags=%usercflags:"=\"%
 set sep1= %nothing%
 shift
 goto again
@@ -245,6 +248,7 @@
 :ucflagne
 shift
 set usercflags=%usercflags%%sep1%%1
+set fusercflags=%usercflags%
 set sep1= %nothing%
 shift
 goto again
@@ -266,6 +270,7 @@
 :ulflagex
 shift
 set userldflags=%userldflags%%sep2%%~1
+set fuserldflags=%userldflags:"=\"%
 set sep2= %nothing%
 shift
 goto again
@@ -273,6 +278,7 @@
 :ulflagne
 shift
 set userldflags=%userldflags%%sep2%%1
+set fuserldflags=%userldflags%
 set sep2= %nothing%
 shift
 goto again
@@ -437,7 +443,7 @@
 :chkuser
 rm -f junk.o
 echo int main (int argc, char *argv[]) {>junk.c
-echo char *usercflags = "%usercflags%";>>junk.c
+echo char *usercflags = "%fusercflags%";>>junk.c
 echo }>>junk.c
 echo gcc -Werror -c junk.c >>config.log
 gcc -Werror -c junk.c >>config.log 2>&1
@@ -745,8 +751,8 @@
 echo /* Start of settings from configure.bat.  */ >>config.tmp
 rem   We write USER_CFLAGS and USER_LDFLAGS starting with a space to
simplify
 rem   processing of compiler options in
w32.c:get_emacs_configuration_options
-if (%docflags%) == (Y) echo #define USER_CFLAGS " %usercflags%">>config.tmp
-if (%doldflags%) == (Y) echo #define USER_LDFLAGS "
%userldflags%">>config.tmp
+if (%docflags%) == (Y) echo #define USER_CFLAGS "
%fusercflags%">>config.tmp
+if (%doldflags%) == (Y) echo #define USER_LDFLAGS "
%fuserldflags%">>config.tmp
 if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp
 if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp
 if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp

</patch>

This patch is just a logical extension of an earlier change I made to allow
support for --cflags and --ldflags options in the form of -DFOO=BAR as long
as they are enclosed in quotes.

I will commit this patch, along with an appropriate update to nt/INSTALL in
the next day or so unless someone objects.

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

[-- Attachment #2: configure.bat.patch --]
[-- Type: application/octet-stream, Size: 2030 bytes --]

=== modified file 'nt/configure.bat'
--- nt/configure.bat	2011-04-25 01:29:31 +0000
+++ nt/configure.bat	2011-04-28 23:31:18 +0000
@@ -97,8 +97,10 @@
 set nocygwin=N
 set COMPILER=
 set usercflags=
+set fusercflags=
 set docflags=
 set userldflags=
+set fuserldflags=
 set extrauserlibs=
 set doldflags=
 set doextralibs=
@@ -238,6 +240,7 @@
 :ucflagex
 shift
 set usercflags=%usercflags%%sep1%%~1
+set fusercflags=%usercflags:"=\"%
 set sep1= %nothing%
 shift
 goto again
@@ -245,6 +248,7 @@
 :ucflagne
 shift
 set usercflags=%usercflags%%sep1%%1
+set fusercflags=%usercflags%
 set sep1= %nothing%
 shift
 goto again
@@ -266,6 +270,7 @@
 :ulflagex
 shift
 set userldflags=%userldflags%%sep2%%~1
+set fuserldflags=%userldflags:"=\"%
 set sep2= %nothing%
 shift
 goto again
@@ -273,6 +278,7 @@
 :ulflagne
 shift
 set userldflags=%userldflags%%sep2%%1
+set fuserldflags=%userldflags%
 set sep2= %nothing%
 shift
 goto again
@@ -437,7 +443,7 @@
 :chkuser
 rm -f junk.o
 echo int main (int argc, char *argv[]) {>junk.c
-echo char *usercflags = "%usercflags%";>>junk.c
+echo char *usercflags = "%fusercflags%";>>junk.c
 echo }>>junk.c
 echo gcc -Werror -c junk.c >>config.log
 gcc -Werror -c junk.c >>config.log 2>&1
@@ -745,8 +751,8 @@
 echo /* Start of settings from configure.bat.  */ >>config.tmp
 rem   We write USER_CFLAGS and USER_LDFLAGS starting with a space to simplify
 rem   processing of compiler options in w32.c:get_emacs_configuration_options
-if (%docflags%) == (Y) echo #define USER_CFLAGS " %usercflags%">>config.tmp
-if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %userldflags%">>config.tmp
+if (%docflags%) == (Y) echo #define USER_CFLAGS " %fusercflags%">>config.tmp
+if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %fuserldflags%">>config.tmp
 if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp
 if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp
 if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch make configure.bat support --cflags and --ldflags options that include quotes
  2011-04-29  0:00 Patch make configure.bat support --cflags and --ldflags options that include quotes Ben Key
@ 2011-04-29  7:30 ` Eli Zaretskii
  2011-04-29 15:11   ` Ben Key
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2011-04-29  7:30 UTC (permalink / raw)
  To: Ben Key; +Cc: Emacs-devel

> From: Ben Key <bkey76@gmail.com>
> Date: Thu, 28 Apr 2011 19:00:51 -0500
> 
> I am working on a patch that will configure.bat support --cflags and
> --ldflags options that include quotes.  For example this patch makes it
> possible to configure Emacs as follows
> 
> configure.bat --without-png --without-jpeg --without-gif --without-tiff
>  --without-xpm --prefix=C:\emacs-24-test
>  --cflags=-I"C:/Program Files/GnuTLS-2.10.1/include"
>  --ldflags=-L"C:/Program Files/GnuTLS-2.10.1/lib" --lib gnutls --lib gcrypt
> 
> to build Emacs with GnuTLS support when the GnuTLS files are installed
> in ""C:/Program Files/GnuTLS-2.10.1."

Thanks.

> I made the changes in such a way that configure.bat falls back to the old
> behavior if command extensions are not available.

Maybe I'm missing something, but where is the fallback, exactly?  If
command extensions are not available, then what will be the value of
fusercflags after this line:

 +set fusercflags=%usercflags:"=\"%

and how will be that value handled by the rest of the batch file?  All
I see is that you use that value to append a line to config.h, like
this:

 +if (%docflags%) == (Y) echo #define USER_CFLAGS " %fusercflags%">>config.tmp

What am I missing?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch make configure.bat support --cflags and --ldflags options that include quotes
  2011-04-29  7:30 ` Eli Zaretskii
@ 2011-04-29 15:11   ` Ben Key
  2011-04-29 17:11     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Key @ 2011-04-29 15:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs-devel

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

Eli Zaretskii wrote:

> Maybe I'm missing something, but where is the fallback, exactly?

The code that you refrenced is simply not called in the fallback case, due
to the following code

:usercflags
if "%use_extensions%" == "1" goto ucflagex
goto ucflagne

The code you referred to is in the ucflagex case, but, if command extensions
are not enabled, the ucflagne case is used.  In the ucflagne case there are
the following lines.

set usercflags=%usercflags%%sep1%%1
set fusercflags=%usercflags%

The first of these lines sets usercflags without attempting to use the
command extensions magic that strips quotes and thus providing support for
options in the form of -DFOO=BAR as long as they are enclosed in quotes and
the second line sets fusercflags so that it simply contains the value of
usercflags

The line latter in the file that you referred to,
if (%docflags%) == (Y) echo #define USER_CFLAGS " %fusercflags%">>config.tmp
, uses only the fusercflags variable which is fine.  This is because of the
fact that, even if command extensions are not enabled, the fusercflags
variable will be set to the appropriate value.  The fusercflags variable will
have the same value as the usercflags variable if command extensions are not
available and will be equal to the usercflags variable with all the quotes
escaped by the backslash character if command extensions are available.

[-- Attachment #2: Type: text/html, Size: 1796 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch make configure.bat support --cflags and --ldflags options that include quotes
  2011-04-29 15:11   ` Ben Key
@ 2011-04-29 17:11     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2011-04-29 17:11 UTC (permalink / raw)
  To: Ben Key; +Cc: Emacs-devel

> From: Ben Key <bkey76@gmail.com>
> Date: Fri, 29 Apr 2011 10:11:47 -0500
> Cc: Emacs-devel@gnu.org
> 
> The code that you refrenced is simply not called in the fallback case, due
> to the following code
> 
> :usercflags
> if "%use_extensions%" == "1" goto ucflagex
> goto ucflagne
> 
> The code you referred to is in the ucflagex case, but, if command extensions
> are not enabled, the ucflagne case is used.  In the ucflagne case there are
> the following lines.
> 
> set usercflags=%usercflags%%sep1%%1
> set fusercflags=%usercflags%

Ah, okay.  In that case, these changes are fine with me.  Thanks.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-29 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-29  0:00 Patch make configure.bat support --cflags and --ldflags options that include quotes Ben Key
2011-04-29  7:30 ` Eli Zaretskii
2011-04-29 15:11   ` Ben Key
2011-04-29 17:11     ` Eli Zaretskii

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).