diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2009-07-29 03:59:23 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2009-08-06 23:26:29 +0200 |
commit | caf3f478eaf04837251d01a6c7ff3b91fb6a384c (patch) | |
tree | 2d2f674007f4a9ac6a621e4cfe4ebc1693c8b370 /scripts | |
parent | 7498c234f5aee19adb73f4905735e2eb3c2055a7 (diff) | |
download | ptxdist-caf3f478eaf04837251d01a6c7ff3b91fb6a384c.tar.gz ptxdist-caf3f478eaf04837251d01a6c7ff3b91fb6a384c.tar.xz |
[ptxd_make_00-init] generate part of cross environment in shell
The generation of some CROSS_* environemnt variables has been moved
into the ptxd_init_cross_env function.
The following CROSS_ vars are now generated here:
CPPFLAGS, LDFLAGS, PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/ptxd_make_00-init.sh | 123 |
1 files changed, 120 insertions, 3 deletions
diff --git a/scripts/lib/ptxd_make_00-init.sh b/scripts/lib/ptxd_make_00-init.sh index 81676b7ec..87d7c8506 100644 --- a/scripts/lib/ptxd_make_00-init.sh +++ b/scripts/lib/ptxd_make_00-init.sh @@ -11,7 +11,7 @@ # # figure out arch string for ipkgs # -# out: $PTXDIST_IPKG_ARCH_STRING +# out: PTXDIST_IPKG_ARCH_STRING # ptxd_init_arch() { local ptx_arch="$(ptxd_get_ptxconf PTXCONF_ARCH_STRING)" @@ -73,8 +73,122 @@ ptxd_init_sysroot_toolchain() { } + +# +# gather all sysroots +# +# out: +# PTXDIST_PATH_SYSROOT additional sysroots (without toolchain) +# PTXDIST_PATH_SYSROOT_ALL all sysroots (including toolchain) +# PTXDIST_PATH_SYSROOT_PREFIX prefixes (/, /usr) of additional sysroots (without toolchain) +# PTXDIST_PATH_SYSROOT_PREFIX_ALL prefixes (/, /usr) of all sysroots (including toolchain) +# +ptxd_init_ptxdist_path() { + local sysroot="$(ptxd_get_ptxconf PTXCONF_SYSROOT_TARGET)" + local sysroot_prefix="${sysroot}:${sysroot}/usr" + + local sysroot_all="${sysroot}" + local sysroot_prefix_all="${sysroot_prefix}" + if [ -n "${PTXDIST_SYSROOT_TOOLCHAIN}" ]; then + sysroot_all="${sysroot_all}:${PTXDIST_SYSROOT_TOOLCHAIN}" + sysroot_prefix_all="${sysroot_prefix}:${PTXDIST_SYSROOT_TOOLCHAIN}:${PTXDIST_SYSROOT_TOOLCHAIN}/usr" + fi + + export \ + PTXDIST_PATH_SYSROOT="${sysroot}" \ + PTXDIST_PATH_SYSROOT_ALL="${sysroot_all}" + PTXDIST_PATH_SYSROOT_PREFIX="${sysroot_prefix}" \ + PTXDIST_PATH_SYSROOT_PREFIX_ALL="${sysroot_prefix_all}" +} + + + # -# initialize some vars needed in PTXdist's make +# setup compiler and pkgconfig environment +# +# in: +# ${PTXDIST_PATH_SYSROOT_PREFIX} +# +# +# out: +# PTXDIST_CROSS_CPPFLAGS CPPFLAGS for cross-compiled packages +# PTXDIST_CROSS_LDFLAGS LDFLAGS for cross-compiled packages +# PTXDIST_CROSS_ENV_PKG_CONFIG PKG_CONFIG_* environemnt for cross pkg-config +# +ptxd_init_cross_env() { + + ######## CPP_FLAGS, LDFLAGS ######## + + local orig_IFS="${IFS}" + IFS=":" + local -a prefix=( ${PTXDIST_PATH_SYSROOT_PREFIX} ) + IFS="${orig_IFS}" + + # add "-isystem <DIR>/include" + local -a cppflags + cppflags=( "${prefix[@]/%//include}" ) + cppflags=( "${cppflags[@]/#/-isystem }" ) + + # add "-L<DIR>/lib -Wl,-rpath-link -Wl,<DIR>" + local -a ldflags + ldflags=( "${prefix[@]/%//lib}" ) + ldflags=( "${ldflags[@]/#/-L}" "${ldflags[@]/#/-Wl,-rpath-link -Wl,}" ) + + export \ + PTXDIST_CROSS_CPPFLAGS="${cppflags[*]}" \ + PTXDIST_CROSS_LDFLAGS="${ldflags[*]}" + + + + ######## PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH ######## + + # + # PKG_CONFIG_LIBDIR contains the default pkg-config search + # directories. Set it to the last two components of + # PTXDIST_PATH_SYSROOT_PREFIX. Which is allways searched last. + # + # PKG_CONFIG_PATH contains additional pkg-config search + # directories, all remaining components of + # PTXDIST_PATH_SYSROOT_PREFIX are added to this. It's searched + # before searching the path specified in _LIBDIR + # + + # add <DIR>/lib/pkgconfig + local -a pkg_path=( "${prefix[@]/%//lib/pkgconfig}" ) + + # + # if we have additional pkg_config_path defined in our ptxconfig + # prefix them with sysroot and add to pkg_path, too. + # + # FIXME: we only take care of normal sysroot for now, no support + # for production releases, though. + # + local -a opt_pkg_path + if opt_pkg_path=( $(ptxd_get_ptxconf PTXCONF_PKG_CONFIG_PATH) ); then + IFS=":" + local -a sysroot=( ${PTXDIST_PATH_SYSROOT} ) + IFS="${orig_IFS}" + + pkg_path=( "${opt_pkg_path[@]/#/${sysroot[0]}}" "${pkg_path[@]}" ) + fi + + # last two go into pkg_libdir, the rest stays in pkg_path + local -i n=${#pkg_path[@]} + local -i n1=$(( --n )) + local -i n2=$(( --n )) + local -a pkg_libdir=( "${pkg_path[n2]}" "${pkg_path[n1]}" ) + + # remove last two + unset pkg_path[n2] pkg_path[n1] + + IFS=":" + export PTXDIST_CROSS_ENV_PKG_CONFIG="PKG_CONFIG_PATH='${pkg_path[*]}' PKG_CONFIG_LIBDIR='${pkg_libdir[*]}'" + IFS="${orig_ifs}" +} + + +# +# initialize vars needed by PTXdist's make # ptxd_make_init() { ptxd_init_arch && @@ -82,6 +196,9 @@ ptxd_make_init() { if ptxd_get_ptxconf PTXCONF_LIBC > /dev/null && ! ptxd_get_ptxconf PTXCONF_BUILD_TOOLCHAIN > /dev/null; then ptxd_init_sysroot_toolchain || return - fi + fi && + + ptxd_init_ptxdist_path && + ptxd_init_cross_env } ptxd_make_init |