summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-01-12 11:08:03 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-01-13 13:05:38 +0200
commitea429635388f7bb53f62c41ec3d5ccf5fa207370 (patch)
tree6a7ef4423364fbb256da708cd38356657b6624e6
parente95a99a2c5ffb5ae1bf0f69bc553f591e57815e2 (diff)
common.mk: tweak rules to workaround make-3.80 bugs
I got some reports from people who use make-3.80 that mtd-utils wasn't building correctly the first time. Turns out that older versions of make misbehave with pattern rules and full paths. So I've tweaked the code a little to work with make-3.80 and make-3.81 (the latest release). Also, I added a small optimization to avoid running `mkdir` when building in-tree. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--common.mk5
1 files changed, 4 insertions, 1 deletions
diff --git a/common.mk b/common.mk
index 5dd21ab..77d28bf 100644
--- a/common.mk
+++ b/common.mk
@@ -19,6 +19,7 @@ else
BUILDDIR := $(PWD)/$(CROSS:-=)
endif
endif
+override BUILDDIR := $(patsubst %/,%,$(BUILDDIR))
override TARGETS := $(addprefix $(BUILDDIR)/,$(TARGETS))
@@ -33,7 +34,7 @@ clean:: $(SUBDIRS_CLEAN)
install:: $(TARGETS) $(SUBDIRS_INSTALL)
-$(BUILDDIR)/%: $(BUILDDIR)/%.o
+%: %.o
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_$(notdir $@)) -g -o $@ $^ $(LDLIBS) $(LDLIBS_$(notdir $@))
$(BUILDDIR)/%.a:
@@ -41,7 +42,9 @@ $(BUILDDIR)/%.a:
$(RANLIB) $@
$(BUILDDIR)/%.o: %.c
+ifneq ($(BUILDDIR),$(CURDIR))
mkdir -p $(dir $@)
+endif
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(<F).dep
subdirs_%: