This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Toplevel (bib): 'maybe' dependencies


This adds the machinery for 'maybe-' targets, to allow me to write 'soft'
dependencies (dependencies which only exist if the depended-on module is
being configured).  It doesn't actually use that machinery yet.  Tested on
i686-pc-linux-gnu, doesn't break anything.  (This is for 3.4 b-i-b.)

To use this machinery we replace
all-gcc: all-gas
with
all-gcc: maybe-all-gas

I'm not wedded to this method of soft dependencies.  The first method I
tried was a series of lines like
@if_gas@all-gcc: all-gas
where "if_gas" was set to "#" if gas wasn't present and "" if it was.  I
think that method was messier, but I can use it if others prefer.

The other versions I've tried are definitely worse, believe me.

I do need to get some version of this in to implement my vision of
clean, fast subdirectory building and configuration in the Makefile.
Some really slick simplifications come out quickly after this, although
for each one testing is needed to identify implicit dependencies and
make them explicit.

	* Makefile.tpl: Implement soft dependency machinery.
	* configure.in: Likewise.
	* Makefile.in: Regenerate.

--- Makefile.tpl.1	2002-11-19 15:34:40.000000000 -0500
+++ Makefile.tpl	2002-11-19 18:24:58.000000000 -0500
@@ -787,7 +787,8 @@
 # These rules are used to build the modules which are built with the
 # build machine's native compiler.
 [+ FOR build_modules +]
-.PHONY: all-build-[+module+]
+.PHONY: all-build-[+module+] maybe-all-build-[+module+]
+maybe-all-build-[+module+]:
 all-build-[+module+]:
 	@if [ -f ./[+module+]/Makefile ] ; then \
 	  r=`${PWD}`; export r; \
@@ -797,7 +798,8 @@
 	  true; \
 	fi
 
-.PHONY: configure-build-[+module+]
+.PHONY: configure-build-[+module+] maybe-configure-build-[+module+]
+maybe-configure-build-[+module+]:
 configure-build-[+module+]:
 	@if [ ! -d $(BUILD_SUBDIR) ]; then \
 	  true; \
@@ -885,7 +887,8 @@
 # These rules are used to build the modules which use FLAGS_TO_PASS.  To
 # build a target all-X means to cd to X and make all.
 [+ FOR host_modules +]
-.PHONY: all-[+module+]
+.PHONY: all-[+module+] maybe-all-[+module+]
+maybe-all-[+module+]:
 all-[+module+]:
 	@dir=[+module+]; \
 	if [ -f ./[+module+]/Makefile ] ; then \
@@ -939,10 +942,12 @@
 [+ ENDIF no_check +]
 
 [+ IF no_install +]
-.PHONY: install-[+module+]
+.PHONY: install-[+module+] maybe-install-[+module+]
+maybe-install-[+module+]:
 install-[+module+]:
 [+ ELSE install +]
-.PHONY: install-[+module+]
+.PHONY: install-[+module+] maybe-install-[+module+]
+maybe-install-[+module+]:
 install-[+module+]: installdirs
 	@dir=[+module+]; \
 	if [ -f ./[+module+]/Makefile ] ; then \
@@ -962,7 +967,8 @@
 # These rules are used to build the modules which are built with the target
 # tools.  To make foo-X means to cd to X and make foo.
 [+ FOR target_modules +]
-.PHONY: configure-target-[+module+]
+.PHONY: configure-target-[+module+] maybe-configure-target-[+module+]
+maybe-configure-target-[+module+]:
 configure-target-[+module+]:
 	@if [ -d $(TARGET_SUBDIR)/[+module+] ]; then \
 	  r=`${PWD}`; export r; \
@@ -1065,7 +1071,8 @@
 	  true; \
 	fi
 
-.PHONY: all-target-[+module+]
+.PHONY: all-target-[+module+] maybe-all-target-[+module+]
+maybe-all-target-[+module+]:
 all-target-[+module+]:
 	@dir=[+module+] ; \
 	if [ -f $(TARGET_SUBDIR)/[+module+]/Makefile ] ; then \
@@ -1095,8 +1102,14 @@
 	  true; \
 	fi
 [+ ENDIF no_check +]
-[+ IF no_install +][+ ELSE install +]\
-.PHONY: install-target-[+module+]
+[+ IF no_install +]
+.PHONY: install-target-[+module+] maybe-install-target-[+module+]
+maybe-install-target-[+module+]:
+# Dummy target for uninstallable.
+install-target-[+module+]:
+[+ ELSE install +]
+.PHONY: install-target-[+module+] maybe-install-target-[+module+]
+maybe-install-target-[+module+]:
 install-target-[+module+]: installdirs
 	@dir=[+module+] ; \
 	if [ -f $(TARGET_SUBDIR)/[+module+]/Makefile ] ; then \
@@ -1112,7 +1125,8 @@
 [+ ENDFOR target_modules +]
 
 # gcc is the only module which uses GCC_FLAGS_TO_PASS.
-.PHONY: all-gcc
+.PHONY: all-gcc maybe-all-gcc
+maybe-all-gcc:
 all-gcc:
 	@if [ -f ./gcc/Makefile ] ; then \
 	  r=`${PWD}`; export r; \
@@ -1199,7 +1213,8 @@
 	  true; \
 	fi 
 
-.PHONY: install-gcc
+.PHONY: install-gcc maybe-install-gcc
+maybe-install-gcc:
 install-gcc:
 	@if [ -f ./gcc/Makefile ] ; then \
 	  r=`${PWD}`; export r; \
@@ -1302,6 +1317,10 @@
 [+ FOR target_modules +]all-target-[+module+]: configure-target-[+module+]
 [+ ENDFOR target_modules +]
 
+# Dependencies of maybe-foo on foo.  These are used because, for example,
+# all-gcc only depends on all-gas if gas is present and being configured.
+@maybe_dependencies@
+
 ### other supporting targets
 
 MAKEDIRS= \
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/configure.in,v
retrieving revision 1.177.4.7
diff -u -r1.177.4.7 configure.in
--- configure.in	19 Nov 2002 06:37:05 -0000	1.177.4.7
+++ configure.in	19 Nov 2002 23:27:27 -0000
@@ -1353,21 +1353,38 @@
 all_host_modules=
 check_host_modules=
 install_host_modules=
+configure_host_modules=
 for module in ${configdirs} ; do
   all_host_modules="${all_host_modules} all-${module}"
   check_host_modules="${check_host_modules} check-${module}"
   install_host_modules="${install_host_modules} install-${module}"
+  configure_host_modules="${configure_host_modules} configure-${module}"
 done
 install_host_modules_nogcc=`echo "${install_host_modules}" | sed -e 's/install-gcc//g'`
 
 all_target_modules=
 check_target_modules=
 install_target_modules=
+configure_target_modules=
 for module in ${target_configdirs} ; do
   all_target_modules="${all_target_modules} all-target-${module}"
   check_target_modules="${check_target_modules} check-target-${module}"
   install_target_modules="${install_target_modules} install-target-${module}"
+  configure_target_modules="${configure_target_modules} configure-target-${module}"
 done
+
+# Create the 'maybe dependencies'.  This uses a temporary file.
+rm -f maybedep.tmp
+for item in ${all_host_modules} ${all_target_modules} \
+	${install_host_modules} ${install_target_modules} \
+	${configure_host_modules} ${configure_target_modules} ; do
+  echo "maybe-${item}: ${item}" >> maybedep.tmp
+done
+sed -e '/@maybe_dependencies@/r maybedep.tmp' \
+    -e 's/@maybe_dependencies@//' Makefile > Makefile.tem
+rm -f Makefile
+mv -f Makefile.tem Makefile
+rm -f maybedep.tmp
 
 # Base args.  Strip norecursion, cache-file, srcdir, host, build, target.
 # These are the ones we might not want to pass down to subconfigures.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]