Advertisement
jimlkosmo

cross2

Sep 2nd, 2020 (edited)
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. linux C libraries:glibc, uclib, musl
  2. binutils: collection of binary tools; ld(linker, links multiple objects into a shared library, an excecutable , or another object file). as(assemlber, produces a binary code object from an assembly txt file). debugging/analysis tools, ranlib...Binutils needs to be configured for the target cpu arch.
  3.  
  4.  
  5.  
  6. #sudo apt install gcc-mips-linux-gnu
  7. #man mips-linux-gnu-gcc
  8. #mips-linux-gnu-gcc --help
  9. #https://shadowllife.wordpress.com/2018/05/04/how-to-cross-compile-openssh/
  10. #https://stackoverflow.com/questions/11841919/cross-compile-openssh-for-arm
  11. #http://papermint-designs.com/dmo-blog/2016-04-having-fun-with-your-home-router
  12. #https://stackoverflow.com/questions/12183433/compile-parameters-for-mips-based-codesourcery-toolchain
  13. ##################################
  14. #Static Builds
  15. If for some reason you want the resulting toolchain binaries to be statically linked, set the following environment variables before running crosstool.sh (or all.sh):
  16.  
  17. BINUTILS_EXTRA_CONFIG="LDFLAGS=-all-static"
  18. GCC_EXTRA_CONFIG="LDFLAGS=-static"
  19. #############################
  20. #http://www.kegel.com/crosstool/
  21. #-static -EB -march=mips32
  22.  
  23.  
  24. #Make a working directory for all the downloads and builds
  25. mkdir /home/$(whoami)/mips
  26. export WORKDIR=/home/$(whoami)/mips
  27.  
  28. #Path of the output folder for the intermediate and the final installs
  29. mkdir /home/$(whoami)/mips/rootfs
  30. export ROOTFS=/home/$(whoami)/mips/rootfs
  31.  
  32. #Download and install cross-compiler
  33. cd $WORKDIR
  34. wget https://sourcery.mentor.com/GNUToolchain/package14486/public/mips-linux-gnu/mips-2016.05-8-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  35. tar -xf mips-2016.05-8-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
  36.  
  37. #GNU Cross-Compiler Bin folder path
  38. export GCC_PATH=/${WORKDIR}/mips-2016.05/bin
  39.  
  40. #Include and Lib paths for the intermediate compiled for the target-system libraries and headers
  41. CFLAGS="-I${ROOTFS}/usr/include" LDFLAGS="-L${ROOTFS}/usr/lib"
  42.  
  43. #Let the system know where the compiler excecutables are
  44. export PATH=${GCC_PATH}:$PATH
  45.  
  46. #Compiler excecutable
  47. export HOST=mips-linux-gnu
  48.  
  49.  
  50. ############################################
  51. # Zlib intermediate cross-compile commands #
  52. ############################################
  53.  
  54. #Download, extract and cross-compile Zlib
  55. cd $WORKDIR
  56. wget https://www.zlib.net/zlib-1.2.11.tar.gz
  57. tar -xvf zlib-1.2.11.tar.gz
  58. cd zlib-1.2.11
  59.  
  60. CC=${HOST}-gcc AR=${HOST}-ar RANLIB=${HOST}-ranlib ./configure --prefix=$ROOTFS/usr
  61. make LDFLAGS="-EB -march=mips32"
  62. make install
  63.  
  64.  
  65.  
  66. #########################
  67. # OPENSSL CROSS COMPILE #
  68. #########################
  69.  
  70. ###this is for runtime library paths search
  71. '-Wl,-rpath,$(LIBRPATH)'
  72. ###
  73.  
  74. ### prefix
  75.  
  76. --prefix=DIR
  77.  
  78. The top of the installation directory tree. Defaults are:
  79.  
  80. Unix: /usr/local
  81.  
  82. ### libdir
  83.  
  84. --libdir=DIR
  85.  
  86. The name of the directory under the top of the installation directory tree
  87. (see the `--prefix` option) where libraries will be installed. By default
  88. this is `lib/`. Note that on Windows only static libraries (`*.lib`) will
  89. be stored in this location. Shared libraries (`*.dll`) will always be
  90. installed to the `bin/` directory.
  91.  
  92. ### openssldir
  93.  
  94. --openssldir=DIR
  95.  
  96. Directory for OpenSSL configuration files, and also the default certificate
  97. and key store. Defaults are:
  98.  
  99. Unix: /usr/local/ssl
  100.  
  101. #Also, note that `--openssldir` refers to target's file system, not one you are
  102. building on.
  103.  
  104.  
  105. #Download Openssh and install
  106. cd $WORKDIR
  107. git clone https://github.com/openssl/openssl
  108. cd openssl
  109.  
  110. #Openssl intermediate cross-compile commands
  111. #makefile: DESTDIR=$ROOTFS
  112.  
  113. ./Configure linux-mips32 shared zlib-dynamic \
  114. --cross-compile-prefix=mips-buildroot-linux-uclibc- \
  115. --prefix=/usr \
  116. --libdir=/usr/lib \
  117. --openssldir=/usr/etc/ssl \
  118. --with-zlib-include=$ROOTFS/usr/include \
  119. --with-zlib-lib=$ROOTFS/usr/lib
  120.  
  121. make CFLAGS="-I${ROOTFS}/usr/include" LDFLAGS="-L${ROOTFS}/usr/lib"
  122. make install
  123.  
  124. #########################
  125. # OPENSSH CROSS COMPILE #
  126. #########################
  127.  
  128. cd $WORKDIR
  129. git clone https://github.com/openssh/openssh-portable
  130. cd openssh-portable
  131.  
  132. #makefile: DESTDIR=$ROOTFS
  133. ./configure \
  134. CC=mips-linux-gnu-gcc AR=mips-linux-gnu-ar \
  135. --host=mips-32 \
  136. --build=i386-pc-linux-gnu \
  137. --prefix=/usr \
  138. --exec-prefix=/usr \
  139. --bindir=/usr/bin \
  140. --sbindir=/usr/sbin \
  141. --libdir=/lib \
  142. --libexecdir=/usr/sbin \
  143. --sysconfdir=/etc \
  144. --datadir=/usr/share \
  145. --localstatedir=/var \
  146. --mandir=/usr/man \
  147. --infodir=/usr/info \
  148. --disable-lastlog --disable-utmp \
  149. --disable-utmpx --disable-wtmp --disable-wtmpx \
  150. --with-libs --with-zlib=${ROOTFS}/usr/lib --with-openssl=${ROOTFS}/usr/lib \
  151. --disable-strip
  152.  
  153. #makefile: delete check-config from install script
  154.  
  155. make && make install
  156.  
  157.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement