Add support for MBEDTLS_USER_CONFIG_FILE
diff --git a/ChangeLog b/ChangeLog
index 62658ac..54d7db6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
= mbed TLS 2 branch
+Features
+ * Added support for yotta as a build system
+
Bugfix
* Fix segfault in the benchmark program when benchmarking DHM.
* Fix build error with CMake and pre-4.5 versions of GCC (found by Hugo
@@ -20,6 +23,9 @@
Changes
* The PEM parser now accepts a trailing space at end of lines (#226).
+ * It is now possible to #include a user-provided configuration file at the
+ end of the default config.h by defining MBEDTLS_USER_CONFIG_FILE on the
+ compiler's command line.
= mbed TLS 2.0.0 released 2015-07-13
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index a17faa1..8283702 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -2425,6 +2425,19 @@
#include "mbedtls/target_config.h"
#endif
+/*
+ * Allow user to override any previous default.
+ *
+ * Use two macro names for that, as:
+ * - with yotta the prefix YOTTA_CFG_ is forced
+ * - without yotta is looks weird to have a YOTTA prefix.
+ */
+#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE)
+#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE
+#elif defined(MBEDTLS_USER_CONFIG_FILE)
+#include MBEDTLS_USER_CONFIG_FILE
+#endif
+
#include "check_config.h"
#endif /* MBEDTLS_CONFIG_H */
diff --git a/tests/scripts/check-names.sh b/tests/scripts/check-names.sh
index ed65306..7e67cef 100755
--- a/tests/scripts/check-names.sh
+++ b/tests/scripts/check-names.sh
@@ -56,7 +56,7 @@
$HEADERS library/*.c \
| grep MBEDTLS | sort -u > _MBEDTLS_XXX
TYPOS=$( diff _caps _MBEDTLS_XXX | sed -n 's/^> //p' \
- | egrep -v 'XXX|__|_$|^MBEDTLS_CONFIG_FILE$' || true )
+ | egrep -v 'XXX|__|_$|^MBEDTLS_.*CONFIG_FILE$' || true )
rm _MBEDTLS_XXX _caps
if [ "x$TYPOS" = "x" ]; then
echo "PASS"
diff --git a/yotta/data/README.md b/yotta/data/README.md
index 577d85a..9e3618e 100644
--- a/yotta/data/README.md
+++ b/yotta/data/README.md
@@ -20,6 +20,22 @@
Please follow the instructions in the [TLS client sample](https://github.com/ARMmbed/mbedtls/tree/master/yotta/data/example-tls-client). These include a list of prerequisites and an explanation of building mbed TLS with yotta.
+## Configuring mbed TLS features
+
+**Warning:** This is only a preview of a future feature that will require support from yotta; as of yotta 0.5.2 this is not supported yet.
+
+mbed TLS makes it easy to disable during the compilation any feature that is not needed for a particular project. The default configuration enables all modern and widely-used features, which should meet the need of any new project; it disables all features that are either older or less mainstrem, in order to keep the footprint low. The list of available compile flags is available in the fully documented [config.h file](https://github.com/ARMmbed/mbedtls/blob/master/include/mbedtls/config.h), present in the `mbedtls` directory of the yotta module.
+
+Should you need to adjust those flags, you can provide your own configuration file with the suitable `#define` and `#undef` statements, to be included between the default definitions and the sanity checks. This file should be in your application's include directory and can be named freely; you just need to let mbed TLS know the name of the file, by using yotta's [configuration system](http://docs.yottabuild.org/reference/config.html). This name should go in your `config.json`, under mbedtls, as the key `user-config-file`, for example:
+
+ {
+ "mbedtls": {
+ "user-config-file": "\"myapp/my_mbedtls_config_changes.h\""
+ }
+ }
+
+Please note you need to provide the exact name that will be used in the `#include` directive, including the `<>` or quotes around the name.
+
## Contributing
We graciously accept bugs and contributions from the community. There are some requirements we need to fulfil in order to be able to integrate contributions in the main code: