summaryrefslogtreecommitdiffstats
path: root/rbutil/libtools.make
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/libtools.make')
-rw-r--r--rbutil/libtools.make12
1 files changed, 11 insertions, 1 deletions
diff --git a/rbutil/libtools.make b/rbutil/libtools.make
index 054a1c2c5a..93ce9532a6 100644
--- a/rbutil/libtools.make
+++ b/rbutil/libtools.make
@@ -74,10 +74,12 @@ endif
WINDRES = windres
BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET)
-OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/
ifdef RBARCH
CFLAGS += -arch $(RBARCH)
+OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/
+else
+OBJDIR = $(abspath $(BUILD_DIR))/
endif
all: $(BINARY)
@@ -85,7 +87,11 @@ all: $(BINARY)
OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(SOURCES))))
LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES))))
+# create dependency files. Make sure to use the same prefix as with OBJS!
$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(subst .c,.o,$(notdir $(src)))): $(src)))
+$(foreach src,$(SOURCES) $(LIBSOURCES),$(eval $(addprefix $(OBJDIR),$(subst .c,.d,$(notdir $(src)))): $(src)))
+DEPS = $(addprefix $(OBJDIR),$(subst .c,.d,$(notdir $(SOURCES) $(LIBSOURCES))))
+-include $(DEPS)
# additional link dependencies for the standalone executable
# extra dependencies: libucl
@@ -135,6 +141,10 @@ clean:
rm -f $(OBJS) $(OUTPUT) $(TARGET_DIR)lib$(OUTPUT)*.a $(OUTPUT).dmg
rm -rf $(OUTPUT)-* i386 ppc $(OBJDIR)
+%.d:
+ $(SILENT)$(call mkdir,$(BUILD_DIR))
+ $(SILENT)$(CC) -MG -MM -MT $(subst .d,.o,$@) $(CFLAGS) -o $(BUILD_DIR)/$(notdir $@) $<
+
# extra tools
BIN2C = $(TOP)/tools/bin2c
$(BIN2C):