| | | | |
| Offset 0, 0 lines modified | Offset 1, 11437 lines modified |
| | 1 | #!·/usr/bin/env·sh |
| | 2 | ##·DO·NOT·EDIT·-·This·file·generated·from·./build-aux/ltmain.in |
| | 3 | ##···············by·inline-source·v2019-02-19.15 |
| | |
| | 4 | #·libtool·(GNU·libtool)·2.4.7.4-1ec8f-dirty |
| | 5 | #·Provide·generalized·library-building·support·services. |
| | 6 | #·Written·by·Gordon·Matzigkeit·<gord@gnu.ai.mit.edu>,·1996 |
| | |
| | 7 | #·Copyright·(C)·1996-2019,·2021-2022·Free·Software·Foundation,·Inc. |
| | 8 | #·This·is·free·software;·see·the·source·for·copying·conditions.··There·is·NO |
| | 9 | #·warranty;·not·even·for·MERCHANTABILITY·or·FITNESS·FOR·A·PARTICULAR·PURPOSE. |
| | |
| | 10 | #·GNU·Libtool·is·free·software;·you·can·redistribute·it·and/or·modify |
| | 11 | #·it·under·the·terms·of·the·GNU·General·Public·License·as·published·by |
| | 12 | #·the·Free·Software·Foundation;·either·version·2·of·the·License,·or |
| | 13 | #·(at·your·option)·any·later·version. |
| | 14 | # |
| | 15 | #·As·a·special·exception·to·the·GNU·General·Public·License, |
| | 16 | #·if·you·distribute·this·file·as·part·of·a·program·or·library·that |
| | 17 | #·is·built·using·GNU·Libtool,·you·may·include·this·file·under·the |
| | 18 | #·same·distribution·terms·that·you·use·for·the·rest·of·that·program. |
| | 19 | # |
| | 20 | #·GNU·Libtool·is·distributed·in·the·hope·that·it·will·be·useful,·but |
| | 21 | #·WITHOUT·ANY·WARRANTY;·without·even·the·implied·warranty·of |
| | 22 | #·MERCHANTABILITY·or·FITNESS·FOR·A·PARTICULAR·PURPOSE.··See·the·GNU |
| | 23 | #·General·Public·License·for·more·details. |
| | 24 | # |
| | 25 | #·You·should·have·received·a·copy·of·the·GNU·General·Public·License |
| | 26 | #·along·with·this·program.··If·not,·see·<http://www.gnu.org/licenses/>. |
| | |
| | |
| | 27 | PROGRAM=libtool |
| | 28 | PACKAGE=libtool |
| | 29 | VERSION=2.4.7.4-1ec8f-dirty |
| | 30 | package_revision=2.4.7.4 |
| | |
| | |
| | 31 | ##·------·## |
| | 32 | ##·Usage.·## |
| | 33 | ##·------·## |
| | |
| | 34 | #·Run·'./libtool·--help'·for·help·with·using·this·script·from·the |
| | 35 | #·command·line. |
| | |
| | |
| | 36 | ##·-------------------------------·## |
| | 37 | ##·User·overridable·command·paths.·## |
| | 38 | ##·-------------------------------·## |
| | |
| | 39 | #·After·configure·completes,·it·has·a·better·idea·of·some·of·the |
| | 40 | #·shell·tools·we·need·than·the·defaults·used·by·the·functions·shared |
| | 41 | #·with·bootstrap,·so·set·those·here·where·they·can·still·be·over- |
| | 42 | #·ridden·by·the·user,·but·otherwise·take·precedence. |
| | |
| | 43 | :·${AUTOCONF="autoconf"} |
| | 44 | :·${AUTOMAKE="automake"} |
| | |
| | |
| | 45 | ##·--------------------------·## |
| | 46 | ##·Source·external·libraries.·## |
| | 47 | ##·--------------------------·## |
| | |
| | 48 | #·Much·of·our·low-level·functionality·needs·to·be·sourced·from·external |
| | 49 | #·libraries,·which·are·installed·to·$pkgauxdir. |
| | |
| | 50 | #·Set·a·version·string·for·this·script. |
| | 51 | scriptversion=2019-02-19.15;·#·UTC |
| | |
| | 52 | #·General·shell·script·boiler·plate,·and·helper·functions. |
| | 53 | #·Written·by·Gary·V.·Vaughan,·2004 |
| | |
| | 54 | #·This·is·free·software.··There·is·NO·warranty;·not·even·for |
| | 55 | #·MERCHANTABILITY·or·FITNESS·FOR·A·PARTICULAR·PURPOSE. |
| | 56 | # |
| | 57 | #·Copyright·(C)·2004-2019,·2021·Bootstrap·Authors |
| | 58 | # |
| | 59 | #·This·file·is·dual·licensed·under·the·terms·of·the·MIT·license |
| | 60 | #·<https://opensource.org/license/MIT>,·and·GPL·version·2·or·later |
| | 61 | #·<http://www.gnu.org/licenses/gpl-2.0.html>.··You·must·apply·one·of |
| | 62 | #·these·licenses·when·using·or·redistributing·this·software·or·any·of |
| | 63 | #·the·files·within·it.··See·the·URLs·above,·or·the·file·`LICENSE` |
| | 64 | #·included·in·the·Bootstrap·distribution·for·the·full·license·texts. |
| | |
| | 65 | #·Please·report·bugs·or·propose·patches·to: |
| | 66 | #·<https://github.com/gnulib-modules/bootstrap/issues> |
| | |
| | |
| | 67 | ##·------·## |
| | 68 | ##·Usage.·## |
| | 69 | ##·------·## |
| | |
| | 70 | #·Evaluate·this·file·near·the·top·of·your·script·to·gain·access·to |
| | 71 | #·the·functions·and·variables·defined·here: |
| | 72 | # |
| | 73 | #···.·`echo·"$0"·|·${SED-sed}·'s|[^/]*$||'`/build-aux/funclib.sh |
| | 74 | # |
| | 75 | #·If·you·need·to·override·any·of·the·default·environment·variable |
| | 76 | #·settings,·do·that·before·evaluating·this·file. |
| | |
| | |
| | 77 | ##·--------------------·## |
| | 78 | ##·Shell·normalisation.·## |
| | 79 | ##·--------------------·## |
| | |
| | 80 | #·Some·shells·need·a·little·help·to·be·as·Bourne·compatible·as·possible. |
| | 81 | #·Before·doing·anything·else,·make·sure·all·that·help·has·been·provided! |
| | |
| | 82 | DUALCASE=1;·export·DUALCASE·#·for·MKS·sh |
| | 83 | if·test·-n·"${ZSH_VERSION+set}"·&&·(emulate·sh)·>/dev/null·2>&1;·then·: |
| | 84 | ··emulate·sh |
| | 85 | ··NULLCMD=: |
| | 86 | ··#·Pre-4.2·versions·of·Zsh·do·word·splitting·on·${1+"$@"},·which |
| | 87 | ··#·is·contrary·to·our·usage.··Disable·this·feature. |
| | 88 | ··alias·-g·'${1+"$@"}'='"$@"' |
| | 89 | ··setopt·NO_GLOB_SUBST |
| | 90 | else |
| | 91 | ··case·`(set·-o)·2>/dev/null`·in·*posix*)·set·-o·posix·;;·esac |
| | 92 | fi |
| | |
| | 93 | #·NLS·nuisances:·We·save·the·old·values·in·case·they·are·required·later. |
| | 94 | _G_user_locale= |
| | 95 | _G_safe_locale= |
| | 96 | for·_G_var·in·LANG·LANGUAGE·LC_ALL·LC_CTYPE·LC_COLLATE·LC_MESSAGES |
| | 97 | do |
| | 98 | ··eval·"if·test·set·=·\"\${$_G_var+set}\";·then |
| | 99 | ··········save_$_G_var=\$$_G_var |
| | 100 | ··········$_G_var=C |
| | 101 | » ··export·$_G_var |
| | 102 | » ··_G_user_locale=\"$_G_var=\\\$save_\$_G_var;·\$_G_user_locale\" |
| | 103 | » ··_G_safe_locale=\"$_G_var=C;·\$_G_safe_locale\" |
| | 104 | » fi" |
| | 105 | done |
| | 106 | #·These·NLS·vars·are·set·unconditionally·(bootstrap·issue·#24).··Unset·those |
| | 107 | #·in·case·the·environment·reset·is·needed·later·and·the·$save_*·variant·is·not |
| | 108 | #·defined·(see·the·code·above). |
| | 109 | LC_ALL=C |
| | 110 | LANGUAGE=C |
| | 111 | export·LANGUAGE·LC_ALL |
| | |
| | 112 | #·Make·sure·IFS·has·a·sensible·default |
| | 113 | sp='·' |
| | 114 | nl=' |
| | 115 | ' |
| | 116 | IFS="$sp» $nl" |
| | |
| | 117 | #·There·are·apparently·some·retarded·systems·that·use·';'·as·a·PATH·separator! |
| | 118 | if·test·"${PATH_SEPARATOR+set}"·!=·set;·then |
| | 119 | ··PATH_SEPARATOR=: |
| | 120 | ··(PATH='/bin;/bin';·FPATH=$PATH;·sh·-c·:)·>/dev/null·2>&1·&&·{ |
| | 121 | ····(PATH='/bin:/bin';·FPATH=$PATH;·sh·-c·:)·>/dev/null·2>&1·|| |
| | 122 | ······PATH_SEPARATOR=';' |
| | 123 | ··} |
| | 124 | fi |
| | |
| | |
| | 125 | #·func_unset·VAR |
| | 126 | #·-------------- |
| | 127 | #·Portably·unset·VAR. |
| | 128 | #·In·some·shells,·an·'unset·VAR'·statement·leaves·a·non-zero·return |
| | 129 | #·status·if·VAR·is·already·unset,·which·might·be·problematic·if·the |
| | 130 | #·statement·is·used·at·the·end·of·a·function·(thus·poisoning·its·return |
| | 131 | #·value)·or·when·'set·-e'·is·active·(causing·even·a·spurious·abort·of |
| | 132 | #·the·script·in·this·case). |
| | 133 | func_unset·() |
| | 134 | { |
| | 135 | ····{·eval·$1=;·(eval·unset·$1)·>/dev/null·2>&1·&&·eval·unset·$1·||·:·;·} |
| | 136 | } |
| | |
| | |
| | 137 | #·Make·sure·CDPATH·doesn't·cause·`cd`·commands·to·output·the·target·dir. |
| | 138 | func_unset·CDPATH |
| | |
| | 139 | #·Make·sure·${,E,F}GREP·behave·sanely. |
| | 140 | func_unset·GREP_OPTIONS |
| | |
| | |
| | 141 | ##·-------------------------·## |
| | 142 | ##·Locate·command·utilities.·## |
| | 143 | ##·-------------------------·## |
| | |
| | |
| | 144 | #·func_executable_p·FILE |
| | 145 | #·---------------------- |
| | 146 | #·Check·that·FILE·is·an·executable·regular·file. |
| | 147 | func_executable_p·() |
| | 148 | { |
| | 149 | ····test·-f·"$1"·&&·test·-x·"$1" |
| | 150 | } |
| | |
| | |
| | 151 | #·func_path_progs·PROGS_LIST·CHECK_FUNC·[PATH] |
| | 152 | #·-------------------------------------------- |
| | 153 | #·Search·for·either·a·program·that·responds·to·--version·with·output |
| | 154 | #·containing·"GNU",·or·else·returned·by·CHECK_FUNC·otherwise,·by |
| | 155 | #·trying·all·the·directories·in·PATH·with·each·of·the·elements·of |
| | 156 | #·PROGS_LIST. |
| | 157 | # |
| | 158 | #·CHECK_FUNC·should·accept·the·path·to·a·candidate·program,·and |
| | 159 | #·set·$func_check_prog_result·if·it·truncates·its·output·less·than |
| | 160 | #·$_G_path_prog_max·characters. |
| | 161 | func_path_progs·() |
| | 162 | { |
| | 163 | ····_G_progs_list=$1 |
| | 164 | ····_G_check_func=$2 |
| | 165 | ····_G_PATH=${3-"$PATH"} |
| | |
| | 166 | ····_G_path_prog_max=0 |
| | 167 | ····_G_path_prog_found=false |
| | 168 | ····_G_save_IFS=$IFS;·IFS=${PATH_SEPARATOR-:} |
| | 169 | ····for·_G_dir·in·$_G_PATH;·do |
| | 170 | ······IFS=$_G_save_IFS |
| | 171 | ······test·-z·"$_G_dir"·&&·_G_dir=. |
| | 172 | ······for·_G_prog_name·in·$_G_progs_list;·do |
| | 173 | ········for·_exeext·in·''·.EXE;·do |
| | 174 | ··········_G_path_prog=$_G_dir/$_G_prog_name$_exeext |
| | 175 | ··········func_executable_p·"$_G_path_prog"·||·continue |
| | 176 | ··········case·`"$_G_path_prog"·--version·2>&1`·in |
| | 177 | ············*GNU*)·func_path_progs_result=$_G_path_prog·_G_path_prog_found=:·;; |
| | 178 | ············*)·····$_G_check_func·$_G_path_prog |
| | 179 | » » ···func_path_progs_result=$func_check_prog_result |
| | 180 | » » ···;; |
| | 181 | ··········esac |
| | 182 | ··········$_G_path_prog_found·&&·break·3 |
| | 183 | ········done |
| | 184 | ······done |
| | 185 | ····done |
| | 186 | ····IFS=$_G_save_IFS |
| | 187 | ····test·-z·"$func_path_progs_result"·&&·{ |
| | 188 | ······echo·"no·acceptable·sed·could·be·found·in·\$PATH"·>&2 |
| | 189 | ······exit·1 |
| | 190 | ····} |
| | 191 | } |
| | |
| | |
| | 192 | #·We·want·to·be·able·to·use·the·functions·in·this·file·before·configure |
| | 193 | #·has·figured·out·where·the·best·binaries·are·kept,·which·means·we·have |
| | 194 | #·to·search·for·them·ourselves·-·except·when·the·results·are·already·set |
| | 195 | #·where·we·skip·the·searches. |
| | |
| | 196 | #·Unless·the·user·overrides·by·setting·SED,·search·the·path·for·either·GNU |
| | 197 | #·sed,·or·the·sed·that·truncates·its·output·the·least. |
| | 198 | test·-z·"$SED"·&&·{ |
| | 199 | ··_G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ |
| | 200 | ··for·_G_i·in·1·2·3·4·5·6·7;·do |
| | 201 | ····_G_sed_script=$_G_sed_script$nl$_G_sed_script |
| | 202 | ··done |
| | 203 | ··echo·"$_G_sed_script"·2>/dev/null·|·sed·99q·>conftest.sed |
| | 204 | ··_G_sed_script= |
| | |
| | 205 | ··func_check_prog_sed·() |
| | 206 | ··{ |
| | 207 | ····_G_path_prog=$1 |
| | |
| | 208 | ····_G_count=0 |
| | 209 | ····printf·0123456789·>conftest.in |
| | 210 | ····while·: |
| | 211 | ····do |
| | 212 | ······cat·conftest.in·conftest.in·>conftest.tmp |
| | 213 | ······mv·conftest.tmp·conftest.in |
| | 214 | ······cp·conftest.in·conftest.nl |
| | 215 | ······echo·''·>>·conftest.nl |
| | 216 | ······"$_G_path_prog"·-f·conftest.sed·<conftest.nl·>conftest.out·2>/dev/null·||·break |
| | 217 | ······diff·conftest.out·conftest.nl·>/dev/null·2>&1·||·break |
| | 218 | ······_G_count=`expr·$_G_count·+·1` |
| | 219 | ······if·test·"$_G_count"·-gt·"$_G_path_prog_max";·then |
| | 220 | ········#·Best·one·so·far,·save·it·but·keep·looking·for·a·better·one |
| | 221 | ········func_check_prog_result=$_G_path_prog |
| | 222 | ········_G_path_prog_max=$_G_count |
| | 223 | ······fi |
| | 224 | ······#·10*(2^10)·chars·as·input·seems·more·than·enough |
| | 225 | ······test·10·-lt·"$_G_count"·&&·break |
| | 226 | ····done |
| | 227 | ····rm·-f·conftest.in·conftest.tmp·conftest.nl·conftest.out |
| | 228 | ··} |
| | |
| | 229 | ··func_path_progs·"sed·gsed"·func_check_prog_sed·"$PATH:/usr/xpg4/bin" |
| | 230 | ··rm·-f·conftest.sed |
| | 231 | ··SED=$func_path_progs_result |
| | 232 | } |
| | |
| | |
| | 233 | #·Unless·the·user·overrides·by·setting·GREP,·search·the·path·for·either·GNU |
| | 234 | #·grep,·or·the·grep·that·truncates·its·output·the·least. |
| | 235 | test·-z·"$GREP"·&&·{ |
| | 236 | ··func_check_prog_grep·() |
| | 237 | ··{ |
| | 238 | ····_G_path_prog=$1 |
| | |
| | 239 | ····_G_count=0 |
| | 240 | ····_G_path_prog_max=0 |
| | 241 | ····printf·0123456789·>conftest.in |
| | 242 | ····while·: |
| | 243 | ····do |
| | 244 | ······cat·conftest.in·conftest.in·>conftest.tmp |
| | 245 | ······mv·conftest.tmp·conftest.in |
| | 246 | ······cp·conftest.in·conftest.nl |
| | 247 | ······echo·'GREP'·>>·conftest.nl |
| | 248 | ······"$_G_path_prog"·-e·'GREP$'·-e·'-(cannot·match)-'·<conftest.nl·>conftest.out·2>/dev/null·||·break |
| | 249 | ······diff·conftest.out·conftest.nl·>/dev/null·2>&1·||·break |
| | 250 | ······_G_count=`expr·$_G_count·+·1` |
| | 251 | ······if·test·"$_G_count"·-gt·"$_G_path_prog_max";·then |
| | 252 | ········#·Best·one·so·far,·save·it·but·keep·looking·for·a·better·one |
| | 253 | ········func_check_prog_result=$_G_path_prog |
| | 254 | ········_G_path_prog_max=$_G_count |
| | 255 | ······fi |
| | 256 | ······#·10*(2^10)·chars·as·input·seems·more·than·enough |
| | 257 | ······test·10·-lt·"$_G_count"·&&·break |
| | 258 | ····done |
| | 259 | ····rm·-f·conftest.in·conftest.tmp·conftest.nl·conftest.out |
| | 260 | ··} |
| | |
| | 261 | ··func_path_progs·"grep·ggrep"·func_check_prog_grep·"$PATH:/usr/xpg4/bin" |
| | 262 | ··GREP=$func_path_progs_result |
| | 263 | } |
| | |
| | |
| | 264 | ##·-------------------------------·## |
| | 265 | ##·User·overridable·command·paths.·## |
| | 266 | ##·-------------------------------·## |
| | |
| | 267 | #·All·uppercase·variable·names·are·used·for·environment·variables.··These |
| | 268 | #·variables·can·be·overridden·by·the·user·before·calling·a·script·that |
| | 269 | #·uses·them·if·a·suitable·command·of·that·name·is·not·already·available |
| | 270 | #·in·the·command·search·PATH. |
| | |
| | 271 | :·${CP="cp·-f"} |
| | 272 | :·${ECHO="printf·%s\n"} |
| | 273 | :·${EGREP="$GREP·-E"} |
| | 274 | :·${FGREP="$GREP·-F"} |
| | 275 | :·${LN_S="ln·-s"} |
| | 276 | :·${MAKE="make"} |
| | 277 | :·${MKDIR="mkdir"} |
| | 278 | :·${MV="mv·-f"} |
| | 279 | :·${RM="rm·-f"} |
| | 280 | :·${SHELL="${CONFIG_SHELL-/bin/sh}"} |
| | |
| | |
| | 281 | ##·--------------------·## |
| | 282 | ##·Useful·sed·snippets.·## |
| | 283 | ##·--------------------·## |
| | |
| | 284 | sed_dirname='s|/[^/]*$||' |
| | 285 | sed_basename='s|^.*/||' |
| | |
| | 286 | #·Sed·substitution·that·helps·us·do·robust·quoting.··It·backslashifies |
| | 287 | #·metacharacters·that·are·still·active·within·double-quoted·strings. |
| | 288 | sed_quote_subst='s|\([`"$\\]\)|\\\1|g' |
| | |
| | 289 | #·Same·as·above,·but·do·not·quote·variable·references. |
| | 290 | sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' |
| | |
| | 291 | #·Sed·substitution·that·turns·a·string·into·a·regex·matching·for·the |
| | 292 | #·string·literally. |
| | 293 | sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' |
| | |
| | 294 | #·Sed·substitution·that·converts·a·w32·file·name·or·path |
| | 295 | #·that·contains·forward·slashes,·into·one·that·contains |
| | 296 | #·(escaped)·backslashes.··A·very·naive·implementation. |
| | 297 | sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' |
| | |
| | 298 | #·Re-'\'·parameter·expansions·in·output·of·sed_double_quote_subst·that |
| | 299 | #·were·'\'-ed·in·input·to·the·same.··If·an·odd·number·of·'\'·preceded·a |
| | 300 | #·'$'·in·input·to·sed_double_quote_subst,·that·'$'·was·protected·from |
| | 301 | #·expansion.··Since·each·input·'\'·is·now·two·'\'s,·look·for·any·number |
| | 302 | #·of·runs·of·four·'\'s·followed·by·two·'\'s·and·then·a·'$'.··'\'·that·'$'. |
| | 303 | _G_bs='\\' |
| | 304 | _G_bs2='\\\\' |
| | 305 | _G_bs4='\\\\\\\\' |
| | 306 | _G_dollar='\$' |
| | 307 | sed_double_backslash="\ |
| | 308 | ··s/$_G_bs4/&\\ |
| | 309 | /g |
| | 310 | ··s/^$_G_bs2$_G_dollar/$_G_bs&/ |
| | 311 | ··s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g |
| | 312 | ··s/\n//g" |
| | |
| | 313 | #·require_check_ifs_backslash |
| | 314 | #·--------------------------- |
| | 315 | #·Check·if·we·can·use·backslash·as·IFS='\'·separator,·and·set |
| | 316 | #·$check_ifs_backshlash_broken·to·':'·or·'false'. |
| | 317 | require_check_ifs_backslash=func_require_check_ifs_backslash |
| | 318 | func_require_check_ifs_backslash·() |
| | 319 | { |
| | 320 | ··_G_save_IFS=$IFS |
| | 321 | ··IFS='\' |
| | 322 | ··_G_check_ifs_backshlash='a\\b' |
| | 323 | ··for·_G_i·in·$_G_check_ifs_backshlash |
| | 324 | ··do |
| | 325 | ··case·$_G_i·in |
| | 326 | ··a) |
| | 327 | ····check_ifs_backshlash_broken=false |
| | 328 | ····;; |
| | 329 | ··'') |
| | 330 | ····break |
| | 331 | ····;; |
| | 332 | ··*) |
| | 333 | ····check_ifs_backshlash_broken=: |
| | 334 | ····break |
| | 335 | ····;; |
| | 336 | ··esac |
| | 337 | ··done |
| | 338 | ··IFS=$_G_save_IFS |
| | 339 | ··require_check_ifs_backslash=: |
| | 340 | } |
| | |
| | |
| | 341 | ##·-----------------·## |
| | 342 | ##·Global·variables.·## |
| | 343 | ##·-----------------·## |
| | |
| | 344 | #·Except·for·the·global·variables·explicitly·listed·below,·the·following |
| | 345 | #·functions·in·the·'^func_'·namespace,·and·the·'^require_'·namespace |
| | 346 | #·variables·initialised·in·the·'Resource·management'·section,·sourcing |
| | 347 | #·this·file·will·not·pollute·your·global·namespace·with·anything |
| | 348 | #·else.·There's·no·portable·way·to·scope·variables·in·Bourne·shell |
| | 349 | #·though,·so·actually·running·these·functions·will·sometimes·place |
| | 350 | #·results·into·a·variable·named·after·the·function,·and·often·use |
| | 351 | #·temporary·variables·in·the·'^_G_'·namespace.·If·you·are·careful·to |
| | 352 | #·avoid·using·those·namespaces·casually·in·your·sourcing·script,·things |
| | 353 | #·should·continue·to·work·as·you·expect.·And,·of·course,·you·can·freely |
| | 354 | #·overwrite·any·of·the·functions·or·variables·defined·here·before |
| | 355 | #·calling·anything·to·customize·them. |
| | |
| | 356 | EXIT_SUCCESS=0 |
| | 357 | EXIT_FAILURE=1 |
| | 358 | EXIT_MISMATCH=63··#·$?·=·63·is·used·to·indicate·version·mismatch·to·missing. |
| | 359 | EXIT_SKIP=77» ··#·$?·=·77·is·used·to·indicate·a·skipped·test·to·automake. |
| | |
| | 360 | #·Allow·overriding,·eg·assuming·that·you·follow·the·convention·of |
| | 361 | #·putting·'$debug_cmd'·at·the·start·of·all·your·functions,·you·can·get |
| | 362 | #·bash·to·show·function·call·trace·with: |
| | 363 | # |
| | 364 | #····debug_cmd='eval·echo·"${FUNCNAME[0]}·$*"·>&2'·bash·your-script-name |
| | 365 | debug_cmd=${debug_cmd-":"} |
| | 366 | exit_cmd=: |
| | |
| | 367 | #·By·convention,·finish·your·script·with: |
| | 368 | # |
| | 369 | #····exit·$exit_status |
| | 370 | # |
| | 371 | #·so·that·you·can·set·exit_status·to·non-zero·if·you·want·to·indicate |
| | 372 | #·something·went·wrong·during·execution·without·actually·bailing·out·at |
| | 373 | #·the·point·of·failure. |
| | 374 | exit_status=$EXIT_SUCCESS |
| | |
| | 375 | #·Work·around·backward·compatibility·issue·on·IRIX·6.5.·On·IRIX·6.4+,·sh |
| | 376 | #·is·ksh·but·when·the·shell·is·invoked·as·"sh"·and·the·current·value·of |
| | 377 | #·the·_XPG·environment·variable·is·not·equal·to·1·(one),·the·special |
| | 378 | #·positional·parameter·$0,·within·a·function·call,·is·the·name·of·the |
| | 379 | #·function. |
| | 380 | progpath=$0 |
| | |
| | 381 | #·The·name·of·this·program. |
| | 382 | progname=`$ECHO·"$progpath"·|$SED·"$sed_basename"` |
| | |
| | 383 | #·Make·sure·we·have·an·absolute·progpath·for·reexecution: |
| | 384 | case·$progpath·in |
| | 385 | ··[\\/]*|[A-Za-z]:\\*)·;; |
| | 386 | ··*[\\/]*) |
| | 387 | ·····progdir=`$ECHO·"$progpath"·|$SED·"$sed_dirname"` |
| | 388 | ·····progdir=`cd·"$progdir"·&&·pwd` |
| | 389 | ·····progpath=$progdir/$progname |
| | 390 | ·····;; |
| | 391 | ··*) |
| | 392 | ·····_G_IFS=$IFS |
| | 393 | ·····IFS=${PATH_SEPARATOR-:} |
| | 394 | ·····for·progdir·in·$PATH;·do |
| | 395 | ·······IFS=$_G_IFS |
| | 396 | ·······test·-x·"$progdir/$progname"·&&·break |
| | 397 | ·····done |
| | 398 | ·····IFS=$_G_IFS |
| | 399 | ·····test·-n·"$progdir"·||·progdir=`pwd` |
| | 400 | ·····progpath=$progdir/$progname |
| | 401 | ·····;; |
| | 402 | esac |
| | |
| | |
| | 403 | ##·-----------------·## |
| | 404 | ##·Standard·options.·## |
| | 405 | ##·-----------------·## |
| | |
| | 406 | #·The·following·options·affect·the·operation·of·the·functions·defined |
| | 407 | #·below,·and·should·be·set·appropriately·depending·on·run-time·para- |
| | 408 | #·meters·passed·on·the·command·line. |
| | |
| | 409 | opt_dry_run=false |
| | 410 | opt_quiet=false |
| | 411 | opt_verbose=false |
| | |
| | 412 | #·Categories·'all'·and·'none'·are·always·available.··Append·any·others |
| | 413 | #·you·will·pass·as·the·first·argument·to·func_warning·from·your·own |
| | 414 | #·code. |
| | 415 | warning_categories= |
| | |
| | 416 | #·By·default,·display·warnings·according·to·'opt_warning_types'.··Set |
| | 417 | #·'warning_func'··to·':'·to·elide·all·warnings,·or·func_fatal_error·to |
| | 418 | #·treat·the·next·displayed·warning·as·a·fatal·error. |
| | 419 | warning_func=func_warn_and_continue |
| | |
| | 420 | #·Set·to·'all'·to·display·all·warnings,·'none'·to·suppress·all |
| | 421 | #·warnings,·or·a·space·delimited·list·of·some·subset·of |
| | 422 | #·'warning_categories'·to·display·only·the·listed·warnings. |
| | 423 | opt_warning_types=all |
| | |
| | |
| | 424 | ##·--------------------·## |
| | 425 | ##·Resource·management.·## |
| | 426 | ##·--------------------·## |
| | |
| | 427 | #·This·section·contains·definitions·for·functions·that·each·ensure·a |
| | 428 | #·particular·resource·(a·file,·or·a·non-empty·configuration·variable·for |
| | 429 | #·example)·is·available,·and·if·appropriate·to·extract·default·values |
| | 430 | #·from·pertinent·package·files.·Call·them·using·their·associated |
| | 431 | #·'require_*'·variable·to·ensure·that·they·are·executed,·at·most,·once. |
| | 432 | # |
| | 433 | #·It's·entirely·deliberate·that·calling·these·functions·can·set |
| | 434 | #·variables·that·don't·obey·the·namespace·limitations·obeyed·by·the·rest |
| | 435 | #·of·this·file,·in·order·that·that·they·be·as·useful·as·possible·to |
| | 436 | #·callers. |
| | |
| | |
| | 437 | #·require_term_colors |
| | 438 | #·------------------- |
| | 439 | #·Allow·display·of·bold·text·on·terminals·that·support·it. |
| | 440 | require_term_colors=func_require_term_colors |
| | 441 | func_require_term_colors·() |
| | 442 | { |
| | 443 | ····$debug_cmd |
| | |
| | 444 | ····test·-t·1·&&·{ |
| | 445 | ······#·COLORTERM·and·USE_ANSI_COLORS·environment·variables·take |
| | 446 | ······#·precedence,·because·most·terminfo·databases·neglect·to·describe |
| | 447 | ······#·whether·color·sequences·are·supported. |
| | 448 | ······test·-n·"${COLORTERM+set}"·&&·:·${USE_ANSI_COLORS="1"} |
| | |
| | 449 | ······if·test·1·=·"$USE_ANSI_COLORS";·then |
| | 450 | ········#·Standard·ANSI·escape·sequences |
| | 451 | ········tc_reset='\x1b[0m' |
| | 452 | ········tc_bold='\x1b[1m';···tc_standout='\x1b[7m' |
| | 453 | ········tc_red='\x1b[31m';···tc_green='\x1b[32m' |
| | 454 | ········tc_blue='\x1b[34m';··tc_cyan='\x1b[36m' |
| | 455 | ······else |
| | 456 | ········#·Otherwise·trust·the·terminfo·database·after·all. |
| | 457 | ········test·-n·"`tput·sgr0·2>/dev/null`"·&&·{ |
| | 458 | ··········tc_reset=`tput·sgr0` |
| | 459 | ··········test·-n·"`tput·bold·2>/dev/null`"·&&·tc_bold=`tput·bold` |
| | 460 | ··········tc_standout=$tc_bold |
| | 461 | ··········test·-n·"`tput·smso·2>/dev/null`"·&&·tc_standout=`tput·smso` |
| | 462 | ··········test·-n·"`tput·setaf·1·2>/dev/null`"·&&·tc_red=`tput·setaf·1` |
| | 463 | ··········test·-n·"`tput·setaf·2·2>/dev/null`"·&&·tc_green=`tput·setaf·2` |
| | 464 | ··········test·-n·"`tput·setaf·4·2>/dev/null`"·&&·tc_blue=`tput·setaf·4` |
| | 465 | ··········test·-n·"`tput·setaf·5·2>/dev/null`"·&&·tc_cyan=`tput·setaf·5` |
| | 466 | ········} |
| | 467 | ······fi |
| | 468 | ····} |
| | |
| | 469 | ····require_term_colors=: |
| | 470 | } |
| | |
| | |
| | 471 | ##·-----------------·## |
| | 472 | ##·Function·library.·## |
| | 473 | ##·-----------------·## |
| | |
| | 474 | #·This·section·contains·a·variety·of·useful·functions·to·call·in·your |
| | 475 | #·scripts.·Take·note·of·the·portable·wrappers·for·features·provided·by |
| | 476 | #·some·modern·shells,·which·will·fall·back·to·slower·equivalents·on |
| | 477 | #·less·featureful·shells. |
| | |
| | |
| | 478 | #·func_append·VAR·VALUE |
| | 479 | #·--------------------- |
| | 480 | #·Append·VALUE·onto·the·existing·contents·of·VAR. |
| | |
| | 481 | ··#·We·should·try·to·minimise·forks,·especially·on·Windows·where·they·are |
| | 482 | ··#·unreasonably·slow,·so·skip·the·feature·probes·when·bash·or·zsh·are |
| | 483 | ··#·being·used: |
| | 484 | ··if·test·set·=·"${BASH_VERSION+set}${ZSH_VERSION+set}";·then |
| | 485 | ····:·${_G_HAVE_ARITH_OP="yes"} |
| | 486 | ····:·${_G_HAVE_XSI_OPS="yes"} |
| | 487 | ····#·The·+=·operator·was·introduced·in·bash·3.1 |
| | 488 | ····case·$BASH_VERSION·in |
| | 489 | ······[12].*·|·3.0·|·3.0*)·;; |
| | 490 | ······*) |
| | 491 | ········:·${_G_HAVE_PLUSEQ_OP="yes"} |
| | 492 | ········;; |
| | 493 | ····esac |
| | 494 | ··fi |
| | |
| | 495 | ··#·_G_HAVE_PLUSEQ_OP |
| | 496 | ··#·Can·be·empty,·in·which·case·the·shell·is·probed,·"yes"·if·+=·is |
| | 497 | ··#·useable·or·anything·else·if·it·does·not·work. |
| | 498 | ··test·-z·"$_G_HAVE_PLUSEQ_OP"·\ |
| | 499 | ····&&·(eval·'x=a;·x+="·b";·test·"a·b"·=·"$x"')·2>/dev/null·\ |
| | 500 | ····&&·_G_HAVE_PLUSEQ_OP=yes |
| | |
| | 501 | if·test·yes·=·"$_G_HAVE_PLUSEQ_OP" |
| | 502 | then |
| | 503 | ··#·This·is·an·XSI·compatible·shell,·allowing·a·faster·implementation... |
| | 504 | ··eval·'func_append·() |
| | 505 | ··{ |
| | 506 | ····$debug_cmd |
| | |
| | 507 | ····eval·"$1+=\$2" |
| | 508 | ··}' |
| | 509 | else |
| | 510 | ··#·...otherwise·fall·back·to·using·expr,·which·is·often·a·shell·builtin. |
| | 511 | ··func_append·() |
| | 512 | ··{ |
| | 513 | ····$debug_cmd |
| | |
| | 514 | ····eval·"$1=\$$1\$2" |
| | 515 | ··} |
| | 516 | fi |
| | |
| | |
| | 517 | #·func_append_quoted·VAR·VALUE |
| | 518 | #·---------------------------- |
| | 519 | #·Quote·VALUE·and·append·to·the·end·of·shell·variable·VAR,·separated |
| | 520 | #·by·a·space. |
| | 521 | if·test·yes·=·"$_G_HAVE_PLUSEQ_OP";·then |
| | 522 | ··eval·'func_append_quoted·() |
| | 523 | ··{ |
| | 524 | ····$debug_cmd |
| | |
| | 525 | ····func_quote_arg·pretty·"$2" |
| | 526 | ····eval·"$1+=\\·\$func_quote_arg_result" |
| | 527 | ··}' |
| | 528 | else |
| | 529 | ··func_append_quoted·() |
| | 530 | ··{ |
| | 531 | ····$debug_cmd |
| | |
| | 532 | ····func_quote_arg·pretty·"$2" |
| | 533 | ····eval·"$1=\$$1\\·\$func_quote_arg_result" |
| | 534 | ··} |
| | 535 | fi |
| | |
| | |
| | 536 | #·func_append_uniq·VAR·VALUE |
| | 537 | #·-------------------------- |
| | 538 | #·Append·unique·VALUE·onto·the·existing·contents·of·VAR,·assuming |
| | 539 | #·entries·are·delimited·by·the·first·character·of·VALUE.··For·example: |
| | 540 | # |
| | 541 | #···func_append_uniq·options·"·--another-option·option-argument" |
| | 542 | # |
| | 543 | #·will·only·append·to·$options·if·"·--another-option·option-argument·" |
| | 544 | #·is·not·already·present·somewhere·in·$options·already·(note·spaces·at |
| | 545 | #·each·end·implied·by·leading·space·in·second·argument). |
| | 546 | func_append_uniq·() |
| | 547 | { |
| | 548 | ····$debug_cmd |
| | |
| | 549 | ····eval·_G_current_value='`$ECHO·$'$1'`' |
| | 550 | ····_G_delim=`expr·"$2"·:·'\(.\)'` |
| | |
| | 551 | ····case·$_G_delim$_G_current_value$_G_delim·in |
| | 552 | ······*"$2$_G_delim"*)·;; |
| | 553 | ······*)·func_append·"$@"·;; |
| | 554 | ····esac |
| | 555 | } |
| | |
| | |
| | 556 | #·func_arith·TERM... |
| | 557 | #·------------------ |
| | 558 | #·Set·func_arith_result·to·the·result·of·evaluating·TERMs. |
| | 559 | ··test·-z·"$_G_HAVE_ARITH_OP"·\ |
| | 560 | ····&&·(eval·'test·2·=·$((·1·+·1·))')·2>/dev/null·\ |
| | 561 | ····&&·_G_HAVE_ARITH_OP=yes |
| | |
| | 562 | if·test·yes·=·"$_G_HAVE_ARITH_OP";·then |
| | 563 | ··eval·'func_arith·() |
| | 564 | ··{ |
| | 565 | ····$debug_cmd |
| | |
| | 566 | ····func_arith_result=$((·$*·)) |
| | 567 | ··}' |
| | 568 | else |
| | 569 | ··func_arith·() |
| | 570 | ··{ |
| | 571 | ····$debug_cmd |
| | |
| | 572 | ····func_arith_result=`expr·"$@"` |
| | 573 | ··} |
| | 574 | fi |
| | |
| | |
| | 575 | #·func_basename·FILE |
| | 576 | #·------------------ |
| | 577 | #·Set·func_basename_result·to·FILE·with·everything·up·to·and·including |
| | 578 | #·the·last·/·stripped. |
| | 579 | if·test·yes·=·"$_G_HAVE_XSI_OPS";·then |
| | 580 | ··#·If·this·shell·supports·suffix·pattern·removal,·then·use·it·to·avoid |
| | 581 | ··#·forking.·Hide·the·definitions·single·quotes·in·case·the·shell·chokes |
| | 582 | ··#·on·unsupported·syntax... |
| | 583 | ··_b='func_basename_result=${1##*/}' |
| | 584 | ··_d='case·$1·in |
| | 585 | ········*/*)·func_dirname_result=${1%/*}$2·;; |
| | 586 | ········*··)·func_dirname_result=$3········;; |
| | 587 | ······esac' |
| | |
| | 588 | else |
| | 589 | ··#·...otherwise·fall·back·to·using·sed. |
| | 590 | ··_b='func_basename_result=`$ECHO·"$1"·|$SED·"$sed_basename"`' |
| | 591 | ··_d='func_dirname_result=`$ECHO·"$1"··|$SED·"$sed_dirname"` |
| | 592 | ······if·test·"X$func_dirname_result"·=·"X$1";·then |
| | 593 | ········func_dirname_result=$3 |
| | 594 | ······else |
| | 595 | ········func_append·func_dirname_result·"$2" |
| | 596 | ······fi' |
| | 597 | fi |
| | |
| | 598 | eval·'func_basename·() |
| | 599 | { |
| | 600 | ····$debug_cmd |
| | |
| | 601 | ····'"$_b"' |
| | 602 | }' |
| | |
| | |
| | 603 | #·func_dirname·FILE·APPEND·NONDIR_REPLACEMENT |
| | 604 | #·------------------------------------------- |
| | 605 | #·Compute·the·dirname·of·FILE.··If·nonempty,·add·APPEND·to·the·result, |
| | 606 | #·otherwise·set·result·to·NONDIR_REPLACEMENT. |
| | 607 | eval·'func_dirname·() |
| | 608 | { |
| | 609 | ····$debug_cmd |
| | |
| | 610 | ····'"$_d"' |
| | 611 | }' |
| | |
| | |
| | 612 | #·func_dirname_and_basename·FILE·APPEND·NONDIR_REPLACEMENT |
| | 613 | #·-------------------------------------------------------- |
| | 614 | #·Perform·func_basename·and·func_dirname·in·a·single·function |
| | 615 | #·call: |
| | 616 | #···dirname:··Compute·the·dirname·of·FILE.··If·nonempty, |
| | 617 | #·············add·APPEND·to·the·result,·otherwise·set·result |
| | 618 | #·············to·NONDIR_REPLACEMENT. |
| | 619 | #·············value·returned·in·"$func_dirname_result" |
| | 620 | #···basename:·Compute·filename·of·FILE. |
| | 621 | #·············value·retuned·in·"$func_basename_result" |
| | 622 | #·For·efficiency,·we·do·not·delegate·to·the·functions·above·but·instead |
| | 623 | #·duplicate·the·functionality·here. |
| | 624 | eval·'func_dirname_and_basename·() |
| | 625 | { |
| | 626 | ····$debug_cmd |
| | |
| | 627 | ····'"$_b"' |
| | 628 | ····'"$_d"' |
| | 629 | }' |
| | |
| | |
| | 630 | #·func_echo·ARG... |
| | 631 | #·---------------- |
| | 632 | #·Echo·program·name·prefixed·message. |
| | 633 | func_echo·() |
| | 634 | { |
| | 635 | ····$debug_cmd |
| | |
| | 636 | ····_G_message=$* |
| | |
| | 637 | ····func_echo_IFS=$IFS |
| | 638 | ····IFS=$nl |
| | 639 | ····for·_G_line·in·$_G_message;·do |
| | 640 | ······IFS=$func_echo_IFS |
| | 641 | ······$ECHO·"$progname:·$_G_line" |
| | 642 | ····done |
| | 643 | ····IFS=$func_echo_IFS |
| | 644 | } |
| | |
| | |
| | 645 | #·func_echo_all·ARG... |
| | 646 | #·-------------------- |
| | 647 | #·Invoke·$ECHO·with·all·args,·space-separated. |
| | 648 | func_echo_all·() |
| | 649 | { |
| | 650 | ····$ECHO·"$*" |
| | 651 | } |
| | |
| | |
| | 652 | #·func_echo_infix_1·INFIX·ARG... |
| | 653 | #·------------------------------ |
| | 654 | #·Echo·program·name,·followed·by·INFIX·on·the·first·line,·with·any |
| | 655 | #·additional·lines·not·showing·INFIX. |
| | 656 | func_echo_infix_1·() |
| | 657 | { |
| | 658 | ····$debug_cmd |
| | |
| | 659 | ····$require_term_colors |
| | |
| | 660 | ····_G_infix=$1;·shift |
| | 661 | ····_G_indent=$_G_infix |
| | 662 | ····_G_prefix="$progname:·$_G_infix:·" |
| | 663 | ····_G_message=$* |
| | |
| | 664 | ····#·Strip·color·escape·sequences·before·counting·printable·length |
| | 665 | ····for·_G_tc·in·"$tc_reset"·"$tc_bold"·"$tc_standout"·"$tc_red"·"$tc_green"·"$tc_blue"·"$tc_cyan" |
| | 666 | ····do |
| | 667 | ······test·-n·"$_G_tc"·&&·{ |
| | 668 | ········_G_esc_tc=`$ECHO·"$_G_tc"·|·$SED·"$sed_make_literal_regex"` |
| | 669 | ········_G_indent=`$ECHO·"$_G_indent"·|·$SED·"s|$_G_esc_tc||g"` |
| | 670 | ······} |
| | 671 | ····done |
| | 672 | ····_G_indent="$progname:·"`echo·"$_G_indent"·|·$SED·'s|.|·|g'`"··"·##·exclude·from·sc_prohibit_nested_quotes |
| | |
| | 673 | ····func_echo_infix_1_IFS=$IFS |
| | 674 | ····IFS=$nl |
| | 675 | ····for·_G_line·in·$_G_message;·do |
| | 676 | ······IFS=$func_echo_infix_1_IFS |
| | 677 | ······$ECHO·"$_G_prefix$tc_bold$_G_line$tc_reset"·>&2 |
| | 678 | ······_G_prefix=$_G_indent |
| | 679 | ····done |
| | 680 | ····IFS=$func_echo_infix_1_IFS |
| | 681 | } |
| | |
| | |
| | 682 | #·func_error·ARG... |
| | 683 | #·----------------- |
| | 684 | #·Echo·program·name·prefixed·message·to·standard·error. |
| | 685 | func_error·() |
| | 686 | { |
| | 687 | ····$debug_cmd |
| | |
| | 688 | ····$require_term_colors |
| | |
| | 689 | ····func_echo_infix_1·"··$tc_standout${tc_red}error$tc_reset"·"$*"·>&2 |
| | 690 | } |
| | |
| | |
| | 691 | #·func_fatal_error·ARG... |
| | 692 | #·----------------------- |
| | 693 | #·Echo·program·name·prefixed·message·to·standard·error,·and·exit. |
| | 694 | func_fatal_error·() |
| | 695 | { |
| | 696 | ····$debug_cmd |
| | |
| | 697 | ····func_error·"$*" |
| | 698 | ····exit·$EXIT_FAILURE |
| | 699 | } |
| | |
| | |
| | 700 | #·func_grep·EXPRESSION·FILENAME |
| | 701 | #·----------------------------- |
| | 702 | #·Check·whether·EXPRESSION·matches·any·line·of·FILENAME,·without·output. |
| | 703 | func_grep·() |
| | 704 | { |
| | 705 | ····$debug_cmd |
| | |
| | 706 | ····$GREP·"$1"·"$2"·>/dev/null·2>&1 |
| | 707 | } |
| | |
| | |
| | 708 | #·func_len·STRING |
| | 709 | #·--------------- |
| | 710 | #·Set·func_len_result·to·the·length·of·STRING.·STRING·may·not |
| | 711 | #·start·with·a·hyphen. |
| | 712 | ··test·-z·"$_G_HAVE_XSI_OPS"·\ |
| | 713 | ····&&·(eval·'x=a/b/c; |
| | 714 | ······test·5aa/bb/cc·=·"${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"')·2>/dev/null·\ |
| | 715 | ····&&·_G_HAVE_XSI_OPS=yes |
| | |
| | 716 | if·test·yes·=·"$_G_HAVE_XSI_OPS";·then |
| | 717 | ··eval·'func_len·() |
| | 718 | ··{ |
| | 719 | ····$debug_cmd |
| | |
| | 720 | ····func_len_result=${#1} |
| | 721 | ··}' |
| | 722 | else |
| | 723 | ··func_len·() |
| | 724 | ··{ |
| | 725 | ····$debug_cmd |
| | |
| | 726 | ····func_len_result=`expr·"$1"·:·".*"·2>/dev/null·||·echo·$max_cmd_len` |
| | 727 | ··} |
| | 728 | fi |
| | |
| | |
| | 729 | #·func_mkdir_p·DIRECTORY-PATH |
| | 730 | #·--------------------------- |
| | 731 | #·Make·sure·the·entire·path·to·DIRECTORY-PATH·is·available. |
| | 732 | func_mkdir_p·() |
| | 733 | { |
| | 734 | ····$debug_cmd |
| | |
| | 735 | ····_G_directory_path=$1 |
| | 736 | ····_G_dir_list= |
| | |
| | 737 | ····if·test·-n·"$_G_directory_path"·&&·test·:·!=·"$opt_dry_run";·then |
| | |
| | 738 | ······#·Protect·directory·names·starting·with·'-' |
| | 739 | ······case·$_G_directory_path·in |
| | 740 | ········-*)·_G_directory_path=./$_G_directory_path·;; |
| | 741 | ······esac |
| | |
| | 742 | ······#·While·some·portion·of·DIR·does·not·yet·exist... |
| | 743 | ······while·test·!·-d·"$_G_directory_path";·do |
| | 744 | ········#·...make·a·list·in·topmost·first·order.··Use·a·colon·delimited |
| | 745 | » #·list·incase·some·portion·of·path·contains·whitespace. |
| | 746 | ········_G_dir_list=$_G_directory_path:$_G_dir_list |
| | |
| | 747 | ········#·If·the·last·portion·added·has·no·slash·in·it,·the·list·is·done |
| | 748 | ········case·$_G_directory_path·in·*/*)·;;·*)·break·;;·esac |
| | |
| | 749 | ········#·...otherwise·throw·away·the·child·directory·and·loop |
| | 750 | ········_G_directory_path=`$ECHO·"$_G_directory_path"·|·$SED·-e·"$sed_dirname"` |
| | 751 | ······done |
| | 752 | ······_G_dir_list=`$ECHO·"$_G_dir_list"·|·$SED·'s|:*$||'` |
| | |
| | 753 | ······func_mkdir_p_IFS=$IFS;·IFS=: |
| | 754 | ······for·_G_dir·in·$_G_dir_list;·do |
| | 755 | » IFS=$func_mkdir_p_IFS |
| | 756 | ········#·mkdir·can·fail·with·a·'File·exist'·error·if·two·processes |
| | 757 | ········#·try·to·create·one·of·the·directories·concurrently.··Don't |
| | 758 | ········#·stop·in·that·case! |
| | 759 | ········$MKDIR·"$_G_dir"·2>/dev/null·||·: |
| | 760 | ······done |
| | 761 | ······IFS=$func_mkdir_p_IFS |
| | |
| | 762 | ······#·Bail·out·if·we·(or·some·other·process)·failed·to·create·a·directory. |
| | 763 | ······test·-d·"$_G_directory_path"·||·\ |
| | 764 | ········func_fatal_error·"Failed·to·create·'$1'" |
| | 765 | ····fi |
| | 766 | } |
| | |
| | |
| | 767 | #·func_mktempdir·[BASENAME] |
| | 768 | #·------------------------- |
| | 769 | #·Make·a·temporary·directory·that·won't·clash·with·other·running |
| | 770 | #·libtool·processes,·and·avoids·race·conditions·if·possible.··If |
| | 771 | #·given,·BASENAME·is·the·basename·for·that·directory. |
| | 772 | func_mktempdir·() |
| | 773 | { |
| | 774 | ····$debug_cmd |
| | |
| | 775 | ····_G_template=${TMPDIR-/tmp}/${1-$progname} |
| | |
| | 776 | ····if·test·:·=·"$opt_dry_run";·then |
| | 777 | ······#·Return·a·directory·name,·but·don't·create·it·in·dry-run·mode |
| | 778 | ······_G_tmpdir=$_G_template-$$ |
| | 779 | ····else |
| | |
| | 780 | ······#·If·mktemp·works,·use·that·first·and·foremost |
| | 781 | ······_G_tmpdir=`mktemp·-d·"$_G_template-XXXXXXXX"·2>/dev/null` |
| | |
| | 782 | ······if·test·!·-d·"$_G_tmpdir";·then |
| | 783 | ········#·Failing·that,·at·least·try·and·use·$RANDOM·to·avoid·a·race |
| | 784 | ········_G_tmpdir=$_G_template-${RANDOM-0}$$ |
| | |
| | 785 | ········func_mktempdir_umask=`umask` |
| | 786 | ········umask·0077 |
| | 787 | ········$MKDIR·"$_G_tmpdir" |
| | 788 | ········umask·$func_mktempdir_umask |
| | 789 | ······fi |
| | |
| | 790 | ······#·If·we're·not·in·dry-run·mode,·bomb·out·on·failure |
| | 791 | ······test·-d·"$_G_tmpdir"·||·\ |
| | 792 | ········func_fatal_error·"cannot·create·temporary·directory·'$_G_tmpdir'" |
| | 793 | ····fi |
| | |
| | 794 | ····$ECHO·"$_G_tmpdir" |
| | 795 | } |
| | |
| | |
| | 796 | #·func_normal_abspath·PATH |
| | 797 | #·------------------------ |
| | 798 | #·Remove·doubled-up·and·trailing·slashes,·"."·path·components, |
| | 799 | #·and·cancel·out·any·".."·path·components·in·PATH·after·making |
| | 800 | #·it·an·absolute·path. |
| | 801 | func_normal_abspath·() |
| | 802 | { |
| | 803 | ····$debug_cmd |
| | |
| | 804 | ····#·These·SED·scripts·presuppose·an·absolute·path·with·a·trailing·slash. |
| | 805 | ····_G_pathcar='s|^/\([^/]*\).*$|\1|' |
| | 806 | ····_G_pathcdr='s|^/[^/]*||' |
| | 807 | ····_G_removedotparts=':dotsl |
| | 808 | » » s|/\./|/|g |
| | 809 | » » t·dotsl |
| | 810 | » » s|/\.$|/|' |
| | 811 | ····_G_collapseslashes='s|/\{1,\}|/|g' |
| | 812 | ····_G_finalslash='s|/*$|/|' |
| | |
| | 813 | ····#·Start·from·root·dir·and·reassemble·the·path. |
| | 814 | ····func_normal_abspath_result= |
| | 815 | ····func_normal_abspath_tpath=$1 |
| | 816 | ····func_normal_abspath_altnamespace= |
| | 817 | ····case·$func_normal_abspath_tpath·in |
| | 818 | ······"") |
| | 819 | ········#·Empty·path,·that·just·means·$cwd. |
| | 820 | ········func_stripname·''·'/'·"`pwd`" |
| | 821 | ········func_normal_abspath_result=$func_stripname_result |
| | 822 | ········return |
| | 823 | ········;; |
| | 824 | ······#·The·next·three·entries·are·used·to·spot·a·run·of·precisely |
| | 825 | ······#·two·leading·slashes·without·using·negated·character·classes; |
| | 826 | ······#·we·take·advantage·of·case's·first-match·behaviour. |
| | 827 | ······///*) |
| | 828 | ········#·Unusual·form·of·absolute·path,·do·nothing. |
| | 829 | ········;; |
| | 830 | ······//*) |
| | 831 | ········#·Not·necessarily·an·ordinary·path;·POSIX·reserves·leading·'//' |
| | 832 | ········#·and·for·example·Cygwin·uses·it·to·access·remote·file·shares |
| | 833 | ········#·over·CIFS/SMB,·so·we·conserve·a·leading·double·slash·if·found. |
| | 834 | ········func_normal_abspath_altnamespace=/ |
| | 835 | ········;; |
| | 836 | ······/*) |
| | 837 | ········#·Absolute·path,·do·nothing. |
| | 838 | ········;; |
| | 839 | ······*) |
| | 840 | ········#·Relative·path,·prepend·$cwd. |
| | 841 | ········func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath |
| | 842 | ········;; |
| | 843 | ····esac |
| | |
| | 844 | ····#·Cancel·out·all·the·simple·stuff·to·save·iterations.··We·also·want |
| | 845 | ····#·the·path·to·end·with·a·slash·for·ease·of·parsing,·so·make·sure |
| | 846 | ····#·there·is·one·(and·only·one)·here. |
| | 847 | ····func_normal_abspath_tpath=`$ECHO·"$func_normal_abspath_tpath"·|·$SED·\ |
| | 848 | ··········-e·"$_G_removedotparts"·-e·"$_G_collapseslashes"·-e·"$_G_finalslash"` |
| | 849 | ····while·:;·do |
| | 850 | ······#·Processed·it·all·yet? |
|
Max diff block lines reached; -1/344628 bytes (-0.00%) of diff not shown.
|