1 2# Also see "include/mbedtls/config.h" 3 4CFLAGS ?= -O2 5WARNING_CFLAGS ?= -Wall -Wextra 6LDFLAGS ?= 7 8# Include ../include for public headers and . for private headers. 9# Note that . needs to be included explicitly for the sake of library 10# files that are not in the /library directory (which currently means 11# under /3rdparty). 12LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -D_FILE_OFFSET_BITS=64 13LOCAL_LDFLAGS = 14 15ifdef DEBUG 16LOCAL_CFLAGS += -g3 17endif 18 19# MicroBlaze specific options: 20# CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift 21 22# To compile on Plan9: 23# CFLAGS += -D_BSD_EXTENSION 24 25# if were running on Windows build for Windows 26ifdef WINDOWS 27WINDOWS_BUILD=1 28else ifeq ($(shell uname -s),Darwin) 29ifeq ($(AR),ar) 30APPLE_BUILD ?= 1 31endif 32endif 33 34# To compile as a shared library: 35ifdef SHARED 36# all code is position-indep with mingw, avoid warning about useless flag 37ifndef WINDOWS_BUILD 38LOCAL_CFLAGS += -fPIC -fpic 39endif 40endif 41 42SOEXT_TLS=so.13 43SOEXT_X509=so.1 44SOEXT_CRYPTO=so.6 45 46# Set AR_DASH= (empty string) to use an ar implementation that does not accept 47# the - prefix for command line options (e.g. llvm-ar) 48AR_DASH ?= - 49 50ARFLAGS = $(AR_DASH)src 51ifdef APPLE_BUILD 52ifneq ($(APPLE_BUILD),0) 53ARFLAGS = $(AR_DASH)Src 54RLFLAGS = -no_warning_for_no_symbols -c 55RL ?= ranlib 56endif 57endif 58 59DLEXT ?= so 60ifdef WINDOWS_BUILD 61# Windows shared library extension: 62DLEXT = dll 63else ifdef APPLE_BUILD 64ifneq ($(APPLE_BUILD),0) 65# Mac OS X shared library extension: 66DLEXT = dylib 67endif 68endif 69 70OBJS_CRYPTO= \ 71 aes.o \ 72 aesni.o \ 73 arc4.o \ 74 aria.o \ 75 asn1parse.o \ 76 asn1write.o \ 77 base64.o \ 78 bignum.o \ 79 blowfish.o \ 80 camellia.o \ 81 ccm.o \ 82 chacha20.o \ 83 chachapoly.o \ 84 cipher.o \ 85 cipher_wrap.o \ 86 cmac.o \ 87 ctr_drbg.o \ 88 des.o \ 89 dhm.o \ 90 ecdh.o \ 91 ecdsa.o \ 92 ecjpake.o \ 93 ecp.o \ 94 ecp_curves.o \ 95 entropy.o \ 96 entropy_poll.o \ 97 error.o \ 98 gcm.o \ 99 havege.o \ 100 hkdf.o \ 101 hmac_drbg.o \ 102 md.o \ 103 md2.o \ 104 md4.o \ 105 md5.o \ 106 memory_buffer_alloc.o \ 107 nist_kw.o \ 108 oid.o \ 109 padlock.o \ 110 pem.o \ 111 pk.o \ 112 pk_wrap.o \ 113 pkcs12.o \ 114 pkcs5.o \ 115 pkparse.o \ 116 pkwrite.o \ 117 platform.o \ 118 platform_util.o \ 119 poly1305.o \ 120 psa_crypto.o \ 121 psa_crypto_driver_wrappers.o \ 122 psa_crypto_se.o \ 123 psa_crypto_slot_management.o \ 124 psa_crypto_storage.o \ 125 psa_its_file.o \ 126 ripemd160.o \ 127 rsa.o \ 128 rsa_internal.o \ 129 sha1.o \ 130 sha256.o \ 131 sha512.o \ 132 threading.o \ 133 timing.o \ 134 version.o \ 135 version_features.o \ 136 xtea.o \ 137 # This line is intentionally left blank 138 139include ../3rdparty/Makefile.inc 140LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES) 141OBJS_CRYPTO+=$(THIRDPARTY_CRYPTO_OBJECTS) 142 143OBJS_X509= \ 144 certs.o \ 145 pkcs11.o \ 146 x509.o \ 147 x509_create.o \ 148 x509_crl.o \ 149 x509_crt.o \ 150 x509_csr.o \ 151 x509write_crt.o \ 152 x509write_csr.o \ 153 # This line is intentionally left blank 154 155OBJS_TLS= \ 156 debug.o \ 157 net_sockets.o \ 158 ssl_cache.o \ 159 ssl_ciphersuites.o \ 160 ssl_cli.o \ 161 ssl_cookie.o \ 162 ssl_msg.o \ 163 ssl_srv.o \ 164 ssl_ticket.o \ 165 ssl_tls.o \ 166 ssl_tls13_keys.o \ 167 # This line is intentionally left blank 168 169.SILENT: 170 171.PHONY: all static shared clean 172 173ifndef SHARED 174all: static 175else 176all: shared static 177endif 178 179static: libmbedcrypto.a libmbedx509.a libmbedtls.a 180 181shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) 182 183# tls 184libmbedtls.a: $(OBJS_TLS) 185 echo " AR $@" 186 $(AR) $(ARFLAGS) $@ $(OBJS_TLS) 187ifdef APPLE_BUILD 188ifneq ($(APPLE_BUILD),0) 189 echo " RL $@" 190 $(RL) $(RLFLAGS) $@ 191endif 192endif 193 194libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so 195 echo " LD $@" 196 $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS) 197 198libmbedtls.so: libmbedtls.$(SOEXT_TLS) 199 echo " LN $@ -> $<" 200 ln -sf $< $@ 201 202libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib 203 echo " LD $@" 204 $(CC) -dynamiclib -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS) 205 206libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll 207 echo " LD $@" 208 $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -lmbedx509 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) 209 210# x509 211libmbedx509.a: $(OBJS_X509) 212 echo " AR $@" 213 $(AR) $(ARFLAGS) $@ $(OBJS_X509) 214ifdef APPLE_BUILD 215ifneq ($(APPLE_BUILD),0) 216 echo " RL $@" 217 $(RL) $(RLFLAGS) $@ 218endif 219endif 220 221libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so 222 echo " LD $@" 223 $(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) 224 225libmbedx509.so: libmbedx509.$(SOEXT_X509) 226 echo " LN $@ -> $<" 227 ln -sf $< $@ 228 229libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib 230 echo " LD $@" 231 $(CC) -dynamiclib -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509) 232 233libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll 234 echo " LD $@" 235 $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) 236 237# crypto 238libmbedcrypto.a: $(OBJS_CRYPTO) 239 echo " AR $@" 240 $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) 241ifdef APPLE_BUILD 242ifneq ($(APPLE_BUILD),0) 243 echo " RL $@" 244 $(RL) $(RLFLAGS) $@ 245endif 246endif 247 248libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) 249 echo " LD $@" 250 $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) 251 252libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) 253 echo " LN $@ -> $<" 254 ln -sf $< $@ 255 256libmbedcrypto.dylib: $(OBJS_CRYPTO) 257 echo " LD $@" 258 $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) 259 260libmbedcrypto.dll: $(OBJS_CRYPTO) 261 echo " LD $@" 262 $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) 263 264.c.o: 265 echo " CC $<" 266 $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $< 267 268clean: 269ifndef WINDOWS 270 rm -f *.o libmbed* 271 rm -f $(THIRDPARTY_CRYPTO_OBJECTS) 272else 273 if exist *.o del /Q /F *.o 274 if exist libmbed* del /Q /F libmbed* 275 del /Q /F del_errors_out_if_the_file_list_is_empty_but_not_if_a_file_does_not_exist $(subst /,\,$(THIRDPARTY_CRYPTO_OBJECTS)) 276endif 277