Makefile 2.89 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
all: programs tests post_build
10

11 12
no_test: programs

Manuel Pégourié-Gonnard's avatar
Manuel Pégourié-Gonnard committed
13
programs: lib
14
	$(MAKE) -C programs
Paul Bakker's avatar
Paul Bakker committed
15 16

lib:
17 18
	$(MAKE) -C library

Manuel Pégourié-Gonnard's avatar
Manuel Pégourié-Gonnard committed
19
tests: lib
20
	$(MAKE) -C tests
Paul Bakker's avatar
Paul Bakker committed
21

22
ifndef WINDOWS
23
install: no_test
24 25
	mkdir -p $(DESTDIR)/include/mbedtls
	cp -r include/mbedtls $(DESTDIR)/include
26 27
	
	mkdir -p $(DESTDIR)/lib
28 29 30
	cp -RP library/libmbedtls.*    $(DESTDIR)/lib
	cp -RP library/libmbedx509.*   $(DESTDIR)/lib
	cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
31 32 33 34 35 36 37 38 39 40
	
	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

41
uninstall:
42
	rm -rf $(DESTDIR)/include/mbedtls
43
	rm -f $(DESTDIR)/lib/libmbedtls.*
44 45
	rm -f $(DESTDIR)/lib/libmbedx509.*
	rm -f $(DESTDIR)/lib/libmbedcrypto.*
46 47 48 49 50 51 52 53
	
	for p in programs/*/* ; do              \
	    if [ -x $$p ] && [ ! -d $$p ] ;     \
	    then                                \
	        f=$(PREFIX)`basename $$p` ;     \
	        rm -f $(DESTDIR)/bin/$$f ;      \
	    fi                                  \
	done
54
endif
55

56 57 58 59 60 61 62 63 64
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)

# Post build steps
post_build:
Simon Butcher's avatar
Simon Butcher committed
65
ifndef WINDOWS
66 67 68
	# If NULL Entropy is configured, display an appropriate warning
	-scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \
	    echo '$(NULL_ENTROPY_WARNING)'
Simon Butcher's avatar
Simon Butcher committed
69
endif
70

71
clean:
72 73 74
	$(MAKE) -C library clean
	$(MAKE) -C programs clean
	$(MAKE) -C tests clean
75
ifndef WINDOWS
76
	find . \( -name \*.gcno -o -name \*.gcda -o -name *.info \) -exec rm {} +
77
endif
78

Manuel Pégourié-Gonnard's avatar
Manuel Pégourié-Gonnard committed
79
check: lib
80
	$(MAKE) -C tests check
81

82
test: check
83

84
ifndef WINDOWS
85
# note: for coverage testing, build with:
86
# make CFLAGS='--coverage -g3 -O0'
87
covtest:
88
	$(MAKE) check
89
	programs/test/selftest
90 91
	tests/compat.sh
	tests/ssl-opt.sh
92

93 94
lcov:
	rm -rf Coverage
95 96
	lcov --capture --initial --directory library -o files.info
	lcov --capture --directory library -o tests.info
97 98
	lcov --add-tracefile files.info --add-tracefile tests.info -o all.info
	lcov --remove all.info -o final.info '*.h'
99
	gendesc tests/Descriptions.txt -o descriptions
100
	genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --no-branch-coverage -o Coverage final.info
101
	rm -f files.info tests.info all.info final.info descriptions
102

103 104
apidoc:
	mkdir -p apidoc
Manuel Pégourié-Gonnard's avatar
Manuel Pégourié-Gonnard committed
105
	doxygen doxygen/mbedtls.doxyfile
106 107

apidoc_clean:
108 109
	rm -rf apidoc
endif