blob: 1580badc8bad0a2917bb6ec8cdc2a0085a8f9197 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001
Paul Bakkerad7eca22010-03-24 06:46:47 +00002# Also see "include/polarssl/config.h"
Paul Bakker5121ce52009-01-03 21:22:43 +00003
Paul Bakker62f88dc2012-05-10 21:26:28 +00004# To compile on MinGW: add "-lws2_32" to LDFLAGS or define WINDOWS in your
5# environment
6#
Paul Bakker46eb1382011-01-30 17:10:13 +00007CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement
Paul Bakkerf1ab0ec2012-10-23 12:12:53 +00008OFLAGS = -O2
Paul Bakker5121ce52009-01-03 21:22:43 +00009
Paul Bakkerc7ffd362012-04-05 12:08:29 +000010ifdef DEBUG
11CFLAGS += -g3
12endif
13
Paul Bakkerad7eca22010-03-24 06:46:47 +000014# MicroBlaze specific options:
15# CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift
Paul Bakker5121ce52009-01-03 21:22:43 +000016
Paul Bakkerad7eca22010-03-24 06:46:47 +000017# To compile on Plan9:
18# CFLAGS += -D_BSD_EXTENSION
Paul Bakker5121ce52009-01-03 21:22:43 +000019
Paul Bakkerad7eca22010-03-24 06:46:47 +000020# To compile as a shared library:
Paul Bakker9a736322012-11-14 12:39:52 +000021ifdef SHARED
Manuel Pégourié-Gonnard3cfb3452015-02-13 13:34:08 +000022# all code is position-indep with mingw, avoid warning about useless flag
23ifndef WINDOWS
Paul Bakker9a736322012-11-14 12:39:52 +000024CFLAGS += -fPIC
25endif
Manuel Pégourié-Gonnard3cfb3452015-02-13 13:34:08 +000026endif
Paul Bakker5121ce52009-01-03 21:22:43 +000027
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020028SOEXT=so.8
Paul Bakker33aac372011-08-13 11:47:41 +000029
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020030DLEXT=so
Paul Bakkerad7eca22010-03-24 06:46:47 +000031# OSX shared library extension:
32# DLEXT=dylib
Paul Bakker5121ce52009-01-03 21:22:43 +000033
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020034#
35# if we running on Windows build
36# for Windows
37#
Paul Bakkercd5b5292012-05-10 20:49:10 +000038ifdef WINDOWS
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020039WINDOWS_BUILD=1
40endif
41
42# Windows shared library extension:
43ifdef WINDOWS_BUILD
Paul Bakkercd5b5292012-05-10 20:49:10 +000044DLEXT=dll
Paul Bakker62f88dc2012-05-10 21:26:28 +000045LDFLAGS += -lws2_32
Paul Bakkercd5b5292012-05-10 20:49:10 +000046endif
Paul Bakkera585beb2011-06-21 08:59:44 +000047
Manuel Pégourié-Gonnard92ac76f2013-12-16 17:12:53 +010048OBJS= aes.o aesni.o arc4.o \
49 asn1parse.o \
Paul Bakkera9379c02012-07-04 11:02:11 +000050 asn1write.o base64.o bignum.o \
Manuel Pégourié-Gonnarda6916fa2014-05-02 15:17:29 +020051 blowfish.o camellia.o ccm.o \
Paul Bakker0e04d0e2011-11-27 14:46:59 +000052 certs.o cipher.o cipher_wrap.o \
Paul Bakker6083fd22011-12-03 21:45:14 +000053 ctr_drbg.o debug.o des.o \
Paul Bakkerd589a0d2013-03-13 16:30:17 +010054 dhm.o ecdh.o ecdsa.o \
Manuel Pégourié-Gonnard32b04c12013-12-02 15:49:09 +010055 ecp.o ecp_curves.o \
Paul Bakkera95919b2013-01-16 17:00:05 +010056 entropy.o entropy_poll.o \
Paul Bakker89e80c92012-03-20 13:50:09 +000057 error.o gcm.o havege.o \
Manuel Pégourié-Gonnard490bdf32014-01-27 14:03:10 +010058 hmac_drbg.o \
Paul Bakker6083fd22011-12-03 21:45:14 +000059 md.o md_wrap.o md2.o \
Paul Bakkerdefc0ca2014-02-04 17:30:24 +010060 md4.o md5.o \
Paul Bakkerb0763142013-11-05 11:27:12 +010061 memory_buffer_alloc.o net.o \
Paul Bakkerc70b9822013-04-07 22:00:46 +020062 oid.o \
Paul Bakkerf518b162012-08-23 13:03:18 +000063 padlock.o pbkdf2.o pem.o \
Paul Bakkerb0c19a42013-06-24 19:26:38 +020064 pkcs5.o pkcs11.o pkcs12.o \
Paul Bakker1a7550a2013-09-15 13:01:22 +020065 pk.o pk_wrap.o pkparse.o \
Paul Bakker747a83a2014-02-01 22:50:07 +010066 pkwrite.o platform.o ripemd160.o \
Paul Bakkerd2681d82013-06-30 14:49:12 +020067 rsa.o sha1.o sha256.o \
68 sha512.o ssl_cache.o ssl_cli.o \
Paul Bakker68884e32013-01-07 18:20:04 +010069 ssl_srv.o ssl_ciphersuites.o \
Paul Bakker2466d932013-09-28 14:40:38 +020070 ssl_tls.o threading.o timing.o \
Paul Bakker0f90d7d2014-04-30 11:49:44 +020071 version.o version_features.o \
Paul Bakker9556d3d2013-09-18 13:50:13 +020072 x509.o x509_create.o \
73 x509_crl.o x509_crt.o x509_csr.o \
74 x509write_crt.o x509write_csr.o \
75 xtea.o
Paul Bakker5121ce52009-01-03 21:22:43 +000076
Paul Bakkerad7eca22010-03-24 06:46:47 +000077.SILENT:
Paul Bakker5121ce52009-01-03 21:22:43 +000078
Paul Bakker9a736322012-11-14 12:39:52 +000079ifndef SHARED
Paul Bakker3783d6d2011-07-13 11:25:36 +000080all: static
Paul Bakker9a736322012-11-14 12:39:52 +000081else
Manuel Pégourié-Gonnard04a81d52015-01-27 11:24:05 +010082all: shared static
Paul Bakker9a736322012-11-14 12:39:52 +000083endif
Paul Bakker5121ce52009-01-03 21:22:43 +000084
Paul Bakkerad7eca22010-03-24 06:46:47 +000085static: libpolarssl.a
Paul Bakker5121ce52009-01-03 21:22:43 +000086
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +020087shared: libpolarssl.$(DLEXT)
Paul Bakker5121ce52009-01-03 21:22:43 +000088
Manuel Pégourié-Gonnardc26a0922015-01-23 12:51:33 +000089libpolarssl.a: libmbedtls.a
90 echo " LN $@ -> $?"
Manuel Pégourié-Gonnard09eb14c2015-02-16 15:25:31 +000091ifndef WINDOWS
Manuel Pégourié-Gonnardc26a0922015-01-23 12:51:33 +000092 ln -sf $? $@
Manuel Pégourié-Gonnard09eb14c2015-02-16 15:25:31 +000093else
94 copy /y /b $? $@
95endif
Manuel Pégourié-Gonnardc26a0922015-01-23 12:51:33 +000096
97libmbedtls.a: $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +000098 echo " AR $@"
Manuel Pégourié-Gonnardfba22fd2015-02-11 14:24:47 +000099 $(AR) rc $@ $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +0000100 echo " RL $@"
Paul Bakkera585beb2011-06-21 08:59:44 +0000101 $(AR) s $@
Paul Bakker5121ce52009-01-03 21:22:43 +0000102
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +0200103libpolarssl.$(DLEXT): libmbedtls.$(DLEXT)
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100104 echo " LN $@ -> $?"
Manuel Pégourié-Gonnard09eb14c2015-02-16 15:25:31 +0000105ifndef WINDOWS
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100106 ln -sf $? $@
Manuel Pégourié-Gonnard09eb14c2015-02-16 15:25:31 +0000107else
108 copy /y /b $? $@
109endif
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +0200110ifdef WINDOWS_BUILD
111ifndef WINDOWS
112 ln -sf $?.a $@.a
113else
114 copy /y /b $?.a $@.a
115endif
116endif
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100117
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +0200118libmbedtls.$(SOEXT): $(OBJS)
Manuel Pégourié-Gonnardf8120542015-02-16 15:24:17 +0000119 echo " LD $@"
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +0200120 $(CC) ${LDFLAGS} -shared -Wl,-soname,$@ -o $@ $(OBJS)
Manuel Pégourié-Gonnardf8120542015-02-16 15:24:17 +0000121
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +0200122libmbedtls.so: libmbedtls.$(SOEXT)
123 echo " LN $@ -> libmbedtls.$(SOEXT)"
124 ln -sf libmbedtls.$(SOEXT) $@
Paul Bakkerb0763142013-11-05 11:27:12 +0100125
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100126libmbedtls.dylib: $(OBJS)
Paul Bakkerad7eca22010-03-24 06:46:47 +0000127 echo " LD $@"
Paul Bakker46eb1382011-01-30 17:10:13 +0000128 $(CC) ${LDFLAGS} -dynamiclib -o $@ $(OBJS)
Paul Bakker5121ce52009-01-03 21:22:43 +0000129
Manuel Pégourié-Gonnard145422f2015-01-26 18:26:10 +0100130libmbedtls.dll: $(OBJS)
Paul Bakkerb0763142013-11-05 11:27:12 +0100131 echo " LD $@"
Alon Bar-Lev18ba0cc2015-02-14 01:04:58 +0200132 $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32
Paul Bakkera585beb2011-06-21 08:59:44 +0000133
Paul Bakkerad7eca22010-03-24 06:46:47 +0000134.c.o:
Paul Bakker96d42da2012-04-05 13:22:07 +0000135 echo " CC $<"
Paul Bakkerad7eca22010-03-24 06:46:47 +0000136 $(CC) $(CFLAGS) $(OFLAGS) -c $<
Paul Bakker5121ce52009-01-03 21:22:43 +0000137
138clean:
Manuel Pégourié-Gonnard09eb14c2015-02-16 15:25:31 +0000139ifndef WINDOWS
Manuel Pégourié-Gonnardc26a0922015-01-23 12:51:33 +0000140 rm -f *.o libpolarssl.* libmbedtls.*
Manuel Pégourié-Gonnard09eb14c2015-02-16 15:25:31 +0000141endif
142ifdef WINDOWS
143 del /Q /F *.o libpolarssl.* libmbedtls.*
144endif