%general-entities; ]> Creating a Multiarch Wrapper Multiarch Wrapper <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 Create the source file: cat > multiarch_wrapper.c << "EOF" #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <string.h> #ifndef USE_ARCH #define USE_ARCH "64" #endif int main(int argc, char **argv) { char *filename; char *use_arch; if(!(use_arch = getenv("USE_ARCH"))) use_arch = USE_ARCH; filename = (char *) malloc(strlen(argv[0]) + strlen(use_arch) + 2); strcpy(filename, argv[0]); strcat(filename, "-"); strcat(filename, use_arch); execvp(filename, argv); perror(argv[0]); free(filename); } EOF Compile and Install the Multiarch Wrapper: gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper 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. Create a testcase: 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 Test the wrapper: USE_ARCH=32 ./test USE_ARCH=64 ./test The output of the above command should be: 32bit Version 64bit Version Contents of The Multiarch Wrapper Installed programs multiarch_wrapper Short Descriptions multiarch_wrapper Will execute a different program based on the USE_ARCH variable. The USE_ARCH variable will be the suffix of the executed program. multiarch_wrapper