build: Makefile: cleanup LDFLAGS
LDFLAGS are reserved for external interaction via make variable, the
following should work:
$ make LDFLAGS="-L/xxx"
$ LDFLAGS="-L/xxx" make
1. Move internal flags to LOCAL_LDFLAGS
2. Respect external LDFLAGS
3. LDFLAGS should be last linkage flags.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
diff --git a/library/Makefile b/library/Makefile
index de00f75..d28c1b2 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -1,11 +1,10 @@
# Also see "include/polarssl/config.h"
-# To compile on MinGW: add "-lws2_32" to LDFLAGS or define WINDOWS in your
-# environment
-#
CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement
OFLAGS = -O2
+LDFLAGS ?=
+LOCAL_LDFLAGS =
ifdef DEBUG
CFLAGS += -g3
@@ -26,7 +25,7 @@
ifdef SHARED
# all code is position-indep with mingw, avoid warning about useless flag
ifndef WINDOWS_BUILD
-CFLAGS += -fPIC
+LOCAL_CFLAGS += -fPIC
endif
endif
@@ -39,7 +38,6 @@
# Windows shared library extension:
ifdef WINDOWS_BUILD
DLEXT=dll
-LDFLAGS += -lws2_32
endif
OBJS= aes.o aesni.o arc4.o \
@@ -114,7 +112,7 @@
libmbedtls.$(SOEXT): $(OBJS)
echo " LD $@"
- $(CC) ${LDFLAGS} -shared -Wl,-soname,$@ -o $@ $(OBJS)
+ $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS)
libmbedtls.so: libmbedtls.$(SOEXT)
echo " LN $@ -> libmbedtls.$(SOEXT)"
@@ -122,11 +120,11 @@
libmbedtls.dylib: $(OBJS)
echo " LD $@"
- $(CC) ${LDFLAGS} -dynamiclib -o $@ $(OBJS)
+ $(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS)
libmbedtls.dll: $(OBJS)
echo " LD $@"
- $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32
+ $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
.c.o:
echo " CC $<"