• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2DESTDIR=/usr/local
3PREFIX=mbedtls_
4
5.SILENT:
6
7.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
8
9all: programs tests
10	$(MAKE) post_build
11
12no_test: programs
13
14programs: lib
15	$(MAKE) -C programs
16
17lib:
18	$(MAKE) -C library
19
20tests: lib
21	$(MAKE) -C tests
22
23ifndef WINDOWS
24install: no_test
25	mkdir -p $(DESTDIR)/include/mbedtls
26	cp -rp include/mbedtls $(DESTDIR)/include
27
28	mkdir -p $(DESTDIR)/lib
29	cp -RP library/libmbedtls.*    $(DESTDIR)/lib
30	cp -RP library/libmbedx509.*   $(DESTDIR)/lib
31	cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
32
33	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
42uninstall:
43	rm -rf $(DESTDIR)/include/mbedtls
44	rm -f $(DESTDIR)/lib/libmbedtls.*
45	rm -f $(DESTDIR)/lib/libmbedx509.*
46	rm -f $(DESTDIR)/lib/libmbedcrypto.*
47
48	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
55endif
56
57WARNING_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
64WARNING_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
71# Post build steps
72post_build:
73ifndef WINDOWS
74
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
79	# 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)'
82endif
83
84clean:
85	$(MAKE) -C library clean
86	$(MAKE) -C programs clean
87	$(MAKE) -C tests clean
88ifndef WINDOWS
89	find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
90endif
91
92check: lib tests
93	$(MAKE) -C tests check
94
95test: check
96
97ifndef WINDOWS
98# note: for coverage testing, build with:
99# make CFLAGS='--coverage -g3 -O0'
100covtest:
101	$(MAKE) check
102	programs/test/selftest
103	tests/compat.sh
104	tests/ssl-opt.sh
105
106lcov:
107	rm -rf Coverage
108	lcov --capture --initial --directory library -o files.info
109	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'
112	gendesc tests/Descriptions.txt -o descriptions
113	genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --branch-coverage -o Coverage final.info
114	rm -f files.info tests.info all.info final.info descriptions
115
116apidoc:
117	mkdir -p apidoc
118	cd doxygen && doxygen mbedtls.doxyfile
119
120apidoc_clean:
121	rm -rf apidoc
122endif
123
124## Editor navigation files
125C_SOURCE_FILES = $(wildcard include/*/*.h library/*.[hc] programs/*/*.[hc] tests/suites/*.function)
126# Exuberant-ctags invocation. Other ctags implementations may require different options.
127CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
128tags: $(C_SOURCE_FILES)
129	$(CTAGS) $@ $(C_SOURCE_FILES)
130TAGS: $(C_SOURCE_FILES)
131	etags --no-line-directive -o $@ $(C_SOURCE_FILES)
132global: GPATH GRTAGS GSYMS GTAGS
133GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
134	ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
135cscope: cscope.in.out cscope.po.out cscope.out
136cscope.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)
138.PHONY: cscope global
139