home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OpenStep 4.2J (Developer)
/
os42jdev.iso
/
NextDeveloper
/
Makefiles
/
pb_makefiles
/
depend.make
< prev
next >
Wrap
Text File
|
1997-03-20
|
3KB
|
119 lines
#
# depend.make
#
# Rules for updating dependencies
#
# PUBLIC TARGETS
# depend: builds individual dependency files and consolidates them into
# Makefile.dependencies.
#
# IMPORTED VARIABLES
# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is
# updated every time the project is built. If NO, the dependency
# file is only built when the depend target is invoked.
# BEFORE_DEPEND: targets to build before building dependencies for a
# subproject
# AFTER_DEPEND: targets to build after building dependencies for a
# subproject
#
#
# Implicit rule that creates a dependency file from a source file
#
.SUFFIXES: .d .dd
.c.d:
$(CC) $(ALL_COMMON_CFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.m.d:
$(CC) $(ALL_COMMON_MFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.C.d .cc.d .cxx.d .cpp.d:
$(CC) $(ALL_COMMON_CCFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.M.d:
$(CC) $(ALL_COMMON_MMFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.d.dd:
$(SED) 's/\.o[ :][ :]*/.d : /' < $< > $(SFILE_DIR)/$(*F).dd
ifeq "YES" "$(COMPUTE_DEPENDENCY_INFO)"
AFTER_PREBUILD += update-dependencies
endif
.PHONY: local-build depend local-depend recursive-depend announce-depend \
update-dependencies recompute-dependencies remove-Makefile.dependencies
#
# Variable definitions
#
ACTUAL_DEPEND = recompute-dependencies
ifeq "YES" "$(INCREMENTAL_DEPENDENCY_INFO)"
DEPENDS_CFLAGS = -MMD -dependency-file $(SFILE_DIR)/$*.d
# use only dependency info from modules that have been compiled so far
DFILES = $(shell ls $(SFILE_DIR)/*.d 2> $(NULL))
else
DFILES = $(CLASSES:.m=.d) $(MFILES:.m=.d) $(CFILES:.c=.d) $(CAPCFILES:.C=.d) $(CXXFILES:.cxx=.d) $(CPPFILES:.cpp=.d) $(CAPMFILES:.M=.d)
endif
DDFILES = $(DFILES:.d=.dd)
#
# First we update local dependencies, then we recurse.
#
depend: local-depend recursive-depend
recursive-depend: $(ALL_SUBPROJECTS:%=depend@%) local-depend
$(ALL_SUBPROJECTS:%=depend@%): local-depend
#
# Local dependencies update
#
local-depend: announce-depend $(BEFORE_DEPEND) $(ACTUAL_DEPEND) $(AFTER_DEPEND)
$(BEFORE_DEPEND): announce-depend
$(ACTUAL_DEPEND): announce-depend $(BEFORE_DEPEND)
$(AFTER_DEPEND): announce-depend $(BEFORE_DEPEND) $(ACTUAL_DEPEND)
#
# Before we do anything we must announce our intentions.
# We don't announce our intentions if we were hooked in from the
# post-depend recursion, since the post-depend has already been announced.
#
announce-depend:
ifndef RECURSING
$(SILENT) $(ECHO) Updating Makefile.dependencies...
else
$(SILENT) $(ECHO) $(RECURSIVE_ELLIPSIS)in $(NAME)
endif
#
# We may want to delete the old dependencies file before creating a new
# one in case some dependencies in the old file must be deleted.
#
recompute-dependencies: remove-Makefile.dependencies Makefile.dependencies
update-dependencies: Makefile.dependencies
#
# Remove Makefile dependencies
#
remove-Makefile.dependencies:
$(RM) -f $(SFILE_DIR)/Makefile.dependencies
remove-dependency-info:
$(CD) $(SFILE_DIR) && $(RM) -f $(DFILES) $(DDFILES)
#
# Update Makefile.dependencies
#
Makefile.dependencies: $(DFILES) $(DDFILES)
ifneq "$(words $(DFILES) $(DDFILES))" "0"
$(CAT) $(DFILES) $(DDFILES) > $(SFILE_DIR)/$(@F)
endif