diff options
Diffstat (limited to 'demos/ARM7-LPC214x-GCC-minimal/Makefile')
-rw-r--r-- | demos/ARM7-LPC214x-GCC-minimal/Makefile | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/demos/ARM7-LPC214x-GCC-minimal/Makefile b/demos/ARM7-LPC214x-GCC-minimal/Makefile index 93e7df446..d035f6f23 100644 --- a/demos/ARM7-LPC214x-GCC-minimal/Makefile +++ b/demos/ARM7-LPC214x-GCC-minimal/Makefile @@ -26,6 +26,9 @@ BIN = $(CP) -O binary MCU = arm7tdmi
+# Enable this if you want the linker to remove unused code and data
+LINK_GC = yes
+
# List all default C defines here, like -D_DEBUG=1
DDEFS =
@@ -111,6 +114,10 @@ WARN = -Wall -Wstrict-prototypes # End of user defines
##############################################################################################
+ifeq ($(LINK_GC),yes)
+ OPT += -ffunction-sections -fdata-sections
+endif
+
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
@@ -122,10 +129,14 @@ ASMOBJS = $(ASMSRC:.s=.o) LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
+ODFLAGS = -x --syms
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
-LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
-ODFLAGS = -x --syms
+ifeq ($(LINK_GC),yes)
+ LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LIBDIR)
+else
+ LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
+endif
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
|