summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2012-06-13 14:56:16 -0400
committerOri Bernstein <orib@google.com>2012-06-13 14:56:16 -0400
commit829b70e103c2f1eb5cf57c02e84fe80675cc3e5d (patch)
treed6aa51c07561391268efa1b7e179f7a7a99a778d /mk
parent5c83c38422a419510708fe7ff93c5f71a6c0ce5c (diff)
downloadmc-829b70e103c2f1eb5cf57c02e84fe80675cc3e5d.tar.gz
Rebuild dependent libraries. Also, don't rely on cflags/ldflags.
Diffstat (limited to 'mk')
-rw-r--r--mk/c.mk31
1 files changed, 21 insertions, 10 deletions
diff --git a/mk/c.mk b/mk/c.mk
index d2524e3..a2364ae 100644
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -1,9 +1,13 @@
-DEPSDIR = .deps
-DEPS=$(addprefix $(DEPSDIR)/, $(OBJ:.o=.d))
+_DEPSDIR = .deps
+_DEPS=$(addprefix $(_DEPSDIR)/, $(OBJ:.o=.d))
+
+_LIBSRCHPATHS=$(addprefix -L, $(dir $(LIBDEPS)))
+_LIBINCPATHS=$(addprefix -I, $(dir $(LIBDEPS)))
+_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(LIBDEPS))))
CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
CFLAGS += -g
-CFLAGS += -MMD -MP -MF ${DEPSDIR}/$(subst /,-,$*).d
+CFLAGS += -MMD -MP -MF ${_DEPSDIR}/$(subst /,-,$*).d
.PHONY: clean clean-gen clean-bin clean-obj clean-misc clean-backups
.PHONY: all
@@ -11,11 +15,18 @@ CFLAGS += -MMD -MP -MF ${DEPSDIR}/$(subst /,-,$*).d
all: subdirs $(BIN) $(LIB) $(EXTRA)
install: subdirs-install install-bin install-lib install-hdr install-pc
-$(LIB): $(OBJ)
- $(AR) -rcs $@ $^
+$(LIB): $(OBJ) libs
+ $(AR) -rcs $@ $(OBJ)
+
+$(BIN): $(OBJ) $(EXTRADEP) libs
+ $(CC) -o $@ $(OBJ) $(_LIBSRCHPATHS) $(_LIBPATHS)
-$(BIN): $(OBJ) $(EXTRADEP)
- $(CC) -o $@ $(OBJ) $(LDFLAGS)
+libs: $(LIBDEPS)
+ @for i in $(dir $(LIBDEPS)); do (\
+ cd $$i && \
+ $(MAKE) || \
+ exit 1 \
+ ) || exit 1; done
subdirs:
@for i in $(SUB); do (\
@@ -64,10 +75,10 @@ clean-backups:
find ./ -name *.bak -exec rm -f {} \;
%.o: %.c .deps
- $(CC) -c $(CFLAGS) $<
+ $(CC) -c $(CFLAGS) $(_LIBINCPATHS) $<
.deps:
- mkdir -p $(DEPSDIR)
+ mkdir -p $(_DEPSDIR)
--include $(DEPS)
+-include $(_DEPS)