makedistsmall.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. rm -rf ./Docker
  40. # these use test.h, which are not portable
  41. rm -rf ./examples
  42. rm -rf ./IDE
  43. rm -rf ./IPP
  44. rm -rf ./lib
  45. rm -rf ./linuxkm
  46. rm -rf ./m4
  47. rm -rf ./mcapi
  48. rm -rf ./mplabx
  49. rm -rf ./mqx
  50. rm -rf ./rpm
  51. rm -rf ./RTOS
  52. rm -rf ./scripts
  53. rm -rf ./sslSniffer
  54. rm -rf ./swig
  55. rm -rf ./tests
  56. rm -rf ./testsuite
  57. rm -rf ./tirtos
  58. rm -rf ./wolfcrypt/user-crypto
  59. rm -rf ./wrapper
  60. rm -f -- *.rc *.supp *.ac *.am *.conf *.sh *.cproject *.project *.pl
  61. rm -f Vagrantfile SCRIPTS-LIST quit input resource.h
  62. find . -name "*.am" -delete
  63. find . -name "*.vcxproj" -delete
  64. find . -name "*.vcproj" -delete
  65. find . -name "*.sln" -delete
  66. # TLS/Compatiblity layer
  67. #rm -rf ./src
  68. #rm -rf ./wolfssl/openssl
  69. # wolfCrypt
  70. #rm -f ./wolfcrypt/src/*.i
  71. #rm -f ./wolfcrypt/src/*.S
  72. #rm -f ./wolfcrypt/src/*.asm
  73. #rm -f ./wolfcrypt/src/arc4.c
  74. #rm -f ./wolfcrypt/src/async.c
  75. #rm -f ./wolfcrypt/src/blake*
  76. #rm -f ./wolfcrypt/src/camellia.c
  77. #rm -f ./wolfcrypt/src/chacha*
  78. #rm -f ./wolfcrypt/src/compress.c
  79. #rm -f ./wolfcrypt/src/cpuid.c
  80. #rm -f ./wolfcrypt/src/curve*
  81. #rm -f ./wolfcrypt/src/cryptocb.c
  82. #rm -f ./wolfcrypt/src/dsa.c
  83. #rm -f ./wolfcrypt/src/ed*
  84. #rm -f ./wolfcrypt/src/evp.c
  85. #rm -f ./wolfcrypt/src/fe*
  86. #rm -f ./wolfcrypt/src/ge*
  87. #rm -f ./wolfcrypt/src/md*.c
  88. #rm -f ./wolfcrypt/src/pkcs*
  89. #rm -f ./wolfcrypt/src/poly*
  90. #rm -f ./wolfcrypt/src/pwdbased.c
  91. #rm -f ./wolfcrypt/src/rc2.c
  92. #rm -f ./wolfcrypt/src/ripemd.c
  93. #rm -f ./wolfcrypt/src/rabbit.c
  94. #rm -f ./wolfcrypt/src/signature.c
  95. #rm -f ./wolfcrypt/src/srp.c
  96. #rm -f ./wolfcrypt/src/wc_dsp.c
  97. #rm -f ./wolfcrypt/src/wolfevent.c
  98. #rm -f ./wolfcrypt/src/wc_encrypt.c
  99. #rm -f ./wolfcrypt/src/wc_pkcs11.c
  100. # SP Math files
  101. #rm -f ./wolfcrypt/src/sp_arm32.c
  102. #rm -f ./wolfcrypt/src/sp_arm64.c
  103. #rm -f ./wolfcrypt/src/sp_armthumb.c
  104. #rm -f ./wolfcrypt/src/sp_cortexm.c
  105. #rm -f ./wolfcrypt/src/sp_dsp32.c
  106. #rm -f ./wolfcrypt/src/sp_x86_64.c
  107. # wolfCrypt Ports
  108. rm -rf ./wolfcrypt/src/port
  109. rm -rf ./wolfssl/wolfcrypt/port
  110. # Setup blank options.h
  111. cp ./wolfssl/options.h.in ./wolfssl/options.h || exit $?
  112. cp ./wolfcrypt/test/test_paths.h.in ./wolfcrypt/test/test_paths.h || exit $?
  113. popd >/dev/null || exit $?
  114. echo "Generating wolfssl-${WOLFSSL_VERSION}-small.tar.gz..."
  115. tar zcf "wolfssl-${WOLFSSL_VERSION}-small.tar.gz" -C "$WOLFSSL_TEMPDIR" . || exit $?
  116. echo "Done"