Makefile 3.73 KB
Newer Older
1 2

DESTDIR=/usr/local
3
PREFIX=mbedtls_
4 5 6

.SILENT:

7
.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
8

9 10
all: programs tests
	$(MAKE) post_build
11

12 13
no_test: programs

14
programs: lib
15
	$(MAKE) -C programs
16 17

lib:
18 19
	$(MAKE) -C library

20
tests: lib
21
	$(MAKE) -C tests
22

23
ifndef WINDOWS
24
install: no_test
25
	mkdir -p $(DESTDIR)/include/mbedtls
26
	cp -rp include/mbedtls $(DESTDIR)/include
27

28
	mkdir -p $(DESTDIR)/lib
29 30 31
	cp -RP library/libmbedtls.*    $(DESTDIR)/lib
	cp -RP library/libmbedx509.*   $(DESTDIR)/lib
	cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
32

33 34 35 36 37 38 39 40 41
	mkdir -p $(DESTDIR)/bin
	for p in programs/*/* ; do              \
	    if [ -x $$p ] && [ ! -d $$p ] ;     \
	    then                                \
	        f=$(PREFIX)`basename $$p` ;     \
	        cp $$p $(DESTDIR)/bin/$$f ;     \
	    fi                                  \
	done

42
uninstall:
43
	rm -rf $(DESTDIR)/include/mbedtls
44
	rm -f $(DESTDIR)/lib/libmbedtls.*
45 46
	rm -f $(DESTDIR)/lib/libmbedx509.*
	rm -f $(DESTDIR)/lib/libmbedcrypto.*
47

48 49 50 51 52 53 54
	for p in programs/*/* ; do              \
	    if [ -x $$p ] && [ ! -d $$p ] ;     \
	    then                                \
	        f=$(PREFIX)`basename $$p` ;     \
	        rm -f $(DESTDIR)/bin/$$f ;      \
	    fi                                  \
	done
55
endif
56

57 58 59 60 61 62 63
WARNING_BORDER      =*******************************************************\n
NULL_ENTROPY_WARN_L1=****  WARNING!  MBEDTLS_TEST_NULL_ENTROPY defined! ****\n
NULL_ENTROPY_WARN_L2=****  THIS BUILD HAS NO DEFINED ENTROPY SOURCES    ****\n
NULL_ENTROPY_WARN_L3=****  AND IS *NOT* SUITABLE FOR PRODUCTION USE     ****\n

NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER)

64 65 66 67 68 69 70
WARNING_BORDER_LONG      =**********************************************************************************\n
CTR_DRBG_128_BIT_KEY_WARN_L1=****  WARNING!  MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined!                      ****\n
CTR_DRBG_128_BIT_KEY_WARN_L2=****  Using 128-bit keys for CTR_DRBG limits the security of generated         ****\n
CTR_DRBG_128_BIT_KEY_WARN_L3=****  keys and operations that use random values generated to 128-bit security ****\n

CTR_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)

71 72
# Post build steps
post_build:
73
ifndef WINDOWS
74 75 76 77 78

	# If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
	-scripts/config.pl get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
	    echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'

79 80 81
	# If NULL Entropy is configured, display an appropriate warning
	-scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \
	    echo '$(NULL_ENTROPY_WARNING)'
82
endif
83

84
clean:
85 86 87
	$(MAKE) -C library clean
	$(MAKE) -C programs clean
	$(MAKE) -C tests clean
88
ifndef WINDOWS
89
	find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
90
endif
91

92
check: lib tests
93
	$(MAKE) -C tests check
94

95
test: check
96

97
ifndef WINDOWS
98
# note: for coverage testing, build with:
99
# make CFLAGS='--coverage -g3 -O0'
100
covtest:
101
	$(MAKE) check
102
	programs/test/selftest
103 104
	tests/compat.sh
	tests/ssl-opt.sh
105

106 107
lcov:
	rm -rf Coverage
108 109
	lcov --capture --initial --directory library -o files.info
	lcov --capture --directory library -o tests.info
110 111
	lcov --add-tracefile files.info --add-tracefile tests.info -o all.info
	lcov --remove all.info -o final.info '*.h'
112
	gendesc tests/Descriptions.txt -o descriptions
113
	genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --no-branch-coverage -o Coverage final.info
114
	rm -f files.info tests.info all.info final.info descriptions
115

116 117
apidoc:
	mkdir -p apidoc
118
	cd doxygen && doxygen mbedtls.doxyfile
119 120

apidoc_clean:
121 122
	rm -rf apidoc
endif