From 885be8a79cf2f43a258efe57720fb9856907fd90 Mon Sep 17 00:00:00 2001 From: Thomas Quinot Date: Thu, 24 Mar 2011 15:57:57 +0000 Subject: [PATCH] Handle installation for cross case: * install build infrastructure (projects, includes, libraries) under $prefix/$target * install host executables (compilation tools) as $prefix/bin/$target-$cmd * install target executables (services) as $prefix/$target/bin/$cmd For K322-023 Subversion-branch: /trunk/polyorb Subversion-revision: 171671 --- Makefile.in | 68 ++++++++++++++++++++++++++--------------------- configure.ac | 13 ++------- polyorb-config.in | 29 +++++++++++++++----- 3 files changed, 61 insertions(+), 49 deletions(-) diff --git a/Makefile.in b/Makefile.in index 489338929..b8e5cb090 100644 --- a/Makefile.in +++ b/Makefile.in @@ -71,8 +71,8 @@ INSTALL_BIN := @INSTALL_BIN@ LN_S := @LN_S@ SHELL := @SHELL@ -TOOL_EXE_SUFFIX := @TOOL_EXE_SUFFIX@ -COMPILER_EXE_SUFFIX := @COMPILER_EXE_SUFFIX@ +HOST_EXE_SUFFIX := @HOST_EXE_SUFFIX@ +TARGET_EXE_SUFFIX := @TARGET_EXE_SUFFIX@ CC_FOR_TARGET := @CC_FOR_TARGET@ GNATCHOP := @GNATCHOP@ GNATMAKE := @GNATMAKE@ @@ -823,41 +823,47 @@ docs: # Installation +host=@host@ +target=@target@ prefix=@prefix@ +ifeq (${target}, ${host}) + target_prefix=${prefix} + host_cmd_prefix=${prefix}/bin/ + target_cmd_prefix=${prefix}/bin/ + +else + target_prefix=${prefix}/${target} + host_cmd_prefix=${prefix}/bin/${target}- + target_cmd_prefix=${target_prefix}/bin/ +endif + .PHONY: install install: all - @echo "Install prefix: ${prefix}" @echo " Sources dir: ${top_srcdir}" @echo " Build dir: ${top_builddir}" - ${INSTALL} -d ${prefix}/bin - ${RM} -fr "${prefix}/lib/gnat/polyorb" - ${INSTALL} -d ${prefix}/lib/gnat/polyorb - ${INSTALL} -d ${prefix}/lib/polyorb - ${INSTALL} -d ${prefix}/lib/polyorb/static - ${RM} -fr "${prefix}/include/polyorb" - ${INSTALL} -d ${prefix}/include/polyorb + @echo "Install prefix: ${prefix}" + @echo " Host: ${host}" + @echo " Target: ${target}" + ${INSTALL} -d ${prefix}/bin ${target_prefix}/bin + ${RM} -fr "${target_prefix}/lib/gnat/polyorb" + ${INSTALL} -d ${target_prefix}/lib/gnat/polyorb + ${INSTALL} -d ${target_prefix}/lib/polyorb + ${INSTALL} -d ${target_prefix}/lib/polyorb/static + ${RM} -fr "${target_prefix}/include/polyorb" + ${INSTALL} -d ${target_prefix}/include/polyorb for comp in ${COMPILER_EXES}; do \ - ${INSTALL_BIN} ${top_builddir}/compilers/$${comp}${COMPILER_EXE_SUFFIX} ${prefix}/bin; \ - : Special case, symlink iac as idlac for backwards compatibility; \ - if [ `basename $${comp}` = iac ]; then \ - (cd ${prefix}/bin && ${RM} -f idlac${TOOL_EXE_SUFFIX} && ${LN_S} iac${TOOL_EXE_SUFFIX} idlac${TOOL_EXE_SUFFIX}); \ - fi; \ + ${INSTALL_BIN} ${top_builddir}/compilers/$${comp}${HOST_EXE_SUFFIX} ${host_cmd_prefix}`basename $${comp}`${HOST_EXE_SUFFIX}; \ done - ${INSTALL_BIN} ${top_builddir}/tools/po_cos_naming/po_cos_naming${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_cos_naming/po_cos_naming_shell${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_cos_naming/ir_ab_names${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_ir/po_ir${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_catref/po_catref${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_createref/po_createref${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_names/po_names${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_BIN} ${top_builddir}/tools/po_dumpir/po_dumpir${TOOL_EXE_SUFFIX} ${prefix}/bin - ${INSTALL_SCRIPT} ${top_builddir}/polyorb-config ${prefix}/bin - ls ${top_builddir}/lib/*.a | ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/lib/polyorb/static - ls ${top_srcdir}/projects-distrib/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/lib/gnat - ls ${top_builddir}/projects-distrib/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/lib/gnat - ls ${top_srcdir}/projects-distrib/polyorb/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/lib/gnat/polyorb - ls ${top_builddir}/projects-distrib/polyorb/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/lib/gnat/polyorb + ${INSTALL_SCRIPT} ${top_builddir}/polyorb-config ${host_cmd_prefix}polyorb-config + for tool in po_cos_naming/po_cos_naming po_cos_naming/po_cos_naming_shell po_cos_naming/ir_ab_names po_ir/po_ir po_catref/po_catref po_createref/po_createref po_names/po_names po_dumpir/po_dumpir; do \ + ${INSTALL_BIN} ${top_builddir}/tools/$$tool${TARGET_EXE_SUFFIX} ${target_cmd_prefix}`basename $$tool`${TARGET_EXE_SUFFIX}; \ + done + ls ${top_builddir}/lib/*.a | ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/lib/polyorb/static + ls ${top_srcdir}/projects-distrib/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/lib/gnat + ls ${top_builddir}/projects-distrib/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/lib/gnat + ls ${top_srcdir}/projects-distrib/polyorb/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/lib/gnat/polyorb + ls ${top_builddir}/projects-distrib/polyorb/*.gpr | ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/lib/gnat/polyorb (find \ ${top_builddir}/src \ ${top_builddir}/cos \ @@ -866,14 +872,14 @@ install: all ${top_srcdir}/cos \ ${top_srcdir}/idls \ -name '*.ads' -o -name '*.adb' -o -name '*.idl') | \ - ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/include/polyorb + ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/include/polyorb (find \ ${top_builddir}/ali \ -name '*.ali' \ -a ! -name 'polyorb-dsa_p-partitions.ali' \ -a ! -name 'polyorb-dsa_p-storages-config.ali' \ -a ! -name 'polyorb-partition_elaboration.ali') | \ - ${XARGS_I} ${INSTALL} -m 444 {} ${prefix}/lib/polyorb + ${XARGS_I} ${INSTALL} -m 444 {} ${target_prefix}/lib/polyorb # Install documentation only if it has been built locally, or # pre-built and packaged with sources. if [ -r docs/polyorb_ug.html ]; \ diff --git a/configure.ac b/configure.ac index df1000e30..548002a94 100644 --- a/configure.ac +++ b/configure.ac @@ -172,17 +172,8 @@ AC_SUBST(WINDOWS_ON_TARGET) # Implementation note: the *vxworks* rule above is for VxWorks 5, it can # present some problems for VxWorks 6. -# Compilers are always built using the native Ada compiler. Therefore, -# their executable suffix depends on the host operating system. - -COMPILER_EXE_SUFFIX=$HOST_EXE_SUFFIX -AC_SUBST(COMPILER_EXE_SUFFIX) - -# Tools are using the cross Ada compiler. Therefore, their executable -# suffix depends on the target operating system. - -TOOL_EXE_SUFFIX=$TARGET_EXE_SUFFIX -AC_SUBST(TOOL_EXE_SUFFIX) +AC_SUBST(HOST_EXE_SUFFIX) +AC_SUBST(TARGET_EXE_SUFFIX) # By default treat all warnings as errors when building directly from the # source repository. The packaging procedure changes the default to "n". diff --git a/polyorb-config.in b/polyorb-config.in index 7ecce0c74..2c29a673a 100644 --- a/polyorb-config.in +++ b/polyorb-config.in @@ -5,6 +5,14 @@ # @configure_input@ +host=@host@ +target=@target@ +if [ "$host" = "$target" ]; then + is_cross=false +else + is_cross=true +fi + # Determine installation prefix case "$0" in @@ -29,13 +37,18 @@ case "$OS" in exec_prefix=`cygpath -w $exec_prefix` esac -if [ -f "${exec_prefix}"/include/polyorb/polyorb.ads ]; then - prefix="${exec_prefix}" -else - # Fall back to configure-time prefix - prefix="@prefix@" +unset tgt_subdir +if $is_cross; then + tgt_subdir=/$target fi +for candidate_prefix in "${exec_prefix}${tgt_subdir}" "@prefix@${tgt_subdir}"; do + prefix="${candidate_prefix}" + if [ -f "${candidate_prefix}"/include/polyorb/polyorb.ads ]; then + break + fi +done + have_gnatmake_aPdir=@HAVE_GNATMAKE_APDIR@ default_appli="@APPLI_LIST@" default_proto="@PROTO_LIST@" @@ -144,7 +157,10 @@ while test $# -gt 0; do echo_exec_prefix=true ;; --version|-v) - echo "PolyORB @POLYORB_VERSION@" 1>&2 + echo "PolyORB @POLYORB_VERSION@ for ${target}" 1>&2 + if $is_cross; then + echo " hosted on ${host}" 1>&2 + fi exit 0 ;; --config) @@ -183,7 +199,6 @@ EOF shift done -exec_prefix="@exec_prefix@" includedir="@includedir@" libdir="@libdir@" polyorb_dir="${includedir}/polyorb"