build: Makefile: cleanup CFLAGS
CFLAGS are reserved for external interaction via make variable, the
following should work:
$ make CFLAGS="-O3"
$ CFLAGS="-O3" make
1. Move internal flags to LOCAL_CFLAGS
2. Respect external CFLAGS
3. CFLAGS should be last compiler flags.
4. Default CFLAGS is -O optimization, remove OFLAGS.
5. Add WARNING_CFLAGS to control warning setting and enable to remove
if compiler does not support flags.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
diff --git a/library/Makefile b/library/Makefile
index d28c1b2..d099471 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -1,13 +1,15 @@
# Also see "include/polarssl/config.h"
-CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement
-OFLAGS = -O2
+CFLAGS ?= -O2
+WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
LDFLAGS ?=
+
+LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
LOCAL_LDFLAGS =
ifdef DEBUG
-CFLAGS += -g3
+LOCAL_CFLAGS += -g3
endif
# MicroBlaze specific options:
@@ -25,7 +27,7 @@
ifdef SHARED
# all code is position-indep with mingw, avoid warning about useless flag
ifndef WINDOWS_BUILD
-LOCAL_CFLAGS += -fPIC
+LOCAL_CFLAGS += -fPIC -fpic
endif
endif
@@ -128,7 +130,7 @@
.c.o:
echo " CC $<"
- $(CC) $(CFLAGS) $(OFLAGS) -c $<
+ $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $<
clean:
ifndef WINDOWS