1#ident "@(#)r-make.dep	1.13 21/04/28 "
2###########################################################################
3# Written 1996-2019 by J. Schilling
4###########################################################################
5#
6# Dependency building rules for make
7#
8###########################################################################
9# Copyright (c) J. Schilling
10###########################################################################
11# The contents of this file are subject to the terms of the
12# Common Development and Distribution License, Version 1.0 only
13# (the "License").  You may not use this file except in compliance
14# with the License.
15#
16# See the file CDDL.Schily.txt in this distribution for details.
17# A copy of the CDDL is also available via the Internet at
18# http://www.opensource.org/licenses/cddl1.txt
19#
20# When distributing Covered Code, include this CDDL HEADER in each
21# file and include the License file CDDL.Schily.txt from this distribution.
22###########################################################################
23#	Note that we currently do not support C++ with Sun make as Sun make
24#	only allows one file to folllow a include directive
25#
26DEP_SUFFIX=	.dep
27RMDEP=		$(RM) $(RM_FORCE) $@
28___C++DEP_FILES= $(C++FILES:%.C=$(ARCHDIR)/%.d)
29__C++DEP_FILES=	$(___C++DEP_FILES:%.cc=$(ARCHDIR)/%.d)
30_C++DEP_FILES=	$(__C++DEP_FILES:%.cpp=$(ARCHDIR)/%.d)
31C++DEP_FILES=	$(_C++DEP_FILES:%.cxx=$(ARCHDIR)/%.d)
32C++PDEP_FILES=	$(C++DEP_FILES)
33DEP_FILE=	$(ARCHDIR)/$(TARGET).dep
34PDEP_FILE=	$(ARCHDIR)/$(TARGET).dep
35PALLDEP_FILE=	$(CFILES:%.c=$(ARCHDIR)/%.d)	$(C++PDEP_FILES) $(ARCHDIR)/$(TARGET).dep
36DEP_DEP=	$(ARCHDIR)/Dnull
37###########################################################################
38depend: rmdep $(DEP_FILE)
39
40rmdep:
41	$(RM) $(RM_FORCE) $(PALLDEP_FILE)
42
43###########################################################################
44#
45# Make the complete path to the architecture subdirectory.
46# Make $(ARCHDIR)/man as well here to avoid this directory to become root
47# owned when root later calls "make install".
48#
49###########################################################################
50$(ARCHDIR) $(ARCHDIR)/man:
51		$(MKDIR) -p $@
52
53###########################################################################
54#
55# Generate dependency file(s).
56# This rules is checked when the dependency file(s) are included.
57#
58# Modify the the path for .o files to reflect that they are placed in
59# $(ARCHDIR). Add the dependency file itself to each line so that
60# the dependencies will be rebuilt if a source is newer that the
61# appropriate dependency file.
62#
63###########################################################################
64$(ARCHDIR)/%.dep: %.c
65		$(MKDEP) $(CPP_FLAGS) $(CPPFLAGS) $(MKDEP_OUT) $< \
66			| sed -e 's;^\(.*\)\.$o[ 	]*:;$(ARCHDIR)/\1.$o $(DEP_FILE):;' > $@
67
68$(DEP_FILE):	$(DEP_DEP) $(CFILES)
69		$(MKDEP) $(CPP_FLAGS) $(CPPFLAGS) $(MKDEP_OUT) $(CFILES) \
70			| sed -e 's;^\(.*\)\.$o[ 	]*:;$(ARCHDIR)/\1.$o $(DEP_FILE):;' > $@
71
72$(DEP_DEP):
73	$(NOECHO)if [ ! -f $@ ]; then				\
74		echo "	==> MAKING DIRECTORY \"$(ARCHDIR)\"";	\
75		$(_MKDIR) -p $(ARCHDIR);		\
76		echo "	==> MAKING DIRECTORY \"$(ARCHDIR)/man\""; \
77		$(_MKDIR) -p $(ARCHDIR)/man;		\
78		echo > $@;				\
79	else						\
80		: work around v7 shell bug;		\
81	fi
82
83###########################################################################
84#
85# Include the dependency file(s) generated from the rules above.
86#
87###########################################################################
88include		$(DEP_FILE)
89