blob: dc12049e9719d0819055cbd189fe485d83449dff [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +00002# Also see "include/mbedtls/config.h"
Paul Bakker5121ce52009-01-03 21:22:43 +00003
Alon Bar-Levf7a9f302015-02-18 17:55:05 +02004CFLAGS ?= -O2
5WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
Alon Bar-Levada41052015-02-18 17:47:52 +02006LDFLAGS ?=
Alon Bar-Levf7a9f302015-02-18 17:55:05 +02007
8LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
Alon Bar-Levada41052015-02-18 17:47:52 +02009LOCAL_LDFLAGS =
Paul Bakker5121ce52009-01-03 21:22:43 +000010
Paul Bakkerc7ffd362012-04-05 12:08:29 +000011ifdef DEBUG
Alon Bar-Levf7a9f302015-02-18 17:55:05 +020012LOCAL_CFLAGS += -g3
Paul Bakkerc7ffd362012-04-05 12:08:29 +000013endif
14
Paul Bakkerad7eca22010-03-24 06:46:47 +000015# MicroBlaze specific options:
16# CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift
Paul Bakker5121ce52009-01-03 21:22:43 +000017
Paul Bakkerad7eca22010-03-24 06:46:47 +000018# To compile on Plan9:
19# CFLAGS += -D_BSD_EXTENSION
Paul Bakker5121ce52009-01-03 21:22:43 +000020
Manuel Pégourié-Gonnard02ba5782015-02-18 13:42:26 +000021# if were running on Windows build for Windows
22ifdef WINDOWS
23WINDOWS_BUILD=1
24endif
25
Paul Bakkerad7eca22010-03-24 06:46:47 +000026# To compile as a shared library:
Paul Bakker9a736322012-11-14 12:39:52 +000027ifdef SHARED
Manuel Pégourié-Gonnard3cfb3452015-02-13 13:34:08 +000028# all code is position-indep with mingw, avoid warning about useless flag
Manuel Pégourié-Gonnard02ba5782015-02-18 13:42:26 +000029ifndef WINDOWS_BUILD
Alon Bar-Levf7a9f302015-02-18 17:55:05 +020030LOCAL_CFLAGS += -fPIC -fpic
Paul Bakker9a736322012-11-14 12:39:52 +000031endif
Manuel Pégourié-Gonnard3cfb3452015-02-13 13:34:08 +000032endif
Paul Bakker5121ce52009-01-03 21:22:43 +000033
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020034SOEXT=so.8
Paul Bakker33aac372011-08-13 11:47:41 +000035
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020036DLEXT=so
Paul Bakkerad7eca22010-03-24 06:46:47 +000037# OSX shared library extension:
38# DLEXT=dylib
Paul Bakker5121ce52009-01-03 21:22:43 +000039
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020040# Windows shared library extension:
41ifdef WINDOWS_BUILD
Paul Bakkercd5b5292012-05-10 20:49:10 +000042DLEXT=dll
43endif
Paul Bakkera585beb2011-06-21 08:59:44 +000044
Manuel Pégourié-Gonnard92ac76f2013-12-16 17:12:53 +010045OBJS= aes.o aesni.o arc4.o \
46 asn1parse.o \
Paul Bakkera9379c02012-07-04 11:02:11 +000047 asn1write.o base64.o bignum.o \
Manuel Pégourié-Gonnarda6916fa2014-05-02 15:17:29 +020048 blowfish.o camellia.o ccm.o \
Paul Bakker0e04d0e2011-11-27 14:46:59 +000049 certs.o cipher.o cipher_wrap.o \
Paul Bakker6083fd22011-12-03 21:45:14 +000050 ctr_drbg.o debug.o des.o \
Paul Bakkerd589a0d2013-03-13 16:30:17 +010051 dhm.o ecdh.o ecdsa.o \
Manuel Pégourié-Gonnard32b04c12013-12-02 15:49:09 +010052 ecp.o ecp_curves.o \
Paul Bakkera95919b2013-01-16 17:00:05 +010053 entropy.o entropy_poll.o \
Paul Bakker89e80c92012-03-20 13:50:09 +000054 error.o gcm.o havege.o \
Manuel Pégourié-Gonnard490bdf32014-01-27 14:03:10 +010055 hmac_drbg.o \
Paul Bakker6083fd22011-12-03 21:45:14 +000056 md.o md_wrap.o md2.o \
Paul Bakkerdefc0ca2014-02-04 17:30:24 +010057 md4.o md5.o \
Paul Bakkerb0763142013-11-05 11:27:12 +010058 memory_buffer_alloc.o net.o \
Manuel Pégourié-Gonnardb6b16bd2015-03-11 11:20:43 +000059 oid.o padlock.o pem.o \
Paul Bakkerb0c19a42013-06-24 19:26:38 +020060 pkcs5.o pkcs11.o pkcs12.o \
Paul Bakker1a7550a2013-09-15 13:01:22 +020061 pk.o pk_wrap.o pkparse.o \
Paul Bakker747a83a2014-02-01 22:50:07 +010062 pkwrite.o platform.o ripemd160.o \
Paul Bakkerd2681d82013-06-30 14:49:12 +020063 rsa.o sha1.o sha256.o \
64 sha512.o ssl_cache.o ssl_cli.o \
Manuel Pégourié-Gonnardfd6d8972015-05-15 12:09:00 +020065 ssl_cookie.o ssl_ticket.o \
Paul Bakker68884e32013-01-07 18:20:04 +010066 ssl_srv.o ssl_ciphersuites.o \
Paul Bakker2466d932013-09-28 14:40:38 +020067 ssl_tls.o threading.o timing.o \
Paul Bakker0f90d7d2014-04-30 11:49:44 +020068 version.o version_features.o \
Paul Bakker9556d3d2013-09-18 13:50:13 +020069 x509.o x509_create.o \
70 x509_crl.o x509_crt.o x509_csr.o \
71 x509write_crt.o x509write_csr.o \
72 xtea.o
Paul Bakker5121ce52009-01-03 21:22:43 +000073
Paul Bakkerad7eca22010-03-24 06:46:47 +000074.SILENT:
Paul Bakker5121ce52009-01-03 21:22:43 +000075
Paul Bakker9a736322012-11-14 12:39:52 +000076ifndef SHARED
Paul Bakker3783d6d2011-07-13 11:25:36 +000077all: static
Paul Bakker9a736322012-11-14 12:39:52 +000078else
Manuel Pégourié-Gonnard04a81d52015-01-27 11:24:05 +010079all: shared static
Paul Bakker9a736322012-11-14 12:39:52 +000080endif
Paul Bakker5121ce52009-01-03 21:22:43 +000081
Manuel Pégourié-Gonnard129db082015-03-09 16:57:18 +000082static: libmbedtls.a
Paul Bakker5121ce52009-01-03 21:22:43 +000083
Manuel Pégourié-Gonnard129db082015-03-09 16:57:18 +000084shared: libmbedtls.$(DLEXT)
Manuel Pégourié-Gonnardc26a0922015-01-23 12:51:33 +000085
86libmbedtls.a: $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +000087 echo " AR $@"
Manuel Pégourié-Gonnardfba22fd2015-02-11 14:24:47 +000088 $(AR) rc $@ $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +000089 echo " RL $@"
Paul Bakkera585beb2011-06-21 08:59:44 +000090 $(AR) s $@
Paul Bakker5121ce52009-01-03 21:22:43 +000091
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020092libmbedtls.$(SOEXT): $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +000093 echo " LD $@"
Alon Bar-Levada41052015-02-18 17:47:52 +020094 $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS)
Paul Bakker5121ce52009-01-03 21:22:43 +000095
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020096libmbedtls.so: libmbedtls.$(SOEXT)
97 echo " LN $@ -> libmbedtls.$(SOEXT)"
98 ln -sf libmbedtls.$(SOEXT) $@
Paul Bakkerb0763142013-11-05 11:27:12 +010099
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100100libmbedtls.dylib: $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +0000101 echo " LD $@"
Alon Bar-Levada41052015-02-18 17:47:52 +0200102 $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS)
Paul Bakker5121ce52009-01-03 21:22:43 +0000103
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100104libmbedtls.dll: $(OBJS)
Paul Bakkerb0763142013-11-05 11:27:12 +0100105 echo " LD $@"
Alon Bar-Levada41052015-02-18 17:47:52 +0200106 $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
Paul Bakkera585beb2011-06-21 08:59:44 +0000107
Paul Bakkerad7eca22010-03-24 06:46:47 +0000108.c.o:
Paul Bakker96d42da2012-04-05 13:22:07 +0000109 echo " CC $<"
Alon Bar-Levf7a9f302015-02-18 17:55:05 +0200110 $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $<
Paul Bakker5121ce52009-01-03 21:22:43 +0000111
112clean:
Paul Bakker62f88dc2012-05-10 21:26:28 +0000113ifndef WINDOWS
Manuel Pégourié-Gonnard129db082015-03-09 16:57:18 +0000114 rm -f *.o libmbedtls.*
Paul Bakker62f88dc2012-05-10 21:26:28 +0000115endif
116ifdef WINDOWS
Manuel Pégourié-Gonnard129db082015-03-09 16:57:18 +0000117 del /Q /F *.o libmbedtls.*
Paul Bakker62f88dc2012-05-10 21:26:28 +0000118endif