Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- linux C libraries:glibc, uclib, musl
- 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.
- #sudo apt install gcc-mips-linux-gnu
- #man mips-linux-gnu-gcc
- #mips-linux-gnu-gcc --help
- #https://shadowllife.wordpress.com/2018/05/04/how-to-cross-compile-openssh/
- #https://stackoverflow.com/questions/11841919/cross-compile-openssh-for-arm
- #http://papermint-designs.com/dmo-blog/2016-04-having-fun-with-your-home-router
- #https://stackoverflow.com/questions/12183433/compile-parameters-for-mips-based-codesourcery-toolchain
- ##################################
- #Static Builds
- 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):
- BINUTILS_EXTRA_CONFIG="LDFLAGS=-all-static"
- GCC_EXTRA_CONFIG="LDFLAGS=-static"
- #############################
- #http://www.kegel.com/crosstool/
- #-static -EB -march=mips32
- #Make a working directory for all the downloads and builds
- mkdir /home/$(whoami)/mips
- export WORKDIR=/home/$(whoami)/mips
- #Path of the output folder for the intermediate and the final installs
- mkdir /home/$(whoami)/mips/rootfs
- export ROOTFS=/home/$(whoami)/mips/rootfs
- #Download and install cross-compiler
- cd $WORKDIR
- wget https://sourcery.mentor.com/GNUToolchain/package14486/public/mips-linux-gnu/mips-2016.05-8-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
- tar -xf mips-2016.05-8-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2
- #GNU Cross-Compiler Bin folder path
- export GCC_PATH=/${WORKDIR}/mips-2016.05/bin
- #Include and Lib paths for the intermediate compiled for the target-system libraries and headers
- CFLAGS="-I${ROOTFS}/usr/include" LDFLAGS="-L${ROOTFS}/usr/lib"
- #Let the system know where the compiler excecutables are
- export PATH=${GCC_PATH}:$PATH
- #Compiler excecutable
- export HOST=mips-linux-gnu
- ############################################
- # Zlib intermediate cross-compile commands #
- ############################################
- #Download, extract and cross-compile Zlib
- cd $WORKDIR
- wget https://www.zlib.net/zlib-1.2.11.tar.gz
- tar -xvf zlib-1.2.11.tar.gz
- cd zlib-1.2.11
- CC=${HOST}-gcc AR=${HOST}-ar RANLIB=${HOST}-ranlib ./configure --prefix=$ROOTFS/usr
- make LDFLAGS="-EB -march=mips32"
- make install
- #########################
- # OPENSSL CROSS COMPILE #
- #########################
- ###this is for runtime library paths search
- '-Wl,-rpath,$(LIBRPATH)'
- ###
- ### prefix
- --prefix=DIR
- The top of the installation directory tree. Defaults are:
- Unix: /usr/local
- ### libdir
- --libdir=DIR
- The name of the directory under the top of the installation directory tree
- (see the `--prefix` option) where libraries will be installed. By default
- this is `lib/`. Note that on Windows only static libraries (`*.lib`) will
- be stored in this location. Shared libraries (`*.dll`) will always be
- installed to the `bin/` directory.
- ### openssldir
- --openssldir=DIR
- Directory for OpenSSL configuration files, and also the default certificate
- and key store. Defaults are:
- Unix: /usr/local/ssl
- #Also, note that `--openssldir` refers to target's file system, not one you are
- building on.
- #Download Openssh and install
- cd $WORKDIR
- git clone https://github.com/openssl/openssl
- cd openssl
- #Openssl intermediate cross-compile commands
- #makefile: DESTDIR=$ROOTFS
- ./Configure linux-mips32 shared zlib-dynamic \
- --cross-compile-prefix=mips-buildroot-linux-uclibc- \
- --prefix=/usr \
- --libdir=/usr/lib \
- --openssldir=/usr/etc/ssl \
- --with-zlib-include=$ROOTFS/usr/include \
- --with-zlib-lib=$ROOTFS/usr/lib
- make CFLAGS="-I${ROOTFS}/usr/include" LDFLAGS="-L${ROOTFS}/usr/lib"
- make install
- #########################
- # OPENSSH CROSS COMPILE #
- #########################
- cd $WORKDIR
- git clone https://github.com/openssh/openssh-portable
- cd openssh-portable
- #makefile: DESTDIR=$ROOTFS
- ./configure \
- CC=mips-linux-gnu-gcc AR=mips-linux-gnu-ar \
- --host=mips-32 \
- --build=i386-pc-linux-gnu \
- --prefix=/usr \
- --exec-prefix=/usr \
- --bindir=/usr/bin \
- --sbindir=/usr/sbin \
- --libdir=/lib \
- --libexecdir=/usr/sbin \
- --sysconfdir=/etc \
- --datadir=/usr/share \
- --localstatedir=/var \
- --mandir=/usr/man \
- --infodir=/usr/info \
- --disable-lastlog --disable-utmp \
- --disable-utmpx --disable-wtmp --disable-wtmpx \
- --with-libs --with-zlib=${ROOTFS}/usr/lib --with-openssl=${ROOTFS}/usr/lib \
- --disable-strip
- #makefile: delete check-config from install script
- make && make install
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement