All GCC final arch/*/src/Makefiles: Allow --start-group and --end-group to be redefined for the case where GCC is used to link (instead of LD). Suggested by Paul Alexander Patience.

This commit is contained in:
Gregory Nutt 2016-05-17 10:43:15 -06:00
parent 8bd57a7fbc
commit fb484a581f
8 changed files with 71 additions and 31 deletions

View file

@ -1,7 +1,7 @@
############################################################################
# arch/arm/src/Makefile
#
# Copyright (C) 2007-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
# Copyright (C) 2007-2009, 2011-2012, 2014-2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -127,6 +127,11 @@ BIN = libarch$(LIBEXT)
LDFLAGS += $(ARCHSCRIPT)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
EXTRA_LIBS ?=
EXTRA_LIBPATHS ?=
LINKLIBS ?=
@ -198,7 +203,7 @@ nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT)
$(Q) echo "LD: nuttx"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
-o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP)
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) $(NM) $(NUTTX) | \
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \

View file

@ -1,7 +1,7 @@
############################################################################
# arch/avr/src/Makefile
#
# Copyright (C) 2010-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2010-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -83,6 +83,11 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDFLAGS += $(ARCHSCRIPT)
EXTRA_LIBS ?=
LINKLIBS ?=
@ -139,7 +144,7 @@ board/libboard$(LIBEXT):
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
@echo "LD: nuttx"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP)
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) $(NM) $(NUTTX) | \
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \

View file

@ -1,7 +1,7 @@
############################################################################
# arch/hc/src/Makefile
#
# Copyright (C) 2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2009, 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -83,6 +83,11 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDFLAGS += $(ARCHSCRIPT)
EXTRA_LIBS ?=
LINKLIBS ?=
@ -138,7 +143,7 @@ board/libboard$(LIBEXT):
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
$(Q) echo "LD: nuttx"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP)
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) $(NM) $(NUTTX)$(EXEEXT) | \
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \

View file

@ -1,7 +1,7 @@
############################################################################
# arch/mips/src/Makefile
#
# Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -80,6 +80,11 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDFLAGS += $(ARCHSCRIPT)
EXTRA_LIBS ?=
LINKLIBS ?=
@ -136,7 +141,7 @@ board/libboard$(LIBEXT):
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
@echo "LD: nuttx"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP)
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) $(NM) $(NUTTX)$(EXEEXT) | \
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \

View file

@ -1,7 +1,7 @@
############################################################################
# arch/rgmp/src/Makefile
#
# Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -39,25 +39,30 @@ include $(CONFIG_RGMP_SUBARCH)/Make.defs
RGMP_ARCH_ASRCS := $(addprefix $(CONFIG_RGMP_SUBARCH)/,$(RGMP_ARCH_ASRCS))
RGMP_ARCH_CSRCS := $(addprefix $(CONFIG_RGMP_SUBARCH)/,$(RGMP_ARCH_CSRCS))
CPPFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES)
CFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES)
CXXFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES)
CPPFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES)
CFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES)
CXXFLAGS += -I$(TOPDIR)/sched -I$(TOPDIR)/fs $(EXTRADEFINES)
ASRCS = $(RGMP_ARCH_ASRCS)
CSRCS = nuttx.c cxx.c $(RGMP_ARCH_CSRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
ASRCS = $(RGMP_ARCH_ASRCS)
CSRCS = nuttx.c cxx.c $(RGMP_ARCH_CSRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
LINKSRCS = rgmp.c bridge.c
LINKOBJS = $(LINKSRCS:.c=$(OBJEXT))
LINKSRCS = rgmp.c bridge.c
LINKOBJS = $(LINKSRCS:.c=$(OBJEXT))
LDFLAGS += -T$(RGMPLKSCPT)
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
LIBPATHS += -L"$(TOPDIR)/lib" -L$(RGMPLIBDIR)
LDLIBS += -lrgmp $(shell "$(CC)" -print-libgcc-file-name)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDFLAGS += -T$(RGMPLKSCPT)
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
LIBPATHS += -L"$(TOPDIR)/lib" -L$(RGMPLIBDIR)
LDLIBS += -lrgmp $(shell "$(CC)" -print-libgcc-file-name)
all: libarch$(LIBEXT)
@ -79,7 +84,7 @@ libarch$(LIBEXT): $(OBJS)
nuttx$(EXEEXT): $(LINKOBJS)
@echo "LD: nuttx$(EXEEXT)"
@$(LD) $(LDFLAGS) $(LIBPATHS) $(LINKOBJS) --start-group $(LDLIBS) $(EXTRA_LIBS) --end-group -o $(TOPDIR)/$@
@$(LD) $(LDFLAGS) $(LIBPATHS) $(LINKOBJS) $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP) -o $(TOPDIR)/$@
@$(OBJDUMP) -S $(TOPDIR)/$@ > $(TOPDIR)/nuttx.asm
@$(NM) -n $(TOPDIR)/$@ > $(TOPDIR)/nuttx.sym
@$(OBJCOPY) -S -O binary $(TOPDIR)/$@ nuttx.img

View file

@ -1,7 +1,7 @@
############################################################################
# arch/sh/src/Makefile
#
# Copyright (C) 2008, 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2008, 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -78,6 +78,11 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDFLAGS += $(ARCHSCRIPT)
EXTRA_LIBS ?=
LINKLIBS ?=
@ -134,7 +139,7 @@ board/libboard$(LIBEXT):
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
@echo "LD: nuttx"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(TOPDIR)/$@ $(HEAD_OBJ) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP)
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) $(NM) $(TOPDIR)/$@ | \
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \

View file

@ -1,7 +1,7 @@
############################################################################
# arch/sim/src/Makefile
#
# Copyright (C) 2007, 2008, 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2007, 2008, 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -154,6 +154,11 @@ ifeq ($(CONFIG_SIM_X11FB),y)
STDLIBS += -lX11 -lXext
endif
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
EXTRA_LIBS ?=
EXTRA_LIBPATHS ?=
@ -245,7 +250,7 @@ endif
nuttx.rel : libarch$(LIBEXT) board/libboard$(LIBEXT) $(HOSTOS)-names.dat $(LINKOBJS)
$(Q) echo "LD: nuttx.rel"
$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o $@ $(REQUIREDOBJS) --start-group $(RELLIBS) $(EXTRA_LIBS) --end-group
$(Q) $(LD) -r $(LDLINKFLAGS) $(RELPATHS) $(EXTRA_LIBPATHS) -o $@ $(REQUIREDOBJS) $(LDSTARTGROUP) $(RELLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
$(Q) $(OBJCOPY) --redefine-syms=$(HOSTOS)-names.dat $@
# Generate the final NuttX binary by linking the host-specific objects with the NuttX

View file

@ -1,7 +1,7 @@
############################################################################
# arch/x86/src/Makefile
#
# Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -80,6 +80,11 @@ COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
# Override in Make.defs if linker is not 'ld'
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LDFLAGS += $(ARCHSCRIPT)
EXTRA_LIBS ?=
LINKLIBS ?=
@ -144,7 +149,7 @@ board/libboard$(LIBEXT):
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT)
@echo "LD: nuttx$(EXEEXT)"
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX)$(EXEEXT) $(HEAD_OBJ) $(EXTRA_OBJS) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP)
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) $(NM) $(NUTTX)$(EXEEXT) | \
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \