#ident "@(#)r-smake.dep	1.15 15/03/26 "
###########################################################################
# Written 1996 by J. Schilling
###########################################################################
#
# Dependency building rules for smake
#
###########################################################################
# Copyright (c) J. Schilling
###########################################################################
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# See the file CDDL.Schily.txt in this distribution for details.
# A copy of the CDDL is also available via the Internet at
# http://www.opensource.org/licenses/cddl1.txt
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file CDDL.Schily.txt from this distribution.
###########################################################################
DEP_SUFFIX=	.d
RMDEP=		$(RM) $(RM_FORCE) $(ARCHDIR)/$@
___C++DEP_FILES= $(C++FILES:%.C=%.d)
__C++DEP_FILES=	$(___C++DEP_FILES:%.cc=%.d)
_C++DEP_FILES=	$(__C++DEP_FILES:%.cpp=%.d)
C++DEP_FILES=	$(_C++DEP_FILES:%.cxx=%.d)
C++PDEP_FILES=	$(C++DEP_FILES:%=$(ARCHDIR)/%)
DEP_FILE=	$(CFILES:%.c=%.d)		$(C++DEP_FILES)
PDEP_FILE=	$(CFILES:%.c=$(ARCHDIR)/%.d)	$(C++PDEP_FILES)
PALLDEP_FILE=	$(CFILES:%.c=$(ARCHDIR)/%.d)	$(C++PDEP_FILES)	$(ARCHDIR)/$(TARGET).dep
DEP_DEP=	$(ARCHDIR)/Dnull
###########################################################################
depend: rmdep $(DEP_FILE)

rmdep:
	$(RM) $(RM_FORCE) $(PALLDEP_FILE)

###########################################################################
#
# Make the complete path to the architecture subdirectory.
# Make $(ARCHDIR)/man as well here to avoid this directory to become root
# owned when root later calls "make install".
#
###########################################################################
$(ARCHDIR) $(ARCHDIR)/man:
		$(MKDIR) -p $@

###########################################################################
#
# Generate dependency file(s).
# This rules is checked when the dependency file(s) are included.
#
# Modify the the path for .o files to reflect that they are placed in
# $(ARCHDIR). Add the dependency file itself to each line so that
# the dependencies will be rebuilt if a source is newer that the
# appropriate dependency file.
#
###########################################################################

# Do not define Simple Suffix Rules anymore
#.d:	.c
#	$(MKDEP) $(CPPFLAGS) $(MKDEP_OUT) $< \
#		| sed -e 's;^\(.*\)\.$o[ 	]*:;\1.$o \1.d:;' > $(ARCHDIR)/$@

%.d: %.c
	$(MKDEP) $(CPPFLAGS) $(MKDEP_OUT) $< \
		| sed -e 's;^\(.*\)\.$o[ 	]*:;\1.$o \1.d:;' > $(ARCHDIR)/$@

%.d: %.C
	$(MKC++DEP) $(CPPFLAGS) $(MKC++DEP_OUT) $< \
		| sed -e 's;^\(.*\)\.$o[ 	]*:;\1.$o \1.d:;' > $(ARCHDIR)/$@
%.d: %.cc
	$(MKC++DEP) $(CPPFLAGS) $(MKC++DEP_OUT) $< \
		| sed -e 's;^\(.*\)\.$o[ 	]*:;\1.$o \1.d:;' > $(ARCHDIR)/$@
%.d: %.cpp
	$(MKC++DEP) $(CPPFLAGS) $(MKC++DEP_OUT) $< \
		| sed -e 's;^\(.*\)\.$o[ 	]*:;\1.$o \1.d:;' > $(ARCHDIR)/$@
%.d: %.cxx
	$(MKC++DEP) $(CPPFLAGS) $(MKC++DEP_OUT) $< \
		| sed -e 's;^\(.*\)\.$o[ 	]*:;\1.$o \1.d:;' > $(ARCHDIR)/$@

$(DEP_DEP):
	@if [ ! -f $@ ]; then				\
		echo "	==> MAKING DIRECTORY \"$(ARCHDIR)\"";	\
		$(_MKDIR) -p $(ARCHDIR);		\
		echo "	==> MAKING DIRECTORY \"$(ARCHDIR)/man\""; \
		$(_MKDIR) -p $(ARCHDIR)/man;		\
		echo > $@;				\
	fi

#$(DEP_FILE):
#		$(MKDEP) $(CPPFLAGS) -f - $(CFILES) \
#			| sed -e 's;^\(.*\.$o[ 	]*:\);$(ARCHDIR)/\1;' > $@

###########################################################################
#
# Include the dependency file(s) generated from the rules above.
#
###########################################################################
-include	$(DEP_DEP) $(DEP_FILE)
