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>
This commit is contained in:
Alon Bar-Lev 2015-02-18 17:47:52 +02:00 committed by Manuel Pégourié-Gonnard
parent 06f0d26240
commit ada4105ba2
3 changed files with 118 additions and 120 deletions

View file

@ -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 @@ endif
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 @@ DLEXT=so
# Windows shared library extension:
ifdef WINDOWS_BUILD
DLEXT=dll
LDFLAGS += -lws2_32
endif
OBJS= aes.o aesni.o arc4.o \
@ -114,7 +112,7 @@ endif
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.so: libmbedtls.$(SOEXT)
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 $<"