create-module.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. set -eu
  3. # relative to the script's directory
  4. TREE=..
  5. DEST=module
  6. # make sure we're running in our own directory
  7. if [ -f create-module.sh ]; then :; else
  8. cd $( dirname $0 )
  9. if [ -f create-module.sh ]; then :; else
  10. echo "Please run the script from is directory." >&2
  11. exit 1
  12. fi
  13. fi
  14. # use a temporary directory to build the module, then rsync to DEST
  15. # this allows touching only new files, for more efficient re-builds
  16. TMP=$DEST-tmp
  17. rm -rf $TMP
  18. mkdir -p $TMP/mbedtls $TMP/source
  19. cp $TREE/include/mbedtls/*.h $TMP/mbedtls
  20. cp $TREE/library/*.c $TMP/source
  21. # temporary, should depend on external module later
  22. cp data/entropy_hardware_poll.c $TMP/source
  23. cp data/target_config.h $TMP/mbedtls
  24. data/adjust-config.sh $TREE/scripts/config.pl $TMP/mbedtls/config.h
  25. mkdir -p $TMP/test
  26. cp -r data/example-* $TMP/test
  27. # later we should have the generated test suites here too
  28. cp data/module.json $TMP
  29. cp data/README.md $TMP
  30. cp ../LICENSE $TMP
  31. if [ -f ../apache-2.0.txt ]; then cp ../apache-2.0.txt $TMP; fi
  32. mkdir -p $DEST
  33. rsync -cr --delete --exclude build --exclude yotta_\* $TMP/ $DEST/
  34. rm -rf $TMP
  35. echo "mbed TLS yotta module created in '$PWD/$DEST'."