From 814a73227f9571d8fbd831fedced5e87cd9c926b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 9 Jan 2014 16:54:01 +0100 Subject: [PATCH] Remove duplicate elements from *_SOURCES This is useful when you do: foo_SOURCES := $(wildcard *.cc) foo.cc where foo.cc is a generated file. In this case, if foo.cc already exists, you get foo.cc twice in foo_SOURCES, leading to a link error. --- libraries.mk | 2 +- programs.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries.mk b/libraries.mk index bc258b799..98cc9f363 100644 --- a/libraries.mk +++ b/libraries.mk @@ -35,7 +35,7 @@ libs_list := define build-library = $(1)_NAME ?= $(1) _d := $$(strip $$($(1)_DIR)) - _srcs := $$(foreach src, $$($(1)_SOURCES), $$(src)) + _srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src))) $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs))) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) diff --git a/programs.mk b/programs.mk index 52e55598c..a97a51635 100644 --- a/programs.mk +++ b/programs.mk @@ -17,7 +17,7 @@ programs_list := # installed; defaults to $(bindir). define build-program = _d := $$($(1)_DIR) - _srcs := $$(foreach src, $$($(1)_SOURCES), $$(src)) + _srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src))) $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs))) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) $(1)_PATH := $$(_d)/$(1)