adde88

OpenWRT Developing stuff

Oct 20th, 2020
1,004
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Some bash functions to make the life of an openwrt developer easier.
  2. # Andreas Nilsen <adde88@gmail.com>
  3.  
  4. export SDKDIR='/root/openwrt'
  5. export CC_SDKDIR='/root/openwrt-sdk'
  6.  
  7. function opkgrm() { rm -rf ./dl/"$1"* && rm -rf ./build_dir/target-*/"$1"*; }
  8.  
  9. function opkgccmake() {
  10.         export DIR="/root/gits/openwrt-useful-tools-15.05/"
  11.         opkgrm "$1"
  12.         make package/"$1"/{clean,download,prepare,compile,install} package/index -j`nproc` V=s
  13.         echo -e '\nCompilation finished!\n'
  14.         find `pwd`/bin -name '"$1"*.ipk'
  15.         export FILE="`pwd`/`find bin -name '"$1"*.ipk'`"
  16.         [ -f "$FILE" ] && { cp "$FILE" "$DIR" ; echo -e 'Package successfully copied to: '"$DIR"''; } || echo -e 'Something went wrong. Compilation failed!'
  17.         echo -e "$FILE\n"
  18. }
  19.  
  20. function opkgmake() {
  21.     export DIR="/root/gits/openwrt-useful-tools/"
  22.     opkgrm "$1"
  23.     make package/"$1"/{clean,download,prepare,compile} package/index -j`nproc` V=s
  24.     echo -e '\nCompilation finished!\n'
  25.     find `pwd`/bin -name '"$1"*.ipk'
  26.     export FILE="`pwd`/`find bin -name "$1"*.ipk`"
  27.     [ -f "$FILE" ] && { cp "$FILE" "$DIR" ; echo -e 'Package successfully copied to: '"$DIR"''; } || echo -e 'Something went wrong. Compilation failed!'
  28.     echo -e "$FILE\n"
  29. }
  30.  
  31. # Here comes some functions to use the OpenWRT's toolchain to compile stuff outside the SDK environment
  32.  
  33. alias wrt-make='\
  34.        CXXFLAGS="-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" \
  35.        ARCH='mips' \
  36.        CROSS='mips-openwrt-linux-musl-' \
  37.        CC='"$CROSS"gcc' \
  38.        LD='"$CROSS"ld' \
  39.        AR='"$CROSS"ar' \
  40.        CXX='"$CROSS"g++' \
  41.        GCC='"$CROSS"gcc' \
  42.        AS='"$CROSS"as' \
  43.        NM='"$CROSS"nm' \
  44.        RANLIB='"$CROSS"ranlib' \
  45.        STRIP='"$CROSS"strip' \
  46.        OBJCOPY='"$CROSS"objcopy' \
  47.        OBJDUMP='"$CROSS"objdump' \
  48.        CFLAGS="-I"$SDKDIR"/staging_dir/target-mips_24kc_musl/usr/include" \
  49.        LDFLAGS="-L"$SDKDIR"/staging_dir/target-mips_24kc_musl/usr/lib" \
  50.        make -j`nproc` \
  51. '
  52.  
  53. alias wrt-make-cc='\
  54.        ARCH='mips' \
  55.        CROSS='mips-openwrt-linux-uclibc-' \
  56.        CC='"$CROSS"gcc' \
  57.        LD='"$CROSS"ld' \
  58.        AR='"$CROSS"ar' \
  59.        CXX='"$CROSS"g++' \
  60.        GCC='"$CROSS"gcc' \
  61.        AS='"$CROSS"as' \
  62.        NM='"$CROSS"nm' \
  63.        RANLIB='"$CROSS"ranlib' \
  64.        STRIP='"$CROSS"strip' \
  65.        OBJCOPY='"$CROSS"objcopy' \
  66.        OBJDUMP='"$CROSS"objdump' \
  67.        CFLAGS="-I"$CC_SDKDIR"/staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr/include -std=gnu99" \
  68.        LDFLAGS="-L"$CC_SDKDIR"/staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr/lib" \
  69.        make -j`nproc` \
  70. '
  71.  
RAW Paste Data