Merge the static and shared core gcc builds.
/trunk/scripts/build/cc_gcc.sh | 195 64 131 0 ++++++++++++++++--------------------------------
1 file changed, 64 insertions(+), 131 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... :-/
28 PREFIX_DEFAULT=/usr/local
41 # Simply print the error message, and exit. Obvious, he?
47 # A small function to test for existence of various tools
48 # Usage: has_or_abort foobar
49 # -> foobar must exist in PATH
50 # Usage: has_or_abort foobar/string
51 # -> foobar must exist in PATH, and $(foobar --version) must contain 'string'
53 tool=$(echo "${1}/" |cut -d / -f 1)
54 regexp=$(echo "${1}/" |cut -d / -f 2)
55 printf "Checking for '${tool}'... "
56 where=$(which "${tool}" 2>/dev/null || true)
57 if [ -z "${where}" ]; then
59 [ ${FORCE} -eq 0 ] && do_error " Bailing out..."
63 if [ -n "${regexp}" ]; then
64 str=$(${tool} --version 2>&1 |egrep "${regexp}" |head -n 1)
65 if [ -z "${str}" ]; then
66 printf " failed: '${tool} --version' does not match regexp '${regexp}'."
67 [ ${FORCE} -eq 0 ] && do_error " Bailing out..."
75 # Given an option string and the following argument,
76 # echoes the value of the option.
77 # If --var=val => echoes val and returns 0, meaning second arg was not consumed
78 # If --var val => echoes val and returns non null, meaning second arg was used
83 echo "${1}" |cut -d '=' -f 2-
94 # The set_xxx functions will set the corresponding configuration variable
95 # They return 0 if second arg was not consumed, and non-zero if it was consumed.
97 PREFIX=$(get_optval "$1" "$2")
102 BINDIR=$(get_optval "$1" "$2")
107 LIBDIR=$(get_optval "$1" "$2")
112 DOCDIR=$(get_optval "$1" "$2")
117 MANDIR=$(get_optval "$1" "$2")
121 # The set_contrib function is different in that it will work like the others,
122 # except in two cases:
123 # If all => replaces all with the list of all available contribs
124 # If list => just echoes the list of all available contribs, and instructs
125 # caller to quit immediately by setting do_quit to non null.
126 # (can't use the return code, see above).
128 opt_val=$(get_optval "$1" "$2")
132 CONTRIB_list=$(LC_ALL=C ls -1 contrib/*.patch.lzma \
133 |xargs -I {} basename {} .patch.lzma \
134 |sed -r -e ':a; /$/N; s/\n/,/; ta;'
139 echo "Available contributions:"
140 LC_ALL=C ls -1 contrib/*.patch.lzma \
141 |xargs -I {} basename {} .patch.lzma \
144 *) CONTRIB_list="${CONTRIB_list},${opt_val}";;
151 \`configure' configures crosstool-NG ${VERSION} to adapt to many kind of systems.
153 USAGE: ./configure [OPTION]...
155 Defaults for the options are specified in brackets.
158 -h, --help display this help and exit
159 --force force ./configure to complete, even if one or more
160 tools were not found. Use at your own risk, only if
161 you know what you are doing!
163 Installation directories:
164 --prefix=PREFIX install files in PREFIX [${PREFIX_DEFAULT}]
165 --local don't install, and use current directory
167 By default, \`make install' will install all the files in
168 \`${PREFIX_DEFAULT}/bin', \`${PREFIX_DEFAULT}/lib' etc. You can specify
169 an installation prefix other than \`${PREFIX_DEFAULT}' using \`--prefix',
170 for instance \`--prefix=\${HOME}'.
172 For better control, use the options below.
174 Fine tuning of the installation directories:
175 --bindir=DIR user executables [PREFIX/bin]
176 --libdir=DIR object code libraries [PREFIX/lib]
177 --docdir=DIR info documentation [PREFIX/share/doc]
178 --mandir=DIR man documentation [PREFIX/share/man]
181 --with-contrib=XXX Include externally contributed features found in the
182 contrib/ sub-directory. Set to a comma-separated list
183 of features. Use 'all' to use all contributions, and
184 'list' to see which are available.
188 #---------------------------------------------------------------------
191 while [ $# -ne 0 ]; do
193 --prefix*) set_prefix "$1" "$2" && shift || shift 2;;
194 --bindir*) set_bindir "$1" "$2" && shift || shift 2;;
195 --libdir*) set_libdir "$1" "$2" && shift || shift 2;;
196 --docdir*) set_docdir "$1" "$2" && shift || shift 2;;
197 --mandir*) set_mandir "$1" "$2" && shift || shift 2;;
198 --local) LOCAL_set=1; shift;;
199 --force) FORCE=1; shift;;
201 set_contrib "$1" "$2" && shift || shift 2
202 [ "${do_quit}" = "1" ] && exit 0
204 --help|-h) do_help; exit 0;;
210 [ -z "${PREFIX}" ] && set_prefix "" "${PREFIX_DEFAULT}"
212 # Special case when installing locally
213 if [ "${LOCAL_set}" = "1" ]; then
217 set_docdir "" $(pwd)/docs
218 set_mandir "" $(pwd)/docs
221 #---------------------------------------------------------------------
222 # Some sanity checks, now
224 # If this version is a svn snapshot, try to get the revision number
225 # If we can't get the revision number, use date
226 printf "Computing version string... "
229 REVISION=$(LC_ALL=C svnversion)
230 case "${REVISION}" in
232 VERSION="${VERSION}unknown@$(date +%Y%m%d.%H%M%S)";;
234 URL=$(LC_ALL=C svn info 2>/dev/null |egrep 'URL: ' |cut -d ' ' -f 2-)
235 ROOT=$(LC_ALL=C svn info 2>/dev/null |egrep 'Repository Root: ' |cut -d ' ' -f 3-)
236 VERSION="${VERSION}${URL#${ROOT}}@${REVISION}"
239 # Arrange to have no / in the directory name, no need to create an
240 # arbitrarily deep directory structure
241 VERSION=$(echo "${VERSION}" |sed -r -e 's|/+|_|g;')
246 # Now we have the version string, we can build up the paths
247 [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin"
248 [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib/ct-ng-${VERSION}"
249 [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc/ct-ng-${VERSION}"
250 [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man/man1"
252 # Check bash is present, and at least version 3.0
253 printf "Checking '/bin/bash' is at least bash-3.0... "
254 [ -x /bin/bash ] || do_error "bash 3.0 or above was not found in '/bin/bash'"
255 bash_version=$(/bin/bash -c 'echo ${BASH_VERSION}')
256 bash_major=$(/bin/bash -c 'echo ${BASH_VERSINFO[0]}')
257 [ ${bash_major} -ge 3 ] || do_error "bash 3.0 or above is needed ('/bin/bash' is '${bash_version}')"
258 echo "${bash_version}"
260 # Check the existence of absolutely required tools
261 for tool in ${TOOLS_TO_CHECK}; do
262 has_or_abort "${tool}"
265 # It's safer to change all ',' to spaces rather than setting IFS
266 CONTRIB_list=$(echo "${CONTRIB_list}" |sed -r -e 's/,+/ /g;')
267 if [ -n "${CONTRIB_list}" ]; then
269 printf "Applying contributed code: "
270 for c in ${CONTRIB_list}; do
272 if [ ! -f "contrib/${c}.patch.lzma" ]; then
273 do_error "Contribution '${c}' does not exist"
275 lzcat "contrib/${c}.patch.lzma" |patch -p1 >/dev/null 2>&1
280 printf "Building up Makefile... "
281 sed -r -e "s,@@BINDIR@@,${BINDIR},g;" \
282 -e "s,@@LIBDIR@@,${LIBDIR},g;" \
283 -e "s,@@DOCDIR@@,${DOCDIR},g;" \
284 -e "s,@@MANDIR@@,${MANDIR},g;" \
285 -e "s,@@VERSION@@,${VERSION},g;" \
286 -e "s,@@DATE@@,${DATE},g;" \
287 -e "s,@@LOCAL@@,${LOCAL_set},g;" \
288 Makefile.in >Makefile
293 crosstool-NG configured as follows:
299 CONTRIB='${CONTRIB_list}'