1
0

makedistsmall.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/usr/bin/env bash
  2. #set -v
  3. # Script to produce a small source/header only package (with CMake support)
  4. # Run this script from the wolfSSL root as `./scripts/makedistsmall.sh`.
  5. # Package requires building with:
  6. # cmake .. -DWOLFSSL_EXAMPLES=no -DWOLFSSL_FILESYSTEM=no
  7. if [ "$1" == "keep" ]; then KEEP="yes"; else KEEP="no"; fi
  8. WOLFSSL_TEMPDIR=$(mktemp -d) || exit $?
  9. WOLFSSL_BRANCH=$(git symbolic-ref --short HEAD)
  10. function cleanup_on_exit() {
  11. if [ "$KEEP" == "no" ];
  12. then
  13. echo "Removing tmp directory"
  14. rm -rf "$WOLFSSL_TEMPDIR"
  15. else
  16. echo "tmp directory ${WOLFSSL_TEMPDIR} left in place."
  17. fi
  18. }
  19. trap cleanup_on_exit EXIT
  20. WOLFSSL_VERSION=$(grep -Eo '[0-9]\.[0-9]\.[0-9]+' wolfssl/version.h)
  21. if [ -n "$WOLFSSL_VERSION" ]; then
  22. echo "Detected wolfSSL Version $WOLFSSL_VERSION"
  23. else
  24. echo "Couldn't detect wolfSSL version."
  25. exit 1
  26. fi
  27. # generate a wolfSSL archive with minimum sources
  28. echo "Setting up work directory..."
  29. git clone -q -n --shared . "$WOLFSSL_TEMPDIR" || exit $?
  30. pushd "$WOLFSSL_TEMPDIR" >/dev/null || exit $?
  31. git checkout -q "$WOLFSSL_BRANCH"
  32. # cleanup example directories
  33. echo "Removing files not needed..."
  34. rm -rf -- ./.git*
  35. rm -rf ./build-aux
  36. rm -rf ./certs
  37. rm -rf ./doc
  38. rm -rf ./Docker
  39. # these use test.h, which are not portable
  40. rm -rf ./examples
  41. rm -rf ./IDE
  42. rm -rf ./IPP
  43. rm -rf ./lib
  44. rm -rf ./linuxkm
  45. rm -rf ./m4
  46. rm -rf ./mcapi
  47. rm -rf ./mplabx
  48. rm -rf ./mqx
  49. rm -rf ./rpm
  50. rm -rf ./RTOS
  51. rm -rf ./scripts
  52. rm -rf ./sslSniffer
  53. rm -rf ./swig
  54. rm -rf ./tests
  55. rm -rf ./testsuite
  56. rm -rf ./tirtos
  57. rm -rf ./wrapper
  58. rm -f -- *.rc *.supp *.ac *.am *.conf *.sh *.cproject *.project *.pl
  59. rm -f Vagrantfile SCRIPTS-LIST quit input resource.h
  60. find . -name "*.am" -delete
  61. find . -name "*.vcxproj" -delete
  62. find . -name "*.vcproj" -delete
  63. find . -name "*.sln" -delete
  64. # TLS/Compatibility layer
  65. #rm -rf ./src
  66. #rm -rf ./wolfssl/openssl
  67. # wolfCrypt
  68. #rm -f ./wolfcrypt/src/*.i
  69. #rm -f ./wolfcrypt/src/*.S
  70. #rm -f ./wolfcrypt/src/*.asm
  71. #rm -f ./wolfcrypt/src/arc4.c
  72. #rm -f ./wolfcrypt/src/async.c
  73. #rm -f ./wolfcrypt/src/blake*
  74. #rm -f ./wolfcrypt/src/camellia.c
  75. #rm -f ./wolfcrypt/src/chacha*
  76. #rm -f ./wolfcrypt/src/compress.c
  77. #rm -f ./wolfcrypt/src/cpuid.c
  78. #rm -f ./wolfcrypt/src/curve*
  79. #rm -f ./wolfcrypt/src/cryptocb.c
  80. #rm -f ./wolfcrypt/src/dsa.c
  81. #rm -f ./wolfcrypt/src/ed*
  82. #rm -f ./wolfcrypt/src/evp.c
  83. #rm -f ./wolfcrypt/src/fe*
  84. #rm -f ./wolfcrypt/src/ge*
  85. #rm -f ./wolfcrypt/src/md*.c
  86. #rm -f ./wolfcrypt/src/pkcs*
  87. #rm -f ./wolfcrypt/src/poly*
  88. #rm -f ./wolfcrypt/src/pwdbased.c
  89. #rm -f ./wolfcrypt/src/rc2.c
  90. #rm -f ./wolfcrypt/src/ripemd.c
  91. #rm -f ./wolfcrypt/src/rabbit.c
  92. #rm -f ./wolfcrypt/src/signature.c
  93. #rm -f ./wolfcrypt/src/srp.c
  94. #rm -f ./wolfcrypt/src/wc_dsp.c
  95. #rm -f ./wolfcrypt/src/wolfevent.c
  96. #rm -f ./wolfcrypt/src/wc_encrypt.c
  97. #rm -f ./wolfcrypt/src/wc_pkcs11.c
  98. # SP Math files
  99. #rm -f ./wolfcrypt/src/sp_arm32.c
  100. #rm -f ./wolfcrypt/src/sp_arm64.c
  101. #rm -f ./wolfcrypt/src/sp_armthumb.c
  102. #rm -f ./wolfcrypt/src/sp_cortexm.c
  103. #rm -f ./wolfcrypt/src/sp_dsp32.c
  104. #rm -f ./wolfcrypt/src/sp_x86_64.c
  105. # wolfCrypt Ports
  106. rm -rf ./wolfcrypt/src/port
  107. rm -rf ./wolfssl/wolfcrypt/port
  108. # Setup blank options.h
  109. cp ./wolfssl/options.h.in ./wolfssl/options.h || exit $?
  110. cp ./wolfcrypt/test/test_paths.h.in ./wolfcrypt/test/test_paths.h || exit $?
  111. popd >/dev/null || exit $?
  112. echo "Generating wolfssl-${WOLFSSL_VERSION}-small.tar.gz..."
  113. tar zcf "wolfssl-${WOLFSSL_VERSION}-small.tar.gz" -C "$WOLFSSL_TEMPDIR" . || exit $?
  114. echo "Done"