6 echo " -buildroot <path to buildroot>"
7 echo " -lib \"<list of additional libraries to link in compile>\""
11 # define the path to the buildroot
23 buildroot|-buildroot|--buildroot)
33 -d|--d|debug|-debug|--debug)
37 -h|--h|help|-help|--help)
42 echo "ERROR: Invalid Argument: $1"
49 # check to ensure correct arguments
50 if [ "$BUILDROOT_PATH" = "" ]
52 echo "ERROR: missing path to buildroot"
59 # define the toolchain and target names
60 #TOOLCHAIN_NAME="toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16"
61 TOOLCHAIN_NAME="toolchain-mipsel_24kc_gcc-5.5.0_musl"
62 TARGET_NAME="target-mipsel_24kc_musl"
64 # define the relative paths
65 STAGING_DIR_RELATIVE="staging_dir"
66 TOOLCHAIN_RELATIVE="$STAGING_DIR_RELATIVE/$TOOLCHAIN_NAME"
67 TARGET_RELATIVE="$STAGING_DIR_RELATIVE/$TARGET_NAME"
69 # define the toolchain paths
70 TOOLCHAIN="$BUILDROOT_PATH/$TOOLCHAIN_RELATIVE"
71 TOOLCHAIN_BIN="$BUILDROOT_PATH/$TOOLCHAIN_RELATIVE/bin"
73 TOOLCHAIN_INCLUDE="$BUILDROOT_PATH/$TOOLCHAIN_RELATIVE/include"
74 TOOLCHAIN_LIB="$BUILDROOT_PATH/$TOOLCHAIN_RELATIVE/lib"
75 TOOLCHAIN_USR_INCLUDE="$BUILDROOT_PATH/$TOOLCHAIN_RELATIVE/usr/include"
76 TOOLCHAIN_USR_LIB="$BUILDROOT_PATH/$TOOLCHAIN_RELATIVE/usr/lib"
78 # define the target paths
79 TARGET="$BUILDROOT_PATH/$TARGET_RELATIVE"
81 TARGET_INCLUDE="$BUILDROOT_PATH/$TARGET_RELATIVE/include"
82 TARGET_LIB="$BUILDROOT_PATH/$TARGET_RELATIVE/lib"
83 TARGET_USR_INCLUDE="$BUILDROOT_PATH/$TARGET_RELATIVE/usr/include"
84 TARGET_USR_LIB="$BUILDROOT_PATH/$TARGET_RELATIVE/usr/lib"
86 export STAGING_DIR="BUILDROOT_PATH/$STAGING_DIR_RELATIVE"
88 # define the compilers and such
89 TOOLCHAIN_CC="$TOOLCHAIN_BIN/mipsel-openwrt-linux-gcc"
90 TOOLCHAIN_CXX="$TOOLCHAIN_BIN/mipsel-openwrt-linux-g++"
91 TOOLCHAIN_LD="$TOOLCHAIN_BIN/mipsel-openwrt-linux-ld"
93 TOOLCHAIN_AR="$TOOLCHAIN_BIN/mipsel-openwrt-linux-ar"
94 TOOLCHAIN_RANLIB="$TOOLCHAIN_BIN/mipsel-openwrt-linux-ranlib"
97 INCLUDE_LINES="-I $TOOLCHAIN_USR_INCLUDE -I $TOOLCHAIN_INCLUDE -I $TARGET_USR_INCLUDE -I $TARGET_INCLUDE"
98 TOOLCHAIN_CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro"
99 #TOOLCHAIN_CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -fpic"
100 TOOLCHAIN_CFLAGS="$TOOLCHAIN_CFLAGS $INCLUDE_LINES"
102 TOOLCHAIN_CXXFLAGS="$TOOLCHAIN_CFLAGS"
103 #TOOLCHAIN_CXXFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -fpic"
104 TOOLCHAIN_CXXFLAGS="$TOOLCHAIN_CXXFLAGS $INCLUDE_LINES"
106 TOOLCHAIN_LDFLAGS="-L$TOOLCHAIN_USR_LIB -L$TOOLCHAIN_LIB -L$TARGET_USR_LIB -L$TARGET_LIB"
109 if [ $bDebug -eq 1 ]; then
110 echo "CC=$TOOLCHAIN_CC"
111 echo "CXX=$TOOLCHAIN_CXX"
112 echo "LD=$TOOLCHAIN_LD"
113 echo "CFLAGS=$TOOLCHAIN_CFLAGS"
114 echo "LDFLAGS=$TOOLCHAIN_LDFLAGS"
115 echo "USER_LIBS=$USER_LIBS"
120 # first run make clean
123 # run the make command
126 CXX="$TOOLCHAIN_CXX" \
128 CFLAGS="$TOOLCHAIN_CFLAGS" \
129 LDFLAGS="$TOOLCHAIN_LDFLAGS" \