blob: ffa3aa04f4af915df74e3dabf3eb8c8876483f47 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001
2DESTDIR=/usr/local
Manuel Pégourié-Gonnard52859702015-01-27 14:05:16 +01003PREFIX=mbedtls_
Paul Bakker5121ce52009-01-03 21:22:43 +00004
5.SILENT:
6
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +02007.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
Paul Bakker5121ce52009-01-03 21:22:43 +00008
Andres AG7aa5fa12016-08-25 16:36:16 +01009all: programs tests
10 $(MAKE) post_build
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020011
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020012no_test: programs
13
Manuel Pégourié-Gonnardcf26e212015-07-02 19:47:06 +020014programs: lib
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020015 $(MAKE) -C programs
Paul Bakkerf9964ab2012-04-05 12:07:50 +000016
17lib:
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020018 $(MAKE) -C library
19
Manuel Pégourié-Gonnardcf26e212015-07-02 19:47:06 +020020tests: lib
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020021 $(MAKE) -C tests
Paul Bakkerf9964ab2012-04-05 12:07:50 +000022
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020023ifndef WINDOWS
Manuel Pégourié-Gonnard99839932015-08-03 10:34:09 +020024install: no_test
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000025 mkdir -p $(DESTDIR)/include/mbedtls
Ruini Xue5a9cb612018-06-28 23:21:26 +080026 cp -rp include/mbedtls $(DESTDIR)/include
Darryl Green11999bb2018-03-13 15:22:58 +000027
Paul Bakker5121ce52009-01-03 21:22:43 +000028 mkdir -p $(DESTDIR)/lib
Manuel Pégourié-Gonnard52a50792015-07-27 10:36:12 +020029 cp -RP library/libmbedtls.* $(DESTDIR)/lib
30 cp -RP library/libmbedx509.* $(DESTDIR)/lib
31 cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
Darryl Green11999bb2018-03-13 15:22:58 +000032
Paul Bakker5121ce52009-01-03 21:22:43 +000033 mkdir -p $(DESTDIR)/bin
34 for p in programs/*/* ; do \
35 if [ -x $$p ] && [ ! -d $$p ] ; \
36 then \
37 f=$(PREFIX)`basename $$p` ; \
38 cp $$p $(DESTDIR)/bin/$$f ; \
39 fi \
40 done
41
Paul Bakker9a736322012-11-14 12:39:52 +000042uninstall:
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043 rm -rf $(DESTDIR)/include/mbedtls
Manuel Pégourié-Gonnard52859702015-01-27 14:05:16 +010044 rm -f $(DESTDIR)/lib/libmbedtls.*
Manuel Pégourié-Gonnard52a50792015-07-27 10:36:12 +020045 rm -f $(DESTDIR)/lib/libmbedx509.*
46 rm -f $(DESTDIR)/lib/libmbedcrypto.*
Darryl Green11999bb2018-03-13 15:22:58 +000047
Paul Bakker9a736322012-11-14 12:39:52 +000048 for p in programs/*/* ; do \
49 if [ -x $$p ] && [ ! -d $$p ] ; \
50 then \
51 f=$(PREFIX)`basename $$p` ; \
52 rm -f $(DESTDIR)/bin/$$f ; \
53 fi \
54 done
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020055endif
Paul Bakker9a736322012-11-14 12:39:52 +000056
Simon Butcher1ceab6e2016-06-21 10:14:00 +010057WARNING_BORDER =*******************************************************\n
58NULL_ENTROPY_WARN_L1=**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! ****\n
59NULL_ENTROPY_WARN_L2=**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES ****\n
60NULL_ENTROPY_WARN_L3=**** AND IS *NOT* SUITABLE FOR PRODUCTION USE ****\n
61
62NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER)
63
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +030064WARNING_BORDER_LONG =**********************************************************************************\n
65CTR_DRBG_128_BIT_KEY_WARN_L1=**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined! ****\n
66CTR_DRBG_128_BIT_KEY_WARN_L2=**** Using 128-bit keys for CTR_DRBG limits the security of generated ****\n
67CTR_DRBG_128_BIT_KEY_WARN_L3=**** keys and operations that use random values generated to 128-bit security ****\n
68
69CTR_DRBG_128_BIT_KEY_WARNING=\n$(WARNING_BORDER_LONG)$(CTR_DRBG_128_BIT_KEY_WARN_L1)$(CTR_DRBG_128_BIT_KEY_WARN_L2)$(CTR_DRBG_128_BIT_KEY_WARN_L3)$(WARNING_BORDER_LONG)
70
Simon Butcher1ceab6e2016-06-21 10:14:00 +010071# Post build steps
72post_build:
Simon Butchercff625f2016-06-27 15:15:11 +010073ifndef WINDOWS
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +030074
75 # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
76 -scripts/config.pl get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
77 echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'
78
Simon Butcher1ceab6e2016-06-21 10:14:00 +010079 # If NULL Entropy is configured, display an appropriate warning
80 -scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \
81 echo '$(NULL_ENTROPY_WARNING)'
Simon Butchercff625f2016-06-27 15:15:11 +010082endif
Simon Butcher1ceab6e2016-06-21 10:14:00 +010083
Paul Bakker5121ce52009-01-03 21:22:43 +000084clean:
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020085 $(MAKE) -C library clean
86 $(MAKE) -C programs clean
87 $(MAKE) -C tests clean
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020088ifndef WINDOWS
Paul Bakkerbd3b3592016-07-13 16:37:32 +010089 find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020090endif
Paul Bakker5121ce52009-01-03 21:22:43 +000091
Andres AGc49b8082016-08-31 16:10:45 +010092check: lib tests
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020093 $(MAKE) -C tests check
Paul Bakker37ca75d2011-01-06 12:28:03 +000094
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020095test: check
Manuel Pégourié-Gonnard6529ff02014-01-31 13:41:07 +010096
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010097ifndef WINDOWS
Manuel Pégourié-Gonnard720375e2014-02-24 12:39:18 +010098# note: for coverage testing, build with:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020099# make CFLAGS='--coverage -g3 -O0'
Manuel Pégourié-Gonnard79d090b2014-02-26 19:39:01 +0100100covtest:
Manuel Pégourié-Gonnardfc367082015-06-26 16:50:24 +0200101 $(MAKE) check
Manuel Pégourié-Gonnard61137df2014-02-24 11:57:36 +0100102 programs/test/selftest
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100103 tests/compat.sh
104 tests/ssl-opt.sh
Manuel Pégourié-Gonnard61137df2014-02-24 11:57:36 +0100105
Manuel Pégourié-Gonnard546d86c2014-01-31 16:19:43 +0100106lcov:
107 rm -rf Coverage
Manuel Pégourié-Gonnard53c6e962014-06-13 12:22:07 +0200108 lcov --capture --initial --directory library -o files.info
Dan Handley8cb19812020-05-28 16:20:31 +0100109 lcov --rc lcov_branch_coverage=1 --capture --directory library -o tests.info
110 lcov --rc lcov_branch_coverage=1 --add-tracefile files.info --add-tracefile tests.info -o all.info
111 lcov --rc lcov_branch_coverage=1 --remove all.info -o final.info '*.h'
Manuel Pégourié-Gonnard720375e2014-02-24 12:39:18 +0100112 gendesc tests/Descriptions.txt -o descriptions
Dan Handley8cb19812020-05-28 16:20:31 +0100113 genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --branch-coverage -o Coverage final.info
Manuel Pégourié-Gonnarde41072e2014-06-16 16:24:24 +0200114 rm -f files.info tests.info all.info final.info descriptions
Manuel Pégourié-Gonnard546d86c2014-01-31 16:19:43 +0100115
Paul Bakker37ca75d2011-01-06 12:28:03 +0000116apidoc:
117 mkdir -p apidoc
Krzysztof Stachowiak744a4ac2018-01-22 13:38:31 +0100118 cd doxygen && doxygen mbedtls.doxyfile
Paul Bakker37ca75d2011-01-06 12:28:03 +0000119
120apidoc_clean:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200121 rm -rf apidoc
122endif
Gilles Peskine6663e9c2018-01-16 14:04:05 +0100123
124## Editor navigation files
125C_SOURCE_FILES = $(wildcard include/*/*.h library/*.[hc] programs/*/*.[hc] tests/suites/*.function)
Manuel Pégourié-Gonnard6c2908e2020-04-02 12:10:45 +0200126# Exuberant-ctags invocation. Other ctags implementations may require different options.
Gilles Peskinef70a3142021-01-13 13:45:30 +0100127CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
Gilles Peskine6663e9c2018-01-16 14:04:05 +0100128tags: $(C_SOURCE_FILES)
Manuel Pégourié-Gonnard6c2908e2020-04-02 12:10:45 +0200129 $(CTAGS) $@ $(C_SOURCE_FILES)
Gilles Peskine6663e9c2018-01-16 14:04:05 +0100130TAGS: $(C_SOURCE_FILES)
Gilles Peskinef70a3142021-01-13 13:45:30 +0100131 etags --no-line-directive -o $@ $(C_SOURCE_FILES)
Gilles Peskine25dee5d2020-11-20 11:50:08 +0100132global: GPATH GRTAGS GSYMS GTAGS
Gilles Peskine6663e9c2018-01-16 14:04:05 +0100133GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
134 ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
Gilles Peskine25dee5d2020-11-20 11:50:08 +0100135cscope: cscope.in.out cscope.po.out cscope.out
Gilles Peskinef9a7f5f2020-11-09 21:21:31 +0100136cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
137 cscope -bq -u -Iinclude -Ilibrary $(patsubst %,-I%,$(wildcard 3rdparty/*/include)) -Itests/include $(C_SOURCE_FILES)
Gilles Peskine25dee5d2020-11-20 11:50:08 +0100138.PHONY: cscope global