scripts/addToolsVersion: properly handle .in vs. .in.2
While most components have their version in the .in file, some
have it in the .in.2 (eg. elf2flt).
Currently, to handle this case, we indiscriminately munge both files,
but this is wrong: in the elf2flt case, if we add a binutils version,
we do not want it to be added to elf2flt, and conversely.
So, for each tool, we need to explicitly know what file to munge.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
2 # Process this file with autoconf to produce a configure script.
5 #AC_INIT([crosstool-NG], [hg], [crossgcc@sourceware.org])
6 AC_INIT([crosstool-NG], [m4_esyscmd_s([cat .version])], [crossgcc@sourceware.org])
7 AC_CONFIG_AUX_DIR([scripts])
9 #--------------------------------------------------------------------
12 # Check for required tool
15 [AC_CHECK_TOOLS([$1], [$2])
18 [AC_MSG_ERROR([missing required tool: $2])])
21 # Check for required tool, set variable to full pathname
24 [ACX_CHECK_TOOL_REQ([$1], [$2])
28 [?*],[AC_MSG_CHECKING([for absolute path to $$1])
30 AC_MSG_RESULT([$$1])])])
32 # Check for required program
34 [ACX_CHECK_PROGS_REQ],
35 [AC_CHECK_PROGS([$1], [$2])
38 [AC_MSG_ERROR([missing required tool: $2])])
41 # Check for path to required program
44 [AC_PATH_PROGS([$1], [$2])
47 [AC_MSG_ERROR([missing required tool: $2])])
50 # Set the kconfig option
52 [ACX_SET_KCONFIG_OPTION],
55 [kconfig_options="$kconfig_options has_$1=y"],
56 [kconfig_options="$kconfig_options has_$1"])
59 #--------------------------------------------------------------------
60 # Allow dummy --{en,dis}able-{static,shared}
65 [don't install, and use current directory])])
66 AC_SUBST([enable_local], [${enable_local:-no}])
71 [build shared libraries (default=yes) (ignored)])])
76 [build static libraries (default=yes) (ignored)])])
78 #---------------------------------------------------------------------
79 # Check for --build and --host...
82 # ... but refuse --target
83 AS_IF([test -n "$target_alias"],
84 AC_MSG_ERROR([--target is not allowed]))
86 # Allow program name tranformation (--program-{prefix,suffix,transform-name})
89 #---------------------------------------------------------------------
90 # Initial checks that are usually done first (I don't know why, that's
91 # just what I seem to experience...)
92 #---------------------------------------------------------------------
93 AC_ARG_WITH([install],
94 AS_HELP_STRING([--with-install=PATH],
95 [Specify the full PATH to a BSD-compatible install]),
101 [test ! "$EGREP" = "$GREP -E"],
102 [AC_MSG_ERROR([egrep is not $GREP -E])])
103 AC_CACHE_VAL([ac_cv_path_SED],
105 AS_HELP_STRING([--with-sed=PATH],
106 [Specify the full PATH to GNU sed]),
107 [ac_cv_path_SED=$withval])])
109 AC_MSG_CHECKING([whether sed understands -r -i -e])
110 touch .ct-ng.sed.test
111 if ${SED} -r -i -e 's/foo/bar/' .ct-ng.sed.test >/dev/null 2>&1; then
112 rm -f .ct-ng.sed.test
115 rm -f .ct-ng.sed.test
121 #--------------------------------------------------------------------
122 # A bunch of boring tests...
123 #--------------------------------------------------------------------
125 AS_IF([test -z "$CC"],
126 [AC_MSG_ERROR([no suitable compiler found])])
129 # But we still need a way to specify the PATH to GNU versions (Damn MacOS)
130 AC_ARG_WITH([objcopy],
131 AS_HELP_STRING([--with-objcopy=PATH],
132 [Specify the full PATH to GNU objcopy]),
134 AC_ARG_WITH([objdump],
135 AS_HELP_STRING([--with-objdump=PATH],
136 [Specify the full PATH to GNU objdump]),
138 AC_ARG_WITH([ranlib],
139 AS_HELP_STRING([--with-ranlib=PATH],
140 [Specify the full PATH to GNU ranlib]),
142 AC_ARG_WITH([readelf],
143 AS_HELP_STRING([--with-readelf=PATH],
144 [Specify the full PATH to GNU readelf]),
148 ACX_PATH_TOOL_REQ([OBJCOPY], [objcopy])
149 ACX_PATH_TOOL_REQ([OBJDUMP], [objdump])
150 ACX_PATH_TOOL_REQ([READELF], [readelf])
152 ACX_CHECK_PROGS_REQ([bison], [bison])
153 ACX_CHECK_PROGS_REQ([flex], [flex])
154 ACX_CHECK_PROGS_REQ([gperf], [gperf])
155 ACX_CHECK_PROGS_REQ([makeinfo], [makeinfo])
156 ACX_CHECK_PROGS_REQ([cut], [cut])
157 ACX_CHECK_PROGS_REQ([stat], [stat])
158 ACX_CHECK_PROGS_REQ([readlink], [readlink])
159 ACX_CHECK_PROGS_REQ([wget], [wget])
160 ACX_CHECK_PROGS_REQ([tar], [tar])
161 ACX_CHECK_PROGS_REQ([gzip], [gzip])
162 ACX_CHECK_PROGS_REQ([bzip2], [bzip2])
164 #--------------------------------------------------------------------
165 # Still boring, but remember the path, now...
166 #--------------------------------------------------------------------
167 ACX_PATH_PROGS_REQ([PATCH], [patch])
169 #--------------------------------------------------------------------
170 # And a bunch of less boring tests...
171 #--------------------------------------------------------------------
172 # We need a bash that is >= 3.1
173 AC_CACHE_VAL([ac_cv_path__BASH],
175 AS_HELP_STRING([--with-bash=PATH],
176 [Specify the full PATH to GNU bash >= 3.1]),
177 [ac_cv_path__BASH=$withval])])
178 AC_CACHE_CHECK([for bash >= 3.1], [ac_cv_path__BASH],
179 [AC_PATH_PROGS_FEATURE_CHECK([_BASH], [bash],
180 [[_BASH_ver=$($ac_path__BASH --version 2>&1 \
181 |$EGREP '^GNU bash, version (3\.[1-9]|4)')
182 test -n "$_BASH_ver" && ac_cv_path__BASH=$ac_path__BASH ac_path__BASH_found=:]],
184 AC_MSG_ERROR([could not find bash >= 3.1])])])
185 AC_SUBST([_BASH], [$ac_cv_path__BASH])
187 # We need a awk that *is* GNU awk
188 AC_CACHE_VAL([ac_cv_path__AWK],
190 AS_HELP_STRING([--with-awk=PATH],
191 [Specify the full PATH to GNU awk]),
192 [ac_cv_path__AWK=$withval])])
193 AC_CACHE_CHECK([for GNU awk], [ac_cv_path__AWK],
194 [AC_PATH_PROGS_FEATURE_CHECK([_AWK], [awk gawk],
195 [[_AWK_ver=$($ac_path__AWK --version 2>&1 \
197 test -n "$_AWK_ver" && ac_cv_path__AWK=$ac_path__AWK ac_path__AWK_found=:]],
199 AC_MSG_ERROR([could not find GNU awk])])])
200 AC_SUBST([_AWK], [$ac_cv_path__AWK])
202 #----------------------------------------
203 # Check for GNU make 3.80 or above
204 AC_CACHE_VAL([ac_cv_path_MAKE],
206 AS_HELP_STRING([--with-make=PATH],
207 [Specify the full PATH to GNU make >= 3.80]),
208 [ac_cv_path_MAKE=$withval])])
209 AC_CACHE_CHECK([for GNU make >= 3.80], [ac_cv_path_MAKE],
210 [AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake],
211 [[MAKE_ver=$($ac_path_MAKE --version 2>&1 \
212 |$EGREP '^GNU Make (3.[89][[:digit:]]|[4-9])')
213 test -n "$MAKE_ver" && ac_cv_path_MAKE=$ac_path_MAKE ac_path_MAKE_found=:]],
215 AC_MSG_ERROR([could not find GNU make >= 3.80])])])
216 AC_SUBST([MAKE], [$ac_cv_path_MAKE])
219 #----------------------------------------
220 # Check for libtool >= 1.5.26
221 AC_CACHE_VAL([ac_cv_path_LIBTOOL],
222 [AC_ARG_WITH([libtool],
223 AS_HELP_STRING([--with-libtool=PATH],
224 [Specify the full PATH to GNU libtool >= 1.5.26]),
225 [ac_cv_path_LIBTOOL=$withval])])
226 AC_CACHE_CHECK([for GNU libtool >= 1.5.26], [ac_cv_path_LIBTOOL],
227 [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOL], [libtool],
228 [[LIBTOOL_ver=$($ac_path_LIBTOOL --version 2>&1 \
229 |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
230 test -n "$LIBTOOL_ver" && ac_cv_path_LIBTOOL=$ac_path_LIBTOOL ac_path_LIBTOOL_found=:]],
232 AC_MSG_ERROR([could not find GNU libtool >= 1.5.26])])])
233 AC_SUBST([LIBTOOL], [$ac_cv_path_LIBTOOL])
235 #----------------------------------------
236 # Check for libtoolize >= 1.5.26
237 AC_CACHE_VAL([ac_cv_path_LIBTOOLIZE],
238 [AC_ARG_WITH([libtoolize],
239 AS_HELP_STRING([--with-libtoolize=PATH],
240 [Specify the full PATH to GNU libtoolize >= 1.5.26]),
241 [ac_cv_path_LIBTOOLIZE=$withval])])
242 AC_CACHE_CHECK([for GNU libtoolize >= 1.5.26], [ac_cv_path_LIBTOOLIZE],
243 [AC_PATH_PROGS_FEATURE_CHECK([LIBTOOLIZE], [libtoolize],
244 [[LIBTOOLIZE_ver=$($ac_path_LIBTOOLIZE --version 2>&1 \
245 |$EGREP '\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)')
246 test -n "$LIBTOOLIZE_ver" && ac_cv_path_LIBTOOLIZE=$ac_path_LIBTOOLIZE ac_path_LIBTOOLIZE_found=:]],
248 AC_MSG_ERROR([could not find GNU libtoolize >= 1.5.26])])])
249 AC_SUBST([LIBTOOLIZE], [$ac_cv_path_LIBTOOLIZE])
251 #----------------------------------------
252 # Check for automake >= 1.10
253 AC_CACHE_VAL([ac_cv_path_automake],
254 [AC_ARG_WITH([automake],
255 AS_HELP_STRING([--with-automake=PATH],
256 [Specify the full PATH to GNU automake >= 1.10]),
257 [ac_cv_path_automake=$withval])])
258 AC_CACHE_CHECK([for GNU automake >= 1.10], [ac_cv_path_automake],
259 [AC_PATH_PROGS_FEATURE_CHECK([automake], [automake],
260 [[automake_ver=$($ac_path_automake --version 2>&1 \
261 |$EGREP '\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)')
262 test -n "$automake_ver" && ac_cv_path_automake=$ac_path_automake ac_path_automake_found=:]],
264 AC_MSG_ERROR([could not find GNU automake >= 1.10])])])
265 AC_SUBST([automake], [$ac_cv_path_automake])
267 #--------------------------------------------------------------------
268 # Boring again... But still a bit of work to do...
269 #--------------------------------------------------------------------
270 AC_SUBST([kconfig_options])
272 #----------------------------------------
273 AC_CHECK_PROGS([xz], [xz])
274 ACX_SET_KCONFIG_OPTION([xz])
277 [AC_CHECK_PROGS([lzma], [lzma])])
278 ACX_SET_KCONFIG_OPTION([lzma])
280 #----------------------------------------
281 AC_CHECK_PROGS([cvs], [cvs])
282 ACX_SET_KCONFIG_OPTION([cvs])
284 #----------------------------------------
285 AC_CHECK_PROGS([svn], [svn])
286 ACX_SET_KCONFIG_OPTION([svn])
288 #--------------------------------------------------------------------
289 # Now, for some fun...
290 #--------------------------------------------------------------------
297 #----------------------------------------
298 # Check for gettext, for the kconfig frontends
302 [ac_ct_gettext_hdr=$ac_header; break])
304 [test -n "$ac_ct_gettext_hdr"],
308 [AC_INCLUDES_DEFAULT()
309 #include <$ac_ct_gettext_hdr>])])
311 #----------------------------------------
312 # Check for ncurses, for the kconfig frontends
313 AC_SUBST([ac_ct_curses_hdr])
315 [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
316 [ac_ct_curses_hdr=$ac_header; break])
318 [test -z "$ac_ct_curses_hdr"],
319 [AC_MSG_ERROR([could not find curses header, required for the kconfig frontends])])
322 [ncursesw ncurses curses],
323 [ac_ct_curses_lib_found=yes; break])
325 [test -z "$ac_ct_curses_lib_found"],
326 [AC_MSG_ERROR([could not find curses library, required for the kconfig frontends])])
328 #--------------------------------------------------------------------
329 # Lastly, take care of crosstool-NG internal values
330 #--------------------------------------------------------------------
331 # Hey! We need the date! :-)
336 # Decorate the version string if needed
338 [test -f version.sh -a -x version.sh],
339 [V=$(./version.sh "${PACKAGE_VERSION}")])
342 [PACKAGE_VERSION="${V}"],
344 [${PACKAGE_VERSION}],
346 [rev_id="$( hg log -r . --template '{branch}-{node|short}\n' \
349 PACKAGE_VERSION="${PACKAGE_VERSION}+${rev_id:-unknown-$( date +%Y%m%d.%H%M%S )}"
351 # Arrange to have no / in the directory name, no need to create an
352 # arbitrarily deep directory structure
353 [PACKAGE_VERSION="$( printf "${PACKAGE_VERSION}\n" |"${SED}" -r -e 's:/+:_:g;' )"]
355 # Handle the local case
356 AC_SUBST([sublibdir])
357 AC_SUBST([subdocdir])
359 [test "x$enable_local" = "xyes"],
360 [AC_MSG_NOTICE([overiding all of --prefix and the likes, because --enable-local was set])
362 exec_prefix="$prefix"
366 docdir="$prefix""/docs"
368 datarootdir="$prefix"
370 [sublibdir="/ct-ng.\${VERSION}"
371 subdocdir="/ct-ng.\${VERSION}"])
373 #--------------------------------------------------------------------
374 # Finally, generate the output file(s)
375 #--------------------------------------------------------------------
376 AC_CONFIG_FILES([Makefile])