Fix removing existing directories by chmod'ing them to be user-writeable.
/trunk/scripts/crosstool.sh | 21 10 11 0 ++++++++++-----------
/trunk/scripts/functions | 7 7 0 0 +++++++
2 files changed, 17 insertions(+), 11 deletions(-)
3 VERSION=$( cat .version )
6 # All absolutely required tools, one per line to ease diff.
7 # See function 'has_or_abort, below, for syntax
8 # - Hopefully, if gcc is present, then all associated tools will be
9 # - awk must be GNU awk
10 # - makeinfo for building docs, even if discarded later on
11 # - others obvious... :-/
13 # Format of a pattern to check for, one per line:
14 # pattern := tool_test OR pattern || tool_test
15 # tool_test := tool=regexp OR tool
16 # tool := basename of the tool OR absolute pathname to the tool
17 # regexp := valid grep(1) extended regular expression, $( tool --version)
18 # will be matched against this regexp.
20 # In case a pattern list is given (eg foo || bar || buz), then tests are performed
21 # from left to right, stopping at the first matching test (like the shell
22 # would parse 'foo || bar || buz' ).
25 # /bin/bash=^GNU bash, version 3\.
26 # will ensure that /bin/bash exists, and that $( /bin/bash --version )
27 # matches the regexp '^GNU bash, version 3\.'
28 # autoconf=(GNU Autoconf) || autoconf2.50
30 # - 'autoconf' is to be found in the PATH, and that $( autoconf --version )
31 # matches the regexp '(GNU Autoconf)' (which btw is the signature of
34 # - 'autoconf2.50' is to be found in the PATH
37 /bin/bash=^GNU bash, version 3\.
46 automake=\(GNU automake\) (1\.[[:digit:]]{2,}\.|[2-9][[:digit:]]*\.)
47 libtool=\(GNU libtool\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)
55 PREFIX_DEFAULT=/usr/local
66 # Simply print the error message, and exit. Obvious, he?
72 # A small function to test for existence of various tools
73 # Usage: has_or_abort test_pattern (see top of file, TOOLS_TO_CHECK, for
74 # complete pattern format)
77 tool_pattern="$( echo "${1}" |"${sed}" -r -e 's/ *\|\| */\n/g;' )"
80 for item in ${tool_pattern}; do
90 printf "Checking for '${tool}'... "
91 where=$( which "${tool}" 2>/dev/null )
92 if [ -z "${where}" ]; then
96 elif [ -n "${regexp}" ]; then
97 tool_version=$( ${tool} --version 2>&1 )
98 str=$( echo "${tool_version}" |"${grep}" -E "${regexp}" |head -n 1 )
99 if [ -z "${str}" ]; then
108 if [ -z "${where}" ]; then
109 for item in ${tool_pattern}; do
119 echo " could not find '${tool}' matching regexp '${regexp}'"
121 echo "Either you are missing entirely the needed tool,"
122 echo "or the version you have is tool old."
123 # FORCE can be set in the environment
124 [ -z "${FORCE}" ] && do_error "Bailing out..."
130 # Given an option string and the following argument,
131 # echoes the value of the option.
132 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
133 # If --var val => echoes val and returns non null, meaning second arg was used
137 echo "${1}" |cut -d '=' -f 2-
147 # The set_xxx functions will set the corresponding configuration variable
148 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
150 PREFIX="$( get_optval "$1" "$2" )"
154 BINDIR="$( get_optval "$1" "$2" )"
158 LIBDIR="$( get_optval "$1" "$2" )"
162 DOCDIR="$( get_optval "$1" "$2" )"
166 MANDIR="$( get_optval "$1" "$2" )"
169 # The set_contrib function is different in that it will work like the others,
170 # except in two cases:
171 # If all => replaces all with the list of all available contribs
172 # If list => just echoes the list of all available contribs, and instructs
173 # caller to quit immediately by setting do_quit to non null.
174 # (can't use the return code, see above).
176 opt_val="$( get_optval "$1" "$2" )"
180 CONTRIB_list="$( LC_ALL=C ls -1 contrib/*.patch.lzma \
181 |xargs -I {} basename {} .patch.lzma \
182 |"${sed}" -r -e ':a; /$/N; s/\n/,/; ta;' \
187 echo "Available contributions:"
188 LC_ALL=C ls -1 contrib/*.patch.lzma \
189 |xargs -I {} basename {} .patch.lzma \
190 |"${sed}" -r -e 's/^/ /;'
192 *) CONTRIB_list="${CONTRIB_list},${opt_val}";;
199 \`configure' configures crosstool-NG ${VERSION} to adapt to many kind of systems.
201 USAGE: ./configure [OPTION]...
203 Defaults for the options are specified in brackets.
206 -h, --help display this help and exit
208 Installation directories:
209 --prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
210 --local don't install, and use current directory
212 By default, \`make install' will install all the files in
213 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
214 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
215 for instance \`--prefix=\${HOME}'.
217 For better control, use the options below.
219 Fine tuning of the installation directories:
220 --bindir=DIR user executables [PREFIX/bin]
221 --libdir=DIR object code libraries [PREFIX/lib]
222 --docdir=DIR info documentation [PREFIX/share/doc]
223 --mandir=DIR man documentation [PREFIX/share/man]
226 --with-contrib=XXX Include externally contributed features found in the
227 contrib/ sub-directory. Set to a comma-separated list
228 of features. Use 'all' to use all contributions, and
229 'list' to see which are available.
233 #---------------------------------------------------------------------
234 # Some sanity checks, now
236 # We check for grep and sed manually, because it is used in has_or_abort
237 printf "Checking for 'grep'... "
238 grep="$( which grep 2>/dev/null )"
239 [ -z "${grep}" ] && do_error "not found"
241 printf "Checking whether '${grep}' supports -E... "
242 if echo 'foo' |"${grep}" -E 'foo' >/dev/null 2>&1; then
247 printf "Checking for 'sed'... "
248 sed="$( which sed 2>/dev/null )"
249 [ -z "${sed}" ] && do_error "not found"
252 # Check the existence of absolutely required tools
256 for tool in ${TOOLS_TO_CHECK}; do
257 has_or_abort "${tool}"
261 #---------------------------------------------------------------------
264 while [ $# -ne 0 ]; do
266 --prefix*) set_prefix "$1" "$2" && shift || shift 2;;
267 --bindir*) set_bindir "$1" "$2" && shift || shift 2;;
268 --libdir*) set_libdir "$1" "$2" && shift || shift 2;;
269 --docdir*) set_docdir "$1" "$2" && shift || shift 2;;
270 --mandir*) set_mandir "$1" "$2" && shift || shift 2;;
271 --local) LOCAL_set=1; shift;;
273 set_contrib "$1" "$2" && shift || shift 2
274 [ "${do_quit}" = "1" ] && exit 0
276 --help|-h) do_help; exit 0;;
282 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
284 # Special case when installing locally
285 if [ "${LOCAL_set}" = "1" ]; then
286 set_prefix "" "$( pwd )"
287 set_bindir "" "$( pwd )"
288 set_libdir "" "$( pwd )"
289 set_docdir "" "$( pwd )/docs"
290 set_mandir "" "$( pwd )/docs"
293 #---------------------------------------------------------------------
294 # Apply contributed code
296 # It's safer to change all ',' to spaces rather than setting IFS
297 CONTRIB_list="$( echo "${CONTRIB_list}" \
298 |"${sed}" -r -e 's/,+/ /g; s/ +/ /g; s/^ //g; s/ $//g;' \
300 if [ -n "${CONTRIB_list}" ]; then
302 printf "Applying contributed code: "
303 for c in ${CONTRIB_list}; do
305 if [ ! -f "contrib/${c}.patch.lzma" ]; then
306 do_error "Contribution '${c}' does not exist"
308 lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
313 #---------------------------------------------------------------------
314 # Compute the version string
316 # If this version is a svn snapshot, try to get the revision number
317 # If we can't get the revision number, use date
318 printf "Computing version string... "
321 REVISION="$( LC_ALL=C svnversion )"
322 case "${REVISION}" in
324 VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
326 URL="$( LC_ALL=C svn info 2>/dev/null \
330 ROOT="$( LC_ALL=C svn info 2>/dev/null \
331 |"${grep}" '^Repository Root: ' \
334 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
337 # Arrange to have no / in the directory name, no need to create an
338 # arbitrarily deep directory structure
339 VERSION="$( echo "${VERSION}" |"${sed}" -r -e 's|/+|_|g;' )"
344 #---------------------------------------------------------------------
345 # Compute and check install paths
347 # Now we have the version string, we can build up the paths
348 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
349 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
350 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
351 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
353 # Check that install PATHs are absolute
354 for p in BIN LIB DOC MAN; do
356 eval v='"${'"${var}"'}"'
359 *) do_error "'${var}' is not an absolute path: '${v}'"
363 #---------------------------------------------------------------------
366 printf "Building up Makefile... "
367 "${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g
368 s,@@LIBDIR@@,${LIBDIR},g
369 s,@@DOCDIR@@,${DOCDIR},g
370 s,@@MANDIR@@,${MANDIR},g
371 s,@@VERSION@@,${VERSION},g
373 s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile
378 crosstool-NG configured as follows:
384 CONTRIB='${CONTRIB_list}'