# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
_BUILD_TARGETS := _prebuild _build _postbuild
+
+comma := ,
+linkerprefix = $(subst -Wl$(comma)-L,-L,$(addprefix -Wl$(comma),$1))
endif
ifeq ($(LINK_USING_CC),1)
-comma := ,
-LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
-LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
-override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
+LDLIBS := $(call linkerprefix,$(LDLIBS))
+LDFLAGS := $(call linkerprefix,$(LDFLAGS))
+override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
O_TO_EXE = $(CC) $(CFLAGS) $(LDFLAGS_$(@)) \
-Wl,-Map=$(@).map,--cref -o $@ $(OBJS-y) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS)
else
exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
ifeq ($(LINK_USING_CC),1)
-comma := ,
-LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS))
-LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS))
-override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS))
+LDLIBS := $(call linkerprefix,$(LDLIBS))
+LDFLAGS := $(call linkerprefix,$(LDFLAGS))
+override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
O_TO_SO = $(CC) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
-shared -o $@ $(OBJS-y) $(LDLIBS)
else