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 do_libelf_backend "${libelf_opts[@]}"
47 # Build libelf for running on host
48 do_libelf_for_host() {
51 CT_DoStep INFO "Installing libelf for host"
52 CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-host-${CT_HOST}"
54 libelf_opts+=( "host=${CT_HOST}" )
55 libelf_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
56 libelf_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
57 do_libelf_backend "${libelf_opts[@]}"
65 if [ "${CT_LIBELF_TARGET}" = "y" ]; then
67 do_libelf_for_target() {
70 CT_DoStep INFO "Installing libelf for the target"
71 CT_mkdir_pushd "${CT_BUILD_DIR}/build-libelf-target-${CT_TARGET}"
73 libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" )
74 libelf_opts+=( "host=${CT_TARGET}" )
75 libelf_opts+=( "prefix=/usr" )
76 libelf_opts+=( "shared=y" )
77 do_libelf_backend "${libelf_opts[@]}"
86 # Parameter : description : type : default
87 # destdir : out-of-tree install dir : string : /
88 # host : machine to run on : tuple : (none)
89 # prefix : prefix to install into : dir : (none)
90 # cflags : host cflags to use : string : (empty)
91 # shared : also buils shared lib : bool : n
105 CT_DoLog EXTRA "Configuring libelf"
107 if [ "${shared}" = "y" ]; then
108 extra_config+=( --enable-shared )
110 extra_config+=( --disable-shared )
115 RANLIB="${host}-ranlib" \
116 CFLAGS="${cflags} -fPIC" \
117 "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure" \
118 --build=${CT_BUILD} \
120 --target=${CT_TARGET} \
121 --prefix="${prefix}" \
124 --enable-extended-format \
128 CT_DoLog EXTRA "Building libelf"
129 CT_DoExecLog ALL make
131 CT_DoLog EXTRA "Installing libelf"
132 CT_DoExecLog ALL make instroot="${destdir}" install
135 fi # CT_LIBELF || CT_LIBELF_TARGET