source: final-system/multilib/multiarch_wrapper.xml@ 08442c9

Last change on this file since 08442c9 was e642efb3, checked in by Joe Ciccone <jciccone@…>, 18 years ago

Fix typo in the 1.0 branch. r2516 from turnk.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-system-multiarch-wrapper" role="wrap">
9 <?dbhtml filename="multiarch_wrapper.html"?>
10
11 <title>Creating a Multiarch Wrapper</title>
12
13 <indexterm zone="ch-system-multiarch-wrapper">
14 <primary sortas="a-File">Multiarch Wrapper</primary>
15 </indexterm>
16
17 <sect2 role="package">
18 <title/>
19
20 <para>The Multiarch Wrapper is used to wrap certain binaries that have
21 hardcoded paths to libraries or are architecture specific.</para>
22
23 </sect2>
24
25 <sect2 role="installation">
26 <title>Installation of The Multiarch Wrapper</title>
27
28 <para os="a">Create the source file:</para>
29
30<screen os="b"><userinput>cat &gt; multiarch_wrapper.c &lt;&lt; "EOF"
31#include &lt;stdio.h&gt;
32#include &lt;stdlib.h&gt;
33#include &lt;string.h&gt;
34#include &lt;errno.h&gt;
35
36#ifndef DEFAULT_ARCH
37# define DEFAULT_ARCH "64"
38#endif
39
40int main (int argc, char *argv[])
41{
42 char *use_arch;
43 if ((use_arch = getenv("USE_ARCH")) == NULL)
44 use_arch = DEFAULT_ARCH;
45
46 char *filename = malloc(strlen(argv[0]) + strlen(use_arch) + 2);
47 strcpy(filename, argv[0]);
48 strcat(filename, "-");
49 strcat(filename, use_arch);
50
51 int ret = execvp(filename, argv);
52 if ((ret != 0)&amp;&amp;(errno != 0))
53 {
54 char *errmsg = malloc(strlen(filename) + 19);
55 strcpy(errmsg, "Unable to execute ");
56 strcat(errmsg, filename);
57 perror(errmsg);
58 free(errmsg);
59 }
60
61 free(filename);
62
63 return ret;
64}
65EOF</userinput></screen>
66
67 <para os="c">Compile and Install the Multiarch Wrapper:</para>
68
69<screen os="d"><userinput>gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper</userinput></screen>
70
71 <para os="e">This multiarch wrapper is going to be used later on in the book
72 with perl. It will also be very useful outside of the base CLFS system.</para>
73
74 <para os="f">Creating the testcase:</para>
75
76<screen os="g"><userinput>echo 'echo "32bit Version"' &gt; test-32
77echo 'echo "64bit Version"' &gt; test-64
78chmod 755 test-32 test-64
79ln -sv /usr/bin/multiarch_wrapper test</userinput></screen>
80
81 <para os="h">Testing the wrapper:</para>
82
83<screen os="i"><userinput>USE_ARCH=32 ./test
84USE_ARCH=64 ./test</userinput></screen>
85
86 <para os="j">The output of the above command should be:</para>
87
88<screen os="k"><userinput>32bit Version
8964bit Version</userinput></screen>
90
91 </sect2>
92
93 <sect2 id="contents-multiarch-wrapper" role="content">
94 <title>Contents of The Multiarch Wrapper</title>
95
96 <segmentedlist>
97 <segtitle>Installed programs</segtitle>
98
99 <seglistitem>
100 <seg>multiarch_wrapper</seg>
101 </seglistitem>
102 </segmentedlist>
103
104 <variablelist>
105 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
106 <?dbfo list-presentation="list"?>
107 <?dbhtml list-presentation="table"?>
108
109 <varlistentry id="multiarch_wrapper">
110 <term><command>multiarch_wrapper</command></term>
111 <listitem>
112 <para>Will execute a different program based on the
113 <envar>USE_ARCH</envar> variable. The <envar>USE_ARCH</envar>
114 variable will be the suffix of the executed program.</para>
115 <indexterm zone="ch-system-multiarch-wrapper multiarch_wrapper">
116 <primary sortas="b-multiarch_wrapper">multiarch_wrapper</primary>
117 </indexterm>
118 </listitem>
119 </varlistentry>
120
121 </variablelist>
122
123 </sect2>
124
125</sect1>
Note: See TracBrowser for help on using the repository browser.