Author: jim Date: 2006-08-31 17:48:18 -0600 (Thu, 31 Aug 2006) New Revision: 2374
Added: trunk/BOOK/final-system/multilib/multiarch_wrapper.xml Modified: / trunk/BOOK/final-system/mips64-chapter.xml trunk/BOOK/final-system/multilib/perl-64bit.xml trunk/BOOK/final-system/ppc64-chapter.xml trunk/BOOK/final-system/sparc64-chapter.xml trunk/BOOK/final-system/x86_64-chapter.xml Log: [EMAIL PROTECTED] (orig r2511): jciccone | 2006-08-31 13:19:47 -0700 Renamed the multilib_wrapper to multiarch_wrapper Changed the env var from PERL_ARCH to USE_ARCH Moved the multiarch_wrapper to its own page towords the beginning of building the final system. Property changes on: ___________________________________________________________________ Name: svk:merge - b6734a72-470d-0410-b049-f317dca95413:/:2510 + b6734a72-470d-0410-b049-f317dca95413:/:2511 Modified: trunk/BOOK/final-system/mips64-chapter.xml =================================================================== --- trunk/BOOK/final-system/mips64-chapter.xml 2006-08-31 19:49:50 UTC (rev 2373) +++ trunk/BOOK/final-system/mips64-chapter.xml 2006-08-31 23:48:18 UTC (rev 2374) @@ -23,6 +23,7 @@ <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="mips64/adjusting.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/binutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="mips64/gcc.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/multiarch_wrapper.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/coreutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="common/iana-etc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/m4.xml"/> Added: trunk/BOOK/final-system/multilib/multiarch_wrapper.xml =================================================================== --- trunk/BOOK/final-system/multilib/multiarch_wrapper.xml (rev 0) +++ trunk/BOOK/final-system/multilib/multiarch_wrapper.xml 2006-08-31 23:48:18 UTC (rev 2374) @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" + "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../../general.ent"> + %general-entities; +]> + +<sect1 id="ch-system-multiarch-wrapper" role="wrap"> + <?dbhtml filename="multiarch_wrapper.html"?> + + <title>Creating a Muliarch Wrapper</title> + + <indexterm zone="ch-system-multiarch-wrapper"> + <primary sortas="a-File">Multiarch Wrapper</primary> + </indexterm> + + <sect2 role="package"> + <title/> + + <para>The Multiarch Wrapper is used to wrap certain binaries that have + hardcoded paths to libraries or are architecture specific.</para> + + </sect2> + + <sect2 role="installation"> + <title>Installation of The Multiarch Wrapper</title> + + <para os="a">Create the source file:</para> + +<screen os="b"><userinput>cat > multiarch_wrapper.c << "EOF" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#ifndef DEFAULT_ARCH +# define DEFAULT_ARCH "64" +#endif + +int main (int argc, char *argv[]) +{ + char *use_arch; + if ((use_arch = getenv("USE_ARCH")) == NULL) + use_arch = DEFAULT_ARCH; + + char *filename = malloc(strlen(argv[0]) + strlen(use_arch) + 2); + strcpy(filename, argv[0]); + strcat(filename, "-"); + strcat(filename, use_arch); + + int ret = execvp(filename, argv); + if ((ret != 0)&&(errno != 0)) + { + char *errmsg = malloc(strlen(filename) + 19); + strcpy(errmsg, "Unable to execute "); + strcat(errmsg, filename); + perror(errmsg); + free(errmsg); + } + + free(filename); + + return ret; +} +EOF</userinput></screen> + + <para os="c">Compile and Install the Multiarch Wrapper:</para> + +<screen os="d"><userinput>gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper</userinput></screen> + + <para os="e">This multiarch wrapper is going to be used later on in the book + with perl. It will also be very useful outside of the base CLFS system.</para> + + <para os="f">Creating the testcase:</para> + +<screen os="g"><userinput>echo 'echo "32bit Version"' > test-32 +echo 'echo "64bit Version"' > test-64 +chmod 755 test-32 test-64 +ln -sv /usr/bin/multiarch_wrapper test</userinput></screen> + + <para os="h">Testing the wrapper:</para> + +<screen os="i"><userinput>USE_ARCH=32 ./test +USE_ARCH=64 ./test</userinput></screen> + + <para os="j">The output of the above command should be:</para> + +<screen os="k"><userinput>32bit Version +64bit Version</userinput></screen> + + </sect2> + + <sect2 id="contents-multiarch-wrapper" role="content"> + <title>Contents of The Multiarch Wrapper</title> + + <segmentedlist> + <segtitle>Installed programs</segtitle> + + <seglistitem> + <seg>multiarch_wrapper</seg> + </seglistitem> + </segmentedlist> + + <variablelist> + <bridgehead renderas="sect3">Short Descriptions</bridgehead> + <?dbfo list-presentation="list"?> + <?dbhtml list-presentation="table"?> + + <varlistentry id="multiarch_wrapper"> + <term><command>multiarch_wrapper</command></term> + <listitem> + <para>Will execute a different program based on the + <envar>USE_ARCH</envar> variable. The <envar>USE_ARCH</envar> + variable will be the suffix of the executed program.</para> + <indexterm zone="ch-system-multiarch-wrapper multiarch_wrapper"> + <primary sortas="b-multiarch_wrapper">multiarch_wrapper</primary> + </indexterm> + </listitem> + </varlistentry> + + </variablelist> + + </sect2> + +</sect1> Modified: trunk/BOOK/final-system/multilib/perl-64bit.xml =================================================================== --- trunk/BOOK/final-system/multilib/perl-64bit.xml 2006-08-31 19:49:50 UTC (rev 2373) +++ trunk/BOOK/final-system/multilib/perl-64bit.xml 2006-08-31 23:48:18 UTC (rev 2374) @@ -115,55 +115,18 @@ <screen os="m"><userinput>mv /usr/bin/perl{,-64}</userinput></screen> - <para os="n">Now we need to create a multilib wrapper that lets us choose - which perl installation to use:</para> + <para os="n">Now we need to create a link to the multiarch wrapper that + lets us choose which perl installation to use:</para> -<screen os="o"><userinput>cat > perl_wrapper.c << "EOF" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> +<screen os="o"><userinput>ln -sv multiarch_wrapper /usr/bin/perl</userinput></screen> -int main (int argc, char *argv[]) -{ - char *perl_arch; - if ((perl_arch = getenv("PERL_ARCH")) == NULL) - perl_arch = "64"; + <para os="p">The value of the <envar>USE_ARCH</envar> enviornment variable + will decide which perl binary to execute. + <command>USE_ARCH=32 perl -V:cc</command> will give the value of CC used to + build the 32bit perl. The multiarch_wrapper will help later with building + perl extensions and bindings. Without the multiarch_wrapper it is very hard + to setup a 32bit extenstion or binding.</para> - char *filename = malloc(strlen(argv[0]) + strlen(perl_arch) + 2); - strcpy(filename, argv[0]); - strcat(filename, "-"); - strcat(filename, perl_arch); - - int ret = 0; - ret = execvp(filename, argv); - if ((ret != 0)&&(errno != 0)) - { - char *errmsg = malloc(strlen(filename) + 19); - strcpy(errmsg, "Unable to execute "); - strcat(errmsg, filename); - perror(errmsg); - free(errmsg); - } - - free(filename); - - return ret; -} -EOF -gcc ${BUILD64} perl_wrapper.c -o /usr/bin/perl</userinput></screen> - - <para os="p">This multilib wrapper makes it possible to build perl - extensions other then 64-bit. The PERL_ARCH environment variable controls - which perl binary to execute. Some packages that may attempt to build - against perl will run <command>perl -V:cc</command> to get the command - that was used to build perl. If you're building a 32-bit extension but you - only have a 64-bit perl this is not desired. By setting PERL_ARCH=32 you - will be able to build the 32-bit extension because - <command>perl -V:cc</command> will return the command used to build the - 32-bit perl installation.</para> - </sect2> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" Modified: trunk/BOOK/final-system/ppc64-chapter.xml =================================================================== --- trunk/BOOK/final-system/ppc64-chapter.xml 2006-08-31 19:49:50 UTC (rev 2373) +++ trunk/BOOK/final-system/ppc64-chapter.xml 2006-08-31 23:48:18 UTC (rev 2374) @@ -22,6 +22,7 @@ <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="ppc64/adjusting.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="ppc64/binutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="ppc64/gcc.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/multiarch_wrapper.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/coreutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="common/iana-etc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/m4.xml"/> Modified: trunk/BOOK/final-system/sparc64-chapter.xml =================================================================== --- trunk/BOOK/final-system/sparc64-chapter.xml 2006-08-31 19:49:50 UTC (rev 2373) +++ trunk/BOOK/final-system/sparc64-chapter.xml 2006-08-31 23:48:18 UTC (rev 2374) @@ -22,6 +22,7 @@ <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/adjusting.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/binutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="sparc64/gcc.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/multiarch_wrapper.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/coreutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="common/iana-etc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/m4.xml"/> Modified: trunk/BOOK/final-system/x86_64-chapter.xml =================================================================== --- trunk/BOOK/final-system/x86_64-chapter.xml 2006-08-31 19:49:50 UTC (rev 2373) +++ trunk/BOOK/final-system/x86_64-chapter.xml 2006-08-31 23:48:18 UTC (rev 2374) @@ -22,6 +22,7 @@ <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="x86_64/adjusting.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/binutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/gcc.xml"/> + <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/multiarch_wrapper.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/coreutils.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="common/iana-etc.xml"/> <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="multilib/m4.xml"/> -- http://linuxfromscratch.org/mailman/listinfo/cross-lfs FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
