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\.
45 automake=\(GNU automake\) [[:digit:]]+\.[[:digit:]]{2,}|automake=\(GNU automake\) [2-9][[:digit:]]*\.
54 PREFIX_DEFAULT=/usr/local
67 # Simply print the error message, and exit. Obvious, he?
73 # A small function to test for existence of various tools
74 # Usage: has_or_abort test_pattern (see top of file, TOOLS_TO_CHECK, for
75 # complete pattern format)
89 printf "Checking for '${tool}'... "
90 where=$( which "${tool}" 2>/dev/null )
91 if [ -z "${where}" ]; then
96 if [ -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
100 echo "${where}: wrong version string: expecting regexp '${regexp}'"
110 [ -z "${where}" -a ${FORCE} -eq 0 ] && do_error "Bailing out..."
114 # Given an option string and the following argument,
115 # echoes the value of the option.
116 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
117 # If --var val => echoes val and returns non null, meaning second arg was used
121 echo "${1}" |cut -d '=' -f 2-
131 # The set_xxx functions will set the corresponding configuration variable
132 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
134 PREFIX="$( get_optval "$1" "$2" )"
138 BINDIR="$( get_optval "$1" "$2" )"
142 LIBDIR="$( get_optval "$1" "$2" )"
146 DOCDIR="$( get_optval "$1" "$2" )"
150 MANDIR="$( get_optval "$1" "$2" )"
153 # The set_contrib function is different in that it will work like the others,
154 # except in two cases:
155 # If all => replaces all with the list of all available contribs
156 # If list => just echoes the list of all available contribs, and instructs
157 # caller to quit immediately by setting do_quit to non null.
158 # (can't use the return code, see above).
160 opt_val="$( get_optval "$1" "$2" )"
164 CONTRIB_list="$( LC_ALL=C ls -1 contrib/*.patch.lzma \
165 |xargs -I {} basename {} .patch.lzma \
166 |sed -r -e ':a; /$/N; s/\n/,/; ta;' \
171 echo "Available contributions:"
172 LC_ALL=C ls -1 contrib/*.patch.lzma \
173 |xargs -I {} basename {} .patch.lzma \
176 *) CONTRIB_list="${CONTRIB_list},${opt_val}";;
183 \`configure' configures crosstool-NG ${VERSION} to adapt to many kind of systems.
185 USAGE: ./configure [OPTION]...
187 Defaults for the options are specified in brackets.
190 -h, --help display this help and exit
191 --force force ./configure to complete, even if one or more
192 tools were not found. Use at your own risk, only if
193 you know what you are doing!
195 Installation directories:
196 --prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
197 --local don't install, and use current directory
199 By default, \`make install' will install all the files in
200 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
201 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
202 for instance \`--prefix=\${HOME}'.
204 For better control, use the options below.
206 Fine tuning of the installation directories:
207 --bindir=DIR user executables [PREFIX/bin]
208 --libdir=DIR object code libraries [PREFIX/lib]
209 --docdir=DIR info documentation [PREFIX/share/doc]
210 --mandir=DIR man documentation [PREFIX/share/man]
213 --with-contrib=XXX Include externally contributed features found in the
214 contrib/ sub-directory. Set to a comma-separated list
215 of features. Use 'all' to use all contributions, and
216 'list' to see which are available.
220 #---------------------------------------------------------------------
223 while [ $# -ne 0 ]; do
225 --prefix*) set_prefix "$1" "$2" && shift || shift 2;;
226 --bindir*) set_bindir "$1" "$2" && shift || shift 2;;
227 --libdir*) set_libdir "$1" "$2" && shift || shift 2;;
228 --docdir*) set_docdir "$1" "$2" && shift || shift 2;;
229 --mandir*) set_mandir "$1" "$2" && shift || shift 2;;
230 --local) LOCAL_set=1; shift;;
231 --force) FORCE=1; shift;;
233 set_contrib "$1" "$2" && shift || shift 2
234 [ "${do_quit}" = "1" ] && exit 0
236 --help|-h) do_help; exit 0;;
242 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
244 # Special case when installing locally
245 if [ "${LOCAL_set}" = "1" ]; then
246 set_prefix "" "$( pwd )"
247 set_bindir "" "$( pwd )"
248 set_libdir "" "$( pwd )"
249 set_docdir "" "$( pwd )/docs"
250 set_mandir "" "$( pwd )/docs"
253 #---------------------------------------------------------------------
254 # Some sanity checks, now
256 # If this version is a svn snapshot, try to get the revision number
257 # If we can't get the revision number, use date
258 printf "Computing version string... "
261 REVISION="$( LC_ALL=C svnversion )"
262 case "${REVISION}" in
264 VERSION="${VERSION}_unknown@$( date +%Y%m%d.%H%M%S )";;
266 URL="$( LC_ALL=C svn info 2>/dev/null \
270 ROOT="$( LC_ALL=C svn info 2>/dev/null \
271 |egrep 'Repository Root: ' \
274 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
277 # Arrange to have no / in the directory name, no need to create an
278 # arbitrarily deep directory structure
279 VERSION="$( echo "${VERSION}" |sed -r -e 's|/+|_|g;' )"
284 # Now we have the version string, we can build up the paths
285 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
286 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
287 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
288 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
290 # Check that install PATHs are absolute
291 for p in BIN LIB DOC MAN; do
293 eval v='"${'"${var}"'}"'
296 *) do_error "'${var}' is not an absolute path: '${v}'"
300 # Check the existence of absolutely required tools
304 for tool in ${TOOLS_TO_CHECK}; do
305 has_or_abort "${tool}"
309 # It's safer to change all ',' to spaces rather than setting IFS
310 CONTRIB_list="$( echo "${CONTRIB_list}" \
311 |sed -r -e 's/,+/ /g; s/ +/ /g; s/^ //g; s/ $//g;' \
313 if [ -n "${CONTRIB_list}" ]; then
315 printf "Applying contributed code: "
316 for c in ${CONTRIB_list}; do
318 if [ ! -f "contrib/${c}.patch.lzma" ]; then
319 do_error "Contribution '${c}' does not exist"
321 lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
326 printf "Building up Makefile... "
327 sed -r -e "s,@@BINDIR@@,${BINDIR},g
328 s,@@LIBDIR@@,${LIBDIR},g
329 s,@@DOCDIR@@,${DOCDIR},g
330 s,@@MANDIR@@,${MANDIR},g
331 s,@@VERSION@@,${VERSION},g
333 s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile
338 crosstool-NG configured as follows:
344 CONTRIB='${CONTRIB_list}'