RE: Patch for Build under MSW + MSYS2
Vincent Belaïche <[email protected]>
| Newsgroups | gmane.emacs.bbdb.user |
|---|---|
| Message-ID | <AM5PR10MB0676E72539A8A7866DFE6E2984F90@AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM> |
Dear Roland, As recommended by you I resend the patch for compiling under MSW + MSYS2 on the new list. The patch computes the absolute path in a shell variable named abs_target in order to use maybe the cygpath -w command and get the real path. Automake CYGPATH_W expands to cygpath -w on MSWindows, and to echo otherwise. Here is the abs_target computation: abs_target=`$(CYGPATH_W) '$(subst ','\"'\"',$(abs_builddir)/$@)' | sed 's/\\([\\\"]\\)/\\\\\\1/g'`; \ The $subst Makefile construct is there in order to shell escape any ' in the absolute path to '"'"' which is the sole way to escape them in Bash. The sed command in the sequel is there to lisp escape any " or \ in the absolute path to \" or \\ respectively. I use backquotes instead of the $( ... ) bash construct for maximum portability, as the expense of this that all " and \ have to be shell escaped by \" and \\ respectively for backquote. The patch could be simpler if you consider that there aren't going to be any directory name in the absolute path containing a single quote, a double quote or a backslash (cygpath outputs forward slashes as filename separator). Although single quotes, double quotes and backslash are allowed filename characters under *nixy shells, autotools check for that and prevent building with such a dir name within root directory. So all the complication for handling ' " and \ is just overkill in this case. However, the reason why I opted out to writing it this way, is that I think that it is good to have some reference code for handling absolute paths in any cases of bash ports, so this code could be reused in another context than autotools as a reference bulletproof coding. Please feel free for brickbats. ;-) Vincent. PS: The simpler coding is just: abs_target=`$(CYGPATH_W) '$(abs_builddir)/$@'`; \ De : Vincent Belaïche <[email protected]> Envoyé : dimanche 20 août 2017 09:50 À : Roland Winkler Objet : RE: Patch for Build under MSW + MSYS2 >Dear Roland, >OK, I will do that when time allows, there is no hurry anyway with this patch. >Thank you for the feedback. > V. > >De : Roland Winkler <[email protected]> >Envoyé : dimanche 20 août 2017 06:36:08 >À : Vincent Belaïche >Objet : RE: Patch for Build under MSW + MSYS2 > >On Fri Aug 18 2017 Vincent Belaïche wrote: >> Dear Roland, >> > [...] > > >I suggest you subscribe to the new mailing list [email protected] >and resend your patch to the new list (preferably in a self-contained >new email that does not reference your old emails that were swallowed >by the system.) > >I have not yet looked at the patches you sent.
patch-abspath.diff
(application/octet-stream, 1.3 KB)
diff --git a/ChangeLog b/ChangeLog index cddbdbf..649493b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-02-02 Vincent Belaïche <[email protected]> + + * lisp/Makefile.am (abs_target): Make absolute path for + bbdb-loaddefs.el MSWindows aware. + 2018-01-06 Roland Winkler <[email protected]> * configure.ac: Increase version number to 3.2. diff --git a/lisp/Makefile.am b/lisp/Makefile.am index ba54709..26efc21 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -87,9 +87,13 @@ bbdb-loaddefs.el: $(dist_lisp_LISP) @echo "" >> $@; # Generated autoload-file must have an absolute path, # $srcdir can be relative. +## The equivalent command line with bash $(...) construct is the following: +## abs_target=$$($(CYGPATH_W) '$(subst ','"'"',$(abs_builddir)/$@)' | sed 's/\([\"]\)/\\\1/g'); +## However " and \ have to be \-escaped within a backquoted expression. + abs_target=`$(CYGPATH_W) '$(subst ','\"'\"',$(abs_builddir)/$@)' | sed 's/\\([\\\"]\\)/\\\\\\1/g'`; \ $(EMACS) --batch $(AM_ELCFLAGS) $(ELCFLAGS) \ --load autoload \ - --eval '(setq generated-autoload-file "'$(abs_builddir)/$@'")' \ + --eval '(setq generated-autoload-file "'"$$abs_target"'")' \ --eval '(setq make-backup-files nil)' \ --funcall batch-update-autoloads $(srcdir)