Makefile 4.05 KB
Newer Older
1

2
# Also see "include/mbedtls/config.h"
3

4 5
CFLAGS	?= -O2
WARNING_CFLAGS ?=  -Wall -W -Wdeclaration-after-statement
6
LDFLAGS ?=
7 8

LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
9
LOCAL_LDFLAGS =
10

11
ifdef DEBUG
12
LOCAL_CFLAGS += -g3
13 14
endif

15 16
# MicroBlaze specific options:
# CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift
17

18 19
# To compile on Plan9:
# CFLAGS += -D_BSD_EXTENSION
20

21 22 23 24 25
# if were running on Windows build for Windows
ifdef WINDOWS
WINDOWS_BUILD=1
endif

26
# To compile as a shared library:
27
ifdef SHARED
28
# all code is position-indep with mingw, avoid warning about useless flag
29
ifndef WINDOWS_BUILD
30
LOCAL_CFLAGS += -fPIC -fpic
31
endif
32
endif
33

Paul Bakker's avatar
Paul Bakker committed
34
SOEXT_TLS=so.10
35 36
SOEXT_X509=so.0
SOEXT_CRYPTO=so.0
37

38
DLEXT=so
39 40
# OSX shared library extension:
# DLEXT=dylib
41

42 43
# Windows shared library extension:
ifdef WINDOWS_BUILD
44 45
DLEXT=dll
endif
46

47 48 49 50 51
OBJS_CRYPTO=	aes.o		aesni.o		arc4.o		\
		asn1parse.o	asn1write.o	base64.o	\
		bignum.o	blowfish.o	camellia.o	\
		ccm.o		cipher.o	cipher_wrap.o	\
		ctr_drbg.o	des.o		dhm.o		\
52 53
		ecdh.o		ecdsa.o		ecjpake.o	\
		ecp.o						\
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
		ecp_curves.o	entropy.o	entropy_poll.o	\
		error.o		gcm.o		havege.o	\
		hmac_drbg.o	md.o		md2.o		\
		md4.o		md5.o		md_wrap.o	\
		memory_buffer_alloc.o		oid.o		\
		padlock.o	pem.o		pk.o		\
		pk_wrap.o	pkcs12.o	pkcs5.o		\
		pkparse.o	pkwrite.o	platform.o	\
		ripemd160.o	rsa.o		sha1.o		\
		sha256.o	sha512.o	threading.o	\
		timing.o	version.o			\
		version_features.o		xtea.o

OBJS_X509=	certs.o		pkcs11.o	x509.o		\
		x509_create.o	x509_crl.o	x509_crt.o	\
		x509_csr.o	x509write_crt.o	x509write_csr.o

71 72 73 74
OBJS_TLS=	debug.o		net_sockets.o		\
		ssl_cache.o	ssl_ciphersuites.o	\
		ssl_cli.o	ssl_cookie.o		\
		ssl_srv.o	ssl_ticket.o		\
75 76
		ssl_tls.o

77
.SILENT:
78

79 80
.PHONY: all static shared clean

81
ifndef SHARED
82
all: static
83
else
84
all: shared static
85
endif
86

87
static: libmbedcrypto.a libmbedx509.a libmbedtls.a
88

89
shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)
90

91 92
# tls
libmbedtls.a: $(OBJS_TLS)
93
	echo "  AR    $@"
94
	$(AR) -rc $@ $(OBJS_TLS)
95
	echo "  RL    $@"
96
	$(AR) -s $@
97

98
libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so
99
	echo "  LD    $@"
100
	$(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto -lmbedx509 $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
101

102 103 104
libmbedtls.so: libmbedtls.$(SOEXT_TLS)
	echo "  LN    $@ -> $<"
	ln -sf $< $@
105

106 107 108 109
libmbedtls.dylib: $(OBJS_TLS)
	echo "  LD    $@"
	$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)

110
libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll
111
	echo "  LD    $@"
112
	$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -lmbedx509 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
113 114 115 116

# x509
libmbedx509.a: $(OBJS_X509)
	echo "  AR    $@"
117
	$(AR) -rc $@ $(OBJS_X509)
118
	echo "  RL    $@"
119
	$(AR) -s $@
120

121
libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so
122
	echo "  LD    $@"
123
	$(CC) -shared -Wl,-soname,$@ -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
124

125 126 127
libmbedx509.so: libmbedx509.$(SOEXT_X509)
	echo "  LN    $@ -> $<"
	ln -sf $< $@
128 129 130 131 132

libmbedx509.dylib: $(OBJS_X509)
	echo "  LD    $@"
	$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)

133
libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll
134
	echo "  LD    $@"
135
	$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
136

137 138 139
# crypto
libmbedcrypto.a: $(OBJS_CRYPTO)
	echo "  AR    $@"
140
	$(AR) -rc $@ $(OBJS_CRYPTO)
141
	echo "  RL    $@"
142
	$(AR) -s $@
143

144
libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO)
145
	echo "  LD    $@"
146
	$(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
147

148 149 150
libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO)
	echo "  LN    $@ -> $<"
	ln -sf $< $@
151 152 153 154 155 156 157

libmbedcrypto.dylib: $(OBJS_CRYPTO)
	echo "  LD    $@"
	$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)

libmbedcrypto.dll: $(OBJS_CRYPTO)
	echo "  LD    $@"
158
	$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
159

160
.c.o:
Paul Bakker's avatar
Paul Bakker committed
161
	echo "  CC    $<"
162
	$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $<
163 164

clean:
165
ifndef WINDOWS
166 167 168
	rm -f *.o libmbed*
else
	del /Q /F *.o libmbed*
169
endif