1
0

makedistsmall.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/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. function cleanup_on_exit() {
  10. if [ "$KEEP" == "no" ];
  11. then
  12. echo "Removing tmp directory"
  13. rm -rf "$WOLFSSL_TEMPDIR"
  14. else
  15. echo "tmp directory ${WOLFSSL_TEMPDIR} left in place."
  16. fi
  17. }
  18. trap cleanup_on_exit EXIT
  19. WOLFSSL_VERSION=$(grep -Eo '[0-9]\.[0-9]\.[0-9]+' wolfssl/version.h)
  20. if [ -n "$WOLFSSL_VERSION" ]; then
  21. echo "Detected wolfSSL Version $WOLFSSL_VERSION"
  22. else
  23. echo "Couldn't detect wolfSSL version."
  24. exit 1
  25. fi
  26. # generate a wolfSSL archive with minimum sources
  27. echo "Setting up work directory..."
  28. git clone -q -n --shared . "$WOLFSSL_TEMPDIR" || exit $?
  29. pushd "$WOLFSSL_TEMPDIR" >/dev/null || exit $?
  30. git checkout -q master || exit $?
  31. # cleanup example directories
  32. echo "Removing files not needed..."
  33. rm -rf -- ./.git*
  34. rm -rf ./build-aux
  35. rm -rf ./certs
  36. rm -rf ./ctaocrypt
  37. rm -rf ./cyassl
  38. rm -rf ./doc
  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 ./scripts
  51. rm -rf ./sslSniffer
  52. rm -rf ./swig
  53. rm -rf ./tests
  54. rm -rf ./testsuite
  55. rm -rf ./tirtos
  56. rm -rf ./wolfcrypt/user-crypto
  57. rm -rf ./wrapper
  58. rm -rf ./zephyr
  59. rm -f -- *.rc *.supp *.ac *.am *.conf *.sh *.cproject *.project *.pl
  60. rm -f Vagrantfile SCRIPTS-LIST quit input resource.h
  61. find . -name "*.am" -delete
  62. find . -name "*.vcxproj" -delete
  63. find . -name "*.vcproj" -delete
  64. find . -name "*.sln" -delete
  65. # TLS/Compatiblity layer
  66. #rm -rf ./src
  67. #rm -rf ./wolfssl/openssl
  68. # wolfCrypt
  69. #rm -f ./wolfcrypt/src/*.i
  70. #rm -f ./wolfcrypt/src/*.S
  71. #rm -f ./wolfcrypt/src/*.asm
  72. #rm -f ./wolfcrypt/src/arc4.c
  73. #rm -f ./wolfcrypt/src/async.c
  74. #rm -f ./wolfcrypt/src/blake*
  75. #rm -f ./wolfcrypt/src/camellia.c
  76. #rm -f ./wolfcrypt/src/chacha*
  77. #rm -f ./wolfcrypt/src/compress.c
  78. #rm -f ./wolfcrypt/src/cpuid.c
  79. #rm -f ./wolfcrypt/src/curve*
  80. #rm -f ./wolfcrypt/src/cryptocb.c
  81. #rm -f ./wolfcrypt/src/dsa.c
  82. #rm -f ./wolfcrypt/src/ed*
  83. #rm -f ./wolfcrypt/src/evp.c
  84. #rm -f ./wolfcrypt/src/fe*
  85. #rm -f ./wolfcrypt/src/ge*
  86. #rm -f ./wolfcrypt/src/md*.c
  87. #rm -f ./wolfcrypt/src/pkcs*
  88. #rm -f ./wolfcrypt/src/poly*
  89. #rm -f ./wolfcrypt/src/pwdbased.c
  90. #rm -f ./wolfcrypt/src/rc2.c
  91. #rm -f ./wolfcrypt/src/ripemd.c
  92. #rm -f ./wolfcrypt/src/rabbit.c
  93. #rm -f ./wolfcrypt/src/signature.c
  94. #rm -f ./wolfcrypt/src/srp.c
  95. #rm -f ./wolfcrypt/src/wc_dsp.c
  96. #rm -f ./wolfcrypt/src/wolfevent.c
  97. #rm -f ./wolfcrypt/src/wc_encrypt.c
  98. #rm -f ./wolfcrypt/src/wc_pkcs11.c
  99. # SP Math files
  100. #rm -f ./wolfcrypt/src/sp_arm32.c
  101. #rm -f ./wolfcrypt/src/sp_arm64.c
  102. #rm -f ./wolfcrypt/src/sp_armthumb.c
  103. #rm -f ./wolfcrypt/src/sp_cortexm.c
  104. #rm -f ./wolfcrypt/src/sp_dsp32.c
  105. #rm -f ./wolfcrypt/src/sp_x86_64.c
  106. # wolfCrypt Ports
  107. rm -rf ./wolfcrypt/src/port
  108. rm -rf ./wolfssl/wolfcrypt/port
  109. # Setup blank options.h
  110. cp ./wolfssl/options.h.in ./wolfssl/options.h || exit $?
  111. cp ./wolfcrypt/test/test_paths.h.in ./wolfcrypt/test/test_paths.h || exit $?
  112. popd >/dev/null || exit $?
  113. echo "Generating wolfssl-${WOLFSSL_VERSION}-small.tar.gz..."
  114. tar zcf "wolfssl-${WOLFSSL_VERSION}-small.tar.gz" -C "$WOLFSSL_TEMPDIR" . || exit $?
  115. echo "Done"