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>
1 # Build script for libelf
4 do_libelf_extract() { :; }
5 do_libelf_for_build() { :; }
6 do_libelf_for_host() { :; }
7 do_libelf_for_target() { :; }
9 if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then
12 # The server hosting libelf will return an "HTTP 300 : Multiple Choices"
13 # error code if we try to download a file that does not exists there.
14 # So we have to request the file with an explicit extension.
15 CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/
19 CT_Extract "libelf-${CT_LIBELF_VERSION}"
20 CT_Patch "libelf" "${CT_LIBELF_VERSION}"
23 if [ "${CT_LIBELF}" = "y" ]; then
25 # Build libelf for running on build
26 # - always build statically
27 # - we do not have build-specific CFLAGS
28 # - install in build-tools prefix
29 do_libelf_for_build() {
32 case "${CT_TOOLCHAIN_TYPE}" in
33 native|cross) return 0;;
36 CT_DoStep INFO "Installing libelf for build"
37 CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-build-${CT_BUILD}"
39 libelf_opts+=( "host=${CT_BUILD}" )
40 libelf_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
41 libelf_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
42 libelf_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
43 do_libelf_backend "${libelf_opts[@]}"
49 # Build libelf for running on host
50 do_libelf_for_host() {
53 CT_DoStep INFO "Installing libelf for host"
54 CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-host-${CT_HOST}"
56 libelf_opts+=( "host=${CT_HOST}" )
57 libelf_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
58 libelf_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
59 libelf_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
60 do_libelf_backend "${libelf_opts[@]}"
68 if [ "${CT_LIBELF_TARGET}" = "y" ]; then
70 do_libelf_for_target() {
73 CT_DoStep INFO "Installing libelf for the target"
74 CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-target-${CT_TARGET}"
76 libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" )
77 libelf_opts+=( "host=${CT_TARGET}" )
78 libelf_opts+=( "prefix=/usr" )
79 libelf_opts+=( "shared=y" )
80 do_libelf_backend "${libelf_opts[@]}"
89 # Parameter : description : type : default
90 # destdir : out-of-tree install dir : string : /
91 # host : machine to run on : tuple : (none)
92 # prefix : prefix to install into : dir : (none)
93 # cflags : cflags to use : string : (empty)
94 # ldflags : ldflags to use : string : (empty)
95 # shared : also buils shared lib : bool : n
103 local -a extra_config
110 CT_DoLog EXTRA "Configuring libelf"
112 if [ "${shared}" = "y" ]; then
113 extra_config+=( --enable-shared )
115 extra_config+=( --disable-shared )
120 RANLIB="${host}-ranlib" \
121 CFLAGS="${cflags} -fPIC" \
122 LDFLAGS="${ldflags}" \
123 "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure" \
124 --build=${CT_BUILD} \
126 --target=${CT_TARGET} \
127 --prefix="${prefix}" \
130 --enable-extended-format \
134 CT_DoLog EXTRA "Building libelf"
135 CT_DoExecLog ALL make
137 CT_DoLog EXTRA "Installing libelf"
138 CT_DoExecLog ALL make instroot="${destdir}" install
141 fi # CT_LIBELF || CT_LIBELF_TARGET