[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Automatic dependencies in gnustep-make
From: |
Malmberg |
Subject: |
Automatic dependencies in gnustep-make |
Date: |
Thu, 22 Nov 2001 02:27:27 +0100 |
Hi,
I've attached a small patch to rules.make that adds automatic dependency
tracking (a feature I've really missed). It's controlled by the
auto_dependencies variable, so 'make auto_dependencies=yes' would
activate it. Putting 'auto_dependencies=yes' in config.make makes it
active by default.
The patch relies on gcc doing the 'right thing' with -MMD, so it works
with v3, but not v2.95.2. The .d files (with dependency information) are
stored in $(GNUSTEP_OBJ_DIR). It works with c, obj-c, and c++ files, and
(as far as I can tell) with all types of projects. I'm no export on
gnustep-make internals, though, so comments would be appreciated.
(Note that you'll need to 'make clean' before using it in a project so
the .d files will be generated.)
- Alexander Malmberg
Index: rules.make
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/make/rules.make,v
retrieving revision 1.117
diff -u -r1.117 rules.make
--- rules.make 2001/11/13 15:09:07 1.117
+++ rules.make 2001/11/22 01:09:41
@@ -307,53 +307,60 @@
# file.m_FILE_FILTER_OUT_FLAGS = -Wno-import
#
+ifeq ($(auto_dependencies),yes)
+auto_dependencies_flag=-MMD -MP
+else
+auto_dependencies_flag=
+endif
+
# Please don't be scared by the following rules ... In normal
# situations, $<_FILTER_OUT_FLAGS is empty, and $<_FILE_FLAGS is empty
# as well, so the following rule is simply equivalent to
# $(CC) $< -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@
# and similarly all the rules below
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.c
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_CFLAGS)) \
$($<_FILE_FLAGS) -o $@
+
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.m
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_OBJCFLAGS)) \
$($<_FILE_FLAGS) -o $@
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.C
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_CFLAGS) \
$(ALL_CCFLAGS)) \
$($<_FILE_FLAGS) -o $@
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.cc
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_CFLAGS) \
$(ALL_CCFLAGS)) \
$($<_FILE_FLAGS) -o $@
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.cpp
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_CFLAGS) \
$(ALL_CCFLAGS)) \
$($<_FILE_FLAGS) -o $@
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.cxx
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_CFLAGS) \
$(ALL_CCFLAGS)) \
$($<_FILE_FLAGS) -o $@
$(GNUSTEP_OBJ_DIR)/%${OEXT} : %.cp
- $(CC) $< -c \
+ $(CC) $< -c $(auto_dependencies_flag) \
$(filter-out $($<_FILE_FILTER_OUT_FLAGS),$(ALL_CPPFLAGS) \
$(ALL_CFLAGS) \
$(ALL_CCFLAGS)) \
@@ -632,6 +639,12 @@
# tool/app/whatever
OBJ_FILES_TO_LINK = $(C_OBJ_FILES) $(OBJC_OBJ_FILES) $(CC_OBJ_FILES) \
$(SUBPROJECT_OBJ_FILES) $(OBJ_FILES)
+
+ifeq ($(auto_dependencies),yes)
+ifneq ($(strip $(OBJ_FILES_TO_LINK)),)
+-include $(addsuffix .d, $(basename $(OBJ_FILES_TO_LINK)))
+endif
+endif
# If we are using Windows32 DLLs, for each library that we link
# against, pass a -Dlib{library_name}_ISDLL=1 option to the
- Automatic dependencies in gnustep-make,
Malmberg <=