This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Try #3 at the .7 implicit rule problem
- From: Kelley Cook <kcook34 at ford dot com>
- To: Nathanael Nerode <neroden at twcny dot rr dot com>
- Cc: zack at codesourcery dot com, mark at codesourcery dot com, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 23 Oct 2003 14:25:45 -0400
- Subject: Try #3 at the .7 implicit rule problem
- Hop-count: 1
- Reply-to: Kelley Cook <kelleycook at wideopenwest dot com>
>>GNU Make always uses the rule itself when determining $<. If you use
>>$+, you do get all of the dependencies -- but the ones not in the rule
>>itself come after the ones in the rule.
>
> Indeed, I just verified this. :-)
>
> However, note that Kelley's proposed patch contains *no* dependencies
> in the rules themselves, and *does* therefore generate difficult order
> dependencies.
... one day later after pouring through the Make manual and doing lots
of experimenting ...
First of all, as Mark alluded to, addtional dependencies are appended to
the rule being executed. Therefore, in the case of implicit rules a $<
will either refer to the first dependency listed on the implicit rule or
to the first dependency on the command-less specific rule that caused
the implicit rule to be run.
The manual does mention that an implicit rule is allowed to be without
dependencies. This, of course, means that the implicit rule will fire
every time it matches the pattern of a target that make has determined
needs to be built.
This could lead to problems in a specific instance, when the dependency
were never specified at all for a specific target.
Namely something like
------
generated_manpages: doc/gcc.info doc/oops.info
doc/gcc.info: gcc.texi includedstuff.texi
doc/%.info:
makeinfo $< -o $@
-----
would appear hung if issued a "make generated_manpages"
Even though we did not write explicit dependencies for doc/oops.info,
our since it matched the target pattern, the generic rule will fire off
with $< remaining empty, so the command will go into lala land waiting
for stdin.
This is a problem. However the following nifty little construct can
guard against that possibilty.
------
generated_manpages: doc/gcc.1 doc/oops.1
doc/gcc.1: gcc.texi includedstuff.texi
doc/%.1:
$(if $<,,$(error $@ requires a dependency to be defined.))
makeinfo $< -o $@
-----
Now a "make generated_manpages" will error out with an appropriate error
message if there wasn't a specific target rule.
Testing with all the combinations I could think of appears to work
wonderfully.
make -j3 bootstrap
make info
make dvi
make generated_manpages
make doc
Would this version be OK to install?
Kelley Cook
2003-10-23 Kelley Cook <kcook@gcc.gnu.org>
* Makefile.in: Define a vpath for .texi. Add stmp-docobjdir to each
$(docobjdir) generated target.
(TEXI_CPP_FILES): Adjust for vpath.
(TEXI_GCC_FILES): Likewise.
(TEXI_GCCINT_FILES): Likewise.
(TEXI_GCCINSTALL_FILES): Likewise.
(TEXI_CPPINT_FILES): Likewise.
($(docobjdir)/%.info): Remove generic dependencies. Abort if no
dependency was defined for specific target being built.
($(docobjdir)/%.dvi): Likewise.
($(docobjdir)/%.1): Likewise.
($(docobjdir)/%.7): Likewise.
--- Makefile.in.orig 2003-10-22 07:58:02.000000000 -0400
+++ Makefile.in 2003-10-23 14:06:40.473034500 -0400
@@ -54,13 +54,10 @@
# -------------------------------
# Standard autoconf-set variables
# -------------------------------
-# Directory where sources are, from where we are.
-VPATH = @srcdir@
-
build=@build@
host=@host@
target=@target@
target_noncanonical=@target_noncanonical@
@@ -87,10 +84,24 @@
# objdir is set by configure.
# It's normally the absolute path to the current directory.
objdir = @objdir@
# --------
+# Defined vpaths
+# --------
+
+# Directory where sources are, from where we are.
+VPATH = @srcdir@
+
+# We define a vpath for the sources of the .texi files here because they
+# are split between multiple directories and we would rather use one implicit
+# pattern rule for everything.
+# This vpath should be extended within the Make-lang fragments.
+
+vpath %.texi $(docdir):$(docdir)/include
+
+# --------
# UNSORTED
# --------
# Variables that exist for you to override.
# See below for how to change them for certain systems.
@@ -2615,88 +2626,81 @@
stmp-docobjdir:
-test -d $(docobjdir) || mkdir $(docobjdir)
$(STAMP) stmp-docobjdir
doc: $(BUILD_INFO) $(GENERATED_MANPAGES) gccbug
-info:: $(docobjdir)/cpp.info $(docobjdir)/gcc.info $(docobjdir)/gccint.info $(docobjdir)/gccinstall.info $(docobjdir)/cppinternals.info
+info:: $(docobjdir)/cpp.info $(docobjdir)/gcc.info $(docobjdir)/gccint.info \
+ $(docobjdir)/gccinstall.info $(docobjdir)/cppinternals.info
-TEXI_CPP_FILES = $(docdir)/cpp.texi $(docdir)/include/fdl.texi \
- $(docdir)/cppenv.texi $(docdir)/cppopts.texi
+TEXI_CPP_FILES = cpp.texi fdl.texi cppenv.texi cppopts.texi
-TEXI_GCC_FILES = $(docdir)/gcc.texi $(docdir)/include/gcc-common.texi \
- $(docdir)/frontends.texi $(docdir)/standards.texi \
- $(docdir)/invoke.texi $(docdir)/extend.texi $(docdir)/md.texi \
- $(docdir)/objc.texi $(docdir)/gcov.texi $(docdir)/trouble.texi \
- $(docdir)/bugreport.texi $(docdir)/service.texi \
- $(docdir)/contribute.texi $(docdir)/compat.texi \
- $(docdir)/include/funding.texi $(docdir)/gnu.texi \
- $(docdir)/include/gpl.texi $(docdir)/include/fdl.texi \
- $(docdir)/contrib.texi $(docdir)/cppenv.texi $(docdir)/cppopts.texi
+TEXI_GCC_FILES = gcc.texi gcc-common.texi frontends.texi standards.texi \
+ invoke.texi extend.texi md.texi objc.texi gcov.texi trouble.texi \
+ bugreport.texi service.texi contribute.texi compat.texi funding.texi \
+ gnu.texi gpl.texi fdl.texi contrib.texi cppenv.texi cppopts.texi
-TEXI_GCCINT_FILES = $(docdir)/gccint.texi \
- $(docdir)/include/gcc-common.texi $(docdir)/contribute.texi \
- $(docdir)/makefile.texi $(docdir)/configterms.texi \
- $(docdir)/portability.texi $(docdir)/interface.texi \
- $(docdir)/passes.texi $(docdir)/c-tree.texi \
- $(docdir)/rtl.texi $(docdir)/md.texi $(docdir)/tm.texi \
- $(docdir)/hostconfig.texi $(docdir)/fragments.texi \
- $(docdir)/configfiles.texi $(docdir)/collect2.texi \
- $(docdir)/headerdirs.texi $(docdir)/include/funding.texi \
- $(docdir)/gnu.texi $(docdir)/include/gpl.texi \
- $(docdir)/include/fdl.texi $(docdir)/contrib.texi \
- $(docdir)/languages.texi $(docdir)/sourcebuild.texi \
- $(docdir)/gty.texi $(docdir)/libgcc.texi
+TEXI_GCCINT_FILES = gccint.texi gcc-common.texi contribute.texi makefile.texi \
+ configterms.texi portability.texi interface.texi passes.texi \
+ c-tree.texi rtl.texi md.texi tm.texi hostconfig.texi fragments.texi \
+ configfiles.texi collect2.texi headerdirs.texi funding.texi gnu.texi \
+ gpl.texi fdl.texi contrib.texi languages.texi sourcebuild.texi \
+ gty.texi libgcc.texi
-TEXI_GCCINSTALL_FILES = $(docdir)/install.texi $(docdir)/install-old.texi \
- $(docdir)/include/fdl.texi
+TEXI_GCCINSTALL_FILES = install.texi install-old.texi fdl.texi
-TEXI_CPPINT_FILES = $(docdir)/cppinternals.texi
+TEXI_CPPINT_FILES = cppinternals.texi
-$(docobjdir)/cpp.info cpp.dvi: $(TEXI_CPP_FILES)
-$(docobjdir)/gcc.info gcc.dvi: $(TEXI_GCC_FILES)
-$(docobjdir)/gccint.info gccint.dvi: $(TEXI_GCCINT_FILES)
-$(docobjdir)/gccinstall.info gccinstall.dvi: $(TEXI_GCCINSTALL_FILES)
-$(docobjdir)/cppinternals.info cppinternals.dvi: $(TEXI_CPPINT_FILES)
+# The *.1, *.7, *.info, and *.dvi files are being generated from implicit
+# patterns without any dependencies. Therefore, it is required that all
+# of these targets have themselves listed with their specific dependencies.
+# In addition please list the input file first in the dependency list,
+# since the implicit patterns are using $< for the input file.
-$(docobjdir)/%.info: $(docdir)/%.texi stmp-docobjdir
+$(docobjdir)/cpp.info cpp.dvi: $(TEXI_CPP_FILES) stmp-docobjdir
+$(docobjdir)/gcc.info gcc.dvi: $(TEXI_GCC_FILES) stmp-docobjdir
+$(docobjdir)/gccint.info gccint.dvi: $(TEXI_GCCINT_FILES) stmp-docobjdir
+$(docobjdir)/gccinstall.info gccinstall.dvi: $(TEXI_GCCINSTALL_FILES) \
+ stmp-docobjdir
+$(docobjdir)/cppinternals.info cppinternals.dvi: $(TEXI_CPPINT_FILES) \
+ stmp-docobjdir
+
+$(docobjdir)/%.info:
+ $(if $<,,$(error $@ requires a dependency to be defined.))
if [ x$(BUILD_INFO) = xinfo ]; then \
$(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) \
-I $(docdir)/include -o $@ $<; \
fi
dvi:: gcc.dvi gccint.dvi gccinstall.dvi cpp.dvi cppinternals.dvi
-%.dvi: $(docdir)/%.texi
+%.dvi:
+ $(if $<,,$(error $@ requires a dependency to be defined.))
$(TEXI2DVI) -I $(docdir) -I $(docdir)/include $<
-gccinstall.dvi:
- s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(TEXI2DVI) -I $$s/doc -I $$s/doc/include -o $@ $$s/doc/install.texi
-
generated-manpages:: $(docobjdir)/gcov.1 $(docobjdir)/cpp.1 \
$(docobjdir)/gcc.1 $(docobjdir)/gfdl.7 $(docobjdir)/gpl.7 \
$(docobjdir)/fsf-funding.7
-$(docobjdir)/gcov.1: $(docdir)/gcov.texi
-$(docobjdir)/cpp.1: $(docdir)/cpp.texi $(docdir)/cppenv.texi \
- $(docdir)/cppopts.texi
-$(docobjdir)/gcc.1: $(docdir)/invoke.texi $(docdir)/cppenv.texi \
- $(docdir)/cppopts.texi
-$(docobjdir)/gfdl.7: $(docdir)/include/fdl.texi
-$(docobjdir)/gpl.7: $(docdir)/include/gpl.texi
-$(docobjdir)/fsf-funding.7: $(docdir)/include/funding.texi
+$(docobjdir)/gcov.1: gcov.texi stmp-docobjdir
+$(docobjdir)/cpp.1: cpp.texi cppenv.texi cppopts.texi stmp-docobjdir
+$(docobjdir)/gcc.1: invoke.texi cppenv.texi cppopts.texi stmp-docobjdir
-$(docobjdir)/%.1: $(docdir)/%.texi stmp-docobjdir
+$(docobjdir)/%.1:
+ $(if $<,,$(error $@ requires a dependency to be defined.))
$(STAMP) $@
-$(TEXI2POD) $< > $(basename $(notdir $@)).pod
-($(POD2MAN) --section=1 \
$(basename $(notdir $@)).pod > $(@).T$$$$ && \
mv -f $(@).T$$$$ $@) || \
(rm -f $(@).T$$$$ && exit 1)
-rm -f $(basename $(notdir $@)).pod
-$(docobjdir)/%.7: $(docdir)/%.texi stmp-docobjdir
+$(docobjdir)/gfdl.7: fdl.texi stmp-docobjdir
+$(docobjdir)/gpl.7: gpl.texi stmp-docobjdir
+$(docobjdir)/fsf-funding.7: funding.texi stmp-docobjdir
+$(docobjdir)/%.7:
+ $(if $<,,$(error $@ requires a dependency to be defined.))
$(STAMP) $@
-$(TEXI2POD) $< > $(basename $(notdir $@)).pod
-($(POD2MAN) --section=7 \
$(basename $(notdir $@)).pod > $(@).T$$$$ && \
mv -f $(@).T$$$$ $@) || \