source: BOOK/final-system/multilib/multiarch_wrapper.xml@ d018b81

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since d018b81 was 32c37aa8, checked in by Joe Ciccone <jciccone@…>, 18 years ago

Add role="nodump" tags so jhalfs will not error. Thanks SkateScout.

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[5accd22]1<?xml version="1.0" encoding="ISO-8859-1"?>
[aa18ac0]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[5accd22]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
[72ed305]11 <title>Creating a Multiarch Wrapper</title>
[5accd22]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"
[5fb43ca]31#include &lt;unistd.h&gt;
[5accd22]32#include &lt;stdlib.h&gt;
33#include &lt;errno.h&gt;
[5fb43ca]34#include &lt;string.h&gt;
[5accd22]35
[84cd165]36#ifndef USE_ARCH
37#define USE_ARCH "64"
[5accd22]38#endif
39
[5fb43ca]40int main(int argc, char **argv)
[5accd22]41{
[5fb43ca]42 char *filename;
[5accd22]43 char *use_arch;
44
[5fb43ca]45 if(!(use_arch = getenv("USE_ARCH")))
[84cd165]46 use_arch = USE_ARCH;
[5fb43ca]47
48 filename = (char *) malloc(strlen(argv[0]) + strlen(use_arch) + 2);
[5accd22]49 strcpy(filename, argv[0]);
50 strcat(filename, "-");
51 strcat(filename, use_arch);
52
[5fb43ca]53 execvp(filename, argv);
54 perror(argv[0]);
[5accd22]55 free(filename);
56}
57EOF</userinput></screen>
58
59 <para os="c">Compile and Install the Multiarch Wrapper:</para>
60
61<screen os="d"><userinput>gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper</userinput></screen>
62
63 <para os="e">This multiarch wrapper is going to be used later on in the book
[a7fa075]64 with Perl. It will also be very useful outside of the base CLFS system.</para>
[5accd22]65
[a7fa075]66 <para os="f">Create a testcase:</para>
[5accd22]67
68<screen os="g"><userinput>echo 'echo "32bit Version"' &gt; test-32
69echo 'echo "64bit Version"' &gt; test-64
70chmod 755 test-32 test-64
71ln -sv /usr/bin/multiarch_wrapper test</userinput></screen>
72
[a7fa075]73 <para os="h">Test the wrapper:</para>
[5accd22]74
75<screen os="i"><userinput>USE_ARCH=32 ./test
76USE_ARCH=64 ./test</userinput></screen>
77
78 <para os="j">The output of the above command should be:</para>
79
[32c37aa8]80<screen os="k" role="nodump"><userinput>32bit Version
[5accd22]8164bit Version</userinput></screen>
82
83 </sect2>
84
85 <sect2 id="contents-multiarch-wrapper" role="content">
86 <title>Contents of The Multiarch Wrapper</title>
87
88 <segmentedlist>
89 <segtitle>Installed programs</segtitle>
90
91 <seglistitem>
92 <seg>multiarch_wrapper</seg>
93 </seglistitem>
94 </segmentedlist>
95
96 <variablelist>
97 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
98 <?dbfo list-presentation="list"?>
99 <?dbhtml list-presentation="table"?>
100
101 <varlistentry id="multiarch_wrapper">
102 <term><command>multiarch_wrapper</command></term>
103 <listitem>
104 <para>Will execute a different program based on the
105 <envar>USE_ARCH</envar> variable. The <envar>USE_ARCH</envar>
106 variable will be the suffix of the executed program.</para>
107 <indexterm zone="ch-system-multiarch-wrapper multiarch_wrapper">
108 <primary sortas="b-multiarch_wrapper">multiarch_wrapper</primary>
109 </indexterm>
110 </listitem>
111 </varlistentry>
112
113 </variablelist>
114
115 </sect2>
116
117</sect1>
Note: See TracBrowser for help on using the repository browser.