diff options
| author | Dani Moncayo | 2013-11-19 20:48:50 -0500 |
|---|---|---|
| committer | Glenn Morris | 2013-11-19 20:48:50 -0500 |
| commit | e976486e7f74d81b8fda468b6fc530a5a5dfd5ae (patch) | |
| tree | f39c4cf10a03eef023758bbd73216ccb75641398 | |
| parent | 826dc7b6b18e3608eac4c237316b9b43efdd8607 (diff) | |
| download | emacs-e976486e7f74d81b8fda468b6fc530a5a5dfd5ae.tar.gz emacs-e976486e7f74d81b8fda468b6fc530a5a5dfd5ae.zip | |
* Makefile.in (msys_to_w32, msys_lisppath_to_w32): Remove.
(msys_w32prefix_subst): Rename from msys_prefix_subst.
Operate on w32prefixpattern.
(epaths-force-w32): Use build-aux/msys-to-w32.
* build-aux/msys-to-w32: New file.
| -rw-r--r-- | ChangeLog | 8 | ||||
| -rw-r--r-- | Makefile.in | 38 | ||||
| -rw-r--r-- | build-aux/msys-to-w32 | 165 |
3 files changed, 185 insertions, 26 deletions
| @@ -1,3 +1,11 @@ | |||
| 1 | 2013-11-20 Dani Moncayo <dmoncayo@gmail.com> | ||
| 2 | |||
| 3 | * build-aux/msys-to-w32: New file. | ||
| 4 | * Makefile.in (msys_to_w32, msys_lisppath_to_w32): Remove. | ||
| 5 | (msys_w32prefix_subst): Rename from msys_prefix_subst. | ||
| 6 | Operate on w32prefixpattern. | ||
| 7 | (epaths-force-w32): Use build-aux/msys-to-w32. | ||
| 8 | |||
| 1 | 2013-11-17 Paul Eggert <eggert@cs.ucla.edu> | 9 | 2013-11-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 10 | ||
| 3 | * configure.ac (DEBUGGER_SEES_C_MACROS): Remove. | 11 | * configure.ac (DEBUGGER_SEES_C_MACROS): Remove. |
diff --git a/Makefile.in b/Makefile.in index e00eb790d66..4c3e261c195 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -317,22 +317,9 @@ epaths-force: FRC | |||
| 317 | -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') && \ | 317 | -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') && \ |
| 318 | ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h | 318 | ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h |
| 319 | 319 | ||
| 320 | # Convert MSYS-style /x/foo or Windows-style x:\foo file names | 320 | # Replace "${w32prefix}" with '%emacs_dir%' (which expands to install |
| 321 | # into x:/foo that Windows can grok. | ||
| 322 | msys_to_w32=sed -e 's,\\\\,/,g' -e 's,^/\([A-Za-z]\)/,\1:/,' | ||
| 323 | |||
| 324 | # Transform directory search path and its components. Original can | ||
| 325 | # be MSYS or Windows style. Set path separator to ";", directory | ||
| 326 | # separator to "/" and transform MSYS-style "/c/" to "c:/". | ||
| 327 | # Remove empty path components and escape semicolons. | ||
| 328 | msys_lisppath_to_w32=sed -e 's,\\\\,/,g' \ | ||
| 329 | -e 's,\(^\|[:;]\)\([A-Za-z]\):/,\1/\2/,g' \ | ||
| 330 | -e 's/:/;/g' -e 's,\(^\|;\)/\([A-Za-z]\)/,\1\2:/,g' \ | ||
| 331 | -e 's/;\+/;/g' -e 's/^;//' -e 's/;$$//' -e 's/;/\\\\;/g' | ||
| 332 | |||
| 333 | # Replace "${prefix}" with '%emacs_dir%' (which expands to install | ||
| 334 | # directory at runtime). | 321 | # directory at runtime). |
| 335 | msys_prefix_subst=sed -e 's!\(^\|;\)'"$${prefixpattern}"'\([;/]\|$$\)!\1%emacs_dir%\2!g' | 322 | msys_w32prefix_subst=sed -e 's!\(^\|;\)'"$${w32prefixpattern}"'\([;/]\|$$\)!\1%emacs_dir%\2!g' |
| 336 | 323 | ||
| 337 | # Quote Sed special characters (except backslash and newline) with | 324 | # Quote Sed special characters (except backslash and newline) with |
| 338 | # a double backslash. | 325 | # a double backslash. |
| @@ -340,22 +327,21 @@ msys_sed_sh_escape=sed -e 's/[];$$*.^[]/\\\\&/g' | |||
| 340 | 327 | ||
| 341 | # The w32 build needs a slightly different editing, and it uses | 328 | # The w32 build needs a slightly different editing, and it uses |
| 342 | # nt/epaths.nt as the template. | 329 | # nt/epaths.nt as the template. |
| 330 | # | ||
| 343 | # Use the value of ${locallisppath} supplied by `configure', | 331 | # Use the value of ${locallisppath} supplied by `configure', |
| 344 | # to support the --enable-locallisppath argument. | 332 | # to support the --enable-locallisppath argument. |
| 345 | # | 333 | # |
| 346 | # When building with MinGW inside the MSYS tree, 'pwd' produces directories | 334 | # In this case, the paths written to 'src/epaths.h' must be in native |
| 347 | # relative to the root of the MSYS tree, e.g. '/home/user/foo' instead of | 335 | # MS-Windows format (e.g. 'c:/foo/bar'), because temacs is a MinGW |
| 348 | # '/d/MSYS/home/user/foo'. If such a value of srcdir is written to | 336 | # program that doesn't support MSYS-style paths (e.g. '/c/foo/bar' or |
| 349 | # src/epaths.h, that causes temacs to fail, because, being a MinGW | 337 | # '/foo/bar'). |
| 350 | # program that knows nothing of MSYS root substitution, it cannot find | ||
| 351 | # the data directory. "pwd -W" produces Windows-style 'd:/foo/bar' | ||
| 352 | # absolute directory names, so we use it here to countermand that lossage. | ||
| 353 | epaths-force-w32: FRC | 338 | epaths-force-w32: FRC |
| 354 | @(w32srcdir=`cd "${srcdir}" && pwd -W` ; \ | 339 | @(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${srcdir}"`; \ |
| 355 | prefixpattern=`echo '${prefix}' | ${msys_to_w32} | ${msys_sed_sh_escape}` ; \ | 340 | w32prefix=`${srcdir}/build-aux/msys-to-w32 "${prefix}" N`; \ |
| 356 | locallisppath=`echo '${locallisppath}' | ${msys_lisppath_to_w32} | ${msys_prefix_subst}` ; \ | 341 | w32prefixpattern=`echo "${w32prefix}" | ${msys_sed_sh_escape}` ; \ |
| 342 | w32locallisppath=`${srcdir}/build-aux/msys-to-w32 "${locallisppath}" N ":" "\\;" | ${msys_w32prefix_subst}` ; \ | ||
| 357 | sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$ \ | 343 | sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$ \ |
| 358 | -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${locallisppath}"'";' \ | 344 | -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${w32locallisppath}"'";' \ |
| 359 | -e '/^.*#/s/@VER@/${version}/g' \ | 345 | -e '/^.*#/s/@VER@/${version}/g' \ |
| 360 | -e '/^.*#/s/@CFG@/${configuration}/g' \ | 346 | -e '/^.*#/s/@CFG@/${configuration}/g' \ |
| 361 | -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ | 347 | -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ |
diff --git a/build-aux/msys-to-w32 b/build-aux/msys-to-w32 new file mode 100644 index 00000000000..31149ea3036 --- /dev/null +++ b/build-aux/msys-to-w32 | |||
| @@ -0,0 +1,165 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Take a list of MSYS-compatible paths and convert them to native | ||
| 3 | # MS-Windows format. | ||
| 4 | # Status is zero if successful, nonzero otherwise. | ||
| 5 | |||
| 6 | # Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 7 | |||
| 8 | # This program is free software: you can redistribute it and/or modify | ||
| 9 | # it under the terms of the GNU General Public License as published by | ||
| 10 | # the Free Software Foundation, either version 3 of the License, or | ||
| 11 | # (at your option) any later version. | ||
| 12 | |||
| 13 | # This program is distributed in the hope that it will be useful, | ||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | # GNU General Public License for more details. | ||
| 17 | |||
| 18 | # You should have received a copy of the GNU General Public License | ||
| 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | # Take only the basename from the full pathname | ||
| 22 | me=${0//*\//} | ||
| 23 | |||
| 24 | usage="usage: ${me} PATHLIST [MUSTEXIST] [SEPARATOR [SEPARATOR2]]" | ||
| 25 | |||
| 26 | help="$usage | ||
| 27 | or: ${me} OPTION | ||
| 28 | |||
| 29 | Convert MSYS-compatible paths to MS-Windows native format. | ||
| 30 | |||
| 31 | PATHLIST should be a list of paths separated by SEPARATOR. This list | ||
| 32 | will be written to the standard output after performing the following | ||
| 33 | transformations: | ||
| 34 | 1. Discard empty paths. | ||
| 35 | 2. Replace backslashes with forward slashes. | ||
| 36 | 3. Replace two consecutive slashes with single ones. | ||
| 37 | 4. Translate to Windows-native format those paths that are not in such | ||
| 38 | format already. The translated paths will not end with a slash, | ||
| 39 | except for root directories (e.g. 'c:/' or 'c:/foo'). | ||
| 40 | 5. Escape with backslashes every ocurrence of SEPARATOR2 within the paths. | ||
| 41 | 6. Concatenate the translated paths with SEPARATOR2. | ||
| 42 | |||
| 43 | If MUSTEXIST is 'Y' or not supplied, then each path in PATHLIST must | ||
| 44 | exist. Otherwise, only some part of each path is required to exist | ||
| 45 | (the deepest existing subpath will be translated and the remainder | ||
| 46 | concatenated to the translation). | ||
| 47 | |||
| 48 | If SEPARATOR is not supplied, PATHLIST will be regarded as a single | ||
| 49 | path. | ||
| 50 | |||
| 51 | If SEPARATOR2 is not supplied, it will take the same value as | ||
| 52 | SEPARATOR. | ||
| 53 | |||
| 54 | Options: | ||
| 55 | --help display this help and exit | ||
| 56 | |||
| 57 | Report bugs to <bug-gnu-emacs@gnu.org>." | ||
| 58 | |||
| 59 | for arg | ||
| 60 | do | ||
| 61 | case $arg in | ||
| 62 | --help | --hel | --he | --h) | ||
| 63 | exec echo "$help" ;; | ||
| 64 | --) | ||
| 65 | shift | ||
| 66 | break ;; | ||
| 67 | -*) | ||
| 68 | echo "${me}: invalid option: $arg" >&2 | ||
| 69 | exit 1 ;; | ||
| 70 | *) | ||
| 71 | break ;; | ||
| 72 | esac | ||
| 73 | done | ||
| 74 | |||
| 75 | { test $# -ge 1 && test $# -le 4; } || | ||
| 76 | { echo "${me}: $usage" >&2; exit 1; } | ||
| 77 | |||
| 78 | # Arguments | ||
| 79 | pathlist="$1" | ||
| 80 | mustexist="${2:-Y}" | ||
| 81 | separator="$3" | ||
| 82 | separator2="${4:-${separator}}" | ||
| 83 | |||
| 84 | # Split pathlist into its path components | ||
| 85 | if test -n "$separator" | ||
| 86 | then | ||
| 87 | IFS=${separator} patharray=( $pathlist ) | ||
| 88 | else | ||
| 89 | patharray=( "$pathlist" ) | ||
| 90 | fi | ||
| 91 | |||
| 92 | w32pathlist="" | ||
| 93 | |||
| 94 | for p in "${patharray[@]}" | ||
| 95 | do | ||
| 96 | # Skip empty paths | ||
| 97 | test "$p" = "" && continue | ||
| 98 | |||
| 99 | # Replace '\' with '/' and '//' with '/' | ||
| 100 | p="${p//\\//}" | ||
| 101 | p="${p//\/\///}" | ||
| 102 | |||
| 103 | if test -d "$p" | ||
| 104 | then | ||
| 105 | # The path exists, so just translate it | ||
| 106 | w32p=`cd "$p" && pwd -W` | ||
| 107 | else | ||
| 108 | # The path does not exists. So, try to guess the | ||
| 109 | # Windows-native translation, by looking for the deepest | ||
| 110 | # existing directory in this path, and then translating the | ||
| 111 | # existing part and concatenating the remainder. | ||
| 112 | |||
| 113 | test "${mustexist}" = "Y" && | ||
| 114 | { echo "${me}: invalid path: $p" >&2; exit 1; } | ||
| 115 | |||
| 116 | p1=$p | ||
| 117 | IFS=/ pcomponents=( $p ) | ||
| 118 | |||
| 119 | for (( i=${#pcomponents[@]}-1 ; i>=0 ; i-- )) | ||
| 120 | do | ||
| 121 | |||
| 122 | if test "${pcomponents[i]}" = "" | ||
| 123 | then | ||
| 124 | # The path component is empty. This can only mean | ||
| 125 | # that the path starts with "/" and all components | ||
| 126 | # have been stripped out already. So in this case we | ||
| 127 | # want to test with the MSYS root directory | ||
| 128 | p1="/" | ||
| 129 | else | ||
| 130 | p1="${p1%/}" | ||
| 131 | p1="${p1%${pcomponents[i]}}" | ||
| 132 | fi | ||
| 133 | |||
| 134 | if test -d "${p1}" | ||
| 135 | then | ||
| 136 | |||
| 137 | # Existing path found | ||
| 138 | |||
| 139 | # Translate the existing part and concatenate the | ||
| 140 | # remainder (ensuring that only one slash is used in | ||
| 141 | # the join, and no trailing slash is left) | ||
| 142 | w32p1=`cd "${p1}" && pwd -W` | ||
| 143 | remainder="${p#${p1}}" | ||
| 144 | remainder="${remainder#/}" | ||
| 145 | remainder="${remainder%/}" | ||
| 146 | w32p="${w32p1%/}/${remainder}" | ||
| 147 | |||
| 148 | break | ||
| 149 | fi | ||
| 150 | |||
| 151 | done | ||
| 152 | |||
| 153 | # If no existing directory was found, error out | ||
| 154 | test -e "${p1}" || | ||
| 155 | { echo "${me}: invalid path: ${p}" >&2; exit 1; } | ||
| 156 | fi | ||
| 157 | |||
| 158 | # Concatenate the translated path to the translated pathlist | ||
| 159 | test "${w32pathlist}" = "" || w32pathlist="${w32pathlist}${separator2}" | ||
| 160 | w32pathlist="${w32pathlist}${w32p//${separator2}/\\${separator2}}" | ||
| 161 | |||
| 162 | done | ||
| 163 | |||
| 164 | # Write the translated pathlist to the standard output | ||
| 165 | printf "${w32pathlist}" | ||