[m-dev.] diff: fix `mmake install' for MLDS grades

Fergus Henderson fjh at cs.mu.OZ.AU
Wed May 17 22:03:39 AEST 2000


Estimated hours taken: 3

Change the Mmake rules for `mmake install' so that they install the
compiler-generated header files for MLDS grades.

compiler/modules.m:
	Generate a new rule for `lib<module>.install_hdrs' in the `.dep' files.
	If --high-level-code is enabled, this rule installs the header
	files, otherwise it does nothing.

scripts/Mmake.rules:
	Make `lib<module>.install' depend on `lib<module>.install_hdrs'.

library/Mmakefile:
	- Override the default definition of `mercury.hs', so that
	  the header file names include the `mercury.' prefix that
	  the MLDS back-end uses for header files in the standard library.
	- Simplify the code by using the automatically generated rule for
	  `liblibrary.install_ints' rather than hand-coding it, and by
	  using `install_lib_dirs' and `install_grade_dirs' (which
	  are defined by scripts/Mmake.rules) rather than hand-coding
	  a rule for `install_dirs'.

Mmakefile:
scripts/Mmake.rules:
scripts/mercury_cleanup_install:
	In the rules for `mmake install_grades', make sure to move
	the `.h' and `.dep' files out of the way too, like we do for the
	`.c', `.o', etc. files, since the contents of the `.h' and `.dep'
	files now depend on the grade.

Workspace: /home/pgrad/fjh/ws/hg2
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.123
diff -u -d -r1.123 modules.m
--- compiler/modules.m	2000/05/16 21:23:28	1.123
+++ compiler/modules.m	2000/05/17 10:58:12
@@ -625,6 +625,7 @@
 		; Ext = ".realclean"
 		; Ext = ".depend"
 		; Ext = ".install_ints"
+		; Ext = ".install_hdrs"
 		; Ext = ".check"
 		; Ext = ".ints"
 		; Ext = ".int3s"
@@ -2939,6 +2940,38 @@
 			"""; \\\n",
 		InstallIntsRuleBody
 	]),
+
+	module_name_to_lib_file_name("lib", ModuleName, ".install_hdrs", no,
+				LibInstallHdrsTargetName),
+	io__write_strings(DepStream, [
+		".PHONY : ", LibInstallHdrsTargetName, "\n",
+		LibInstallHdrsTargetName, " : $(", MakeVarName, ".hs) ",
+			"install_lib_dirs\n"
+	]),
+	globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
+	( { HighLevelCode = yes } ->
+		%
+		% XXX  Note that we install the header files in two places:
+		% in the `inc' directory, so that the C compiler will find
+		% them, and also in the `ints' directory, so that Mmake
+		% will find them.  That's not ideal, but it works.
+		% (A better fix would be to change the VPATH setting
+		% in scripts/Mmake.vars.in so that Mmake also searches
+		% the `inc' directory, but doing that properly is non-trivial.)
+		%
+		io__write_strings(DepStream, [
+			"\tfor hdr in $(", MakeVarName, ".hs); do \\\n",
+			"\t	$(INSTALL) $$hdr $(INSTALL_INC_DIR)\\\n",
+			"\t	$(INSTALL) $$hdr $(INSTALL_INT_DIR)\\\n",
+			"\tdone\n\n"
+		])
+	;
+		# for non-MLDS grades, we don't need to install the header
+		# files, so this rule does nothing
+		io__write_strings(DepStream, [
+			"\t\n\n"
+		])
+	),
 
 	module_name_to_file_name(SourceModuleName, ".check", no,
 				CheckTargetName),
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.47
diff -u -d -r1.47 Mmakefile
--- library/Mmakefile	2000/05/17 07:18:22	1.47
+++ library/Mmakefile	2000/05/17 10:51:49
@@ -90,6 +90,17 @@
 
 #-----------------------------------------------------------------------------#
 
+# We need to override library.hs manually here, since the default
+# definition of library.hs does not include the `mercury.' prefix.
+# (We could modify compiler/modules.m to generate it correctly,
+# but it's easier to just manually override it here.)
+# This definition is only correct for MLDS grades, but fortunately
+# it is also only used for MLDS grades.
+
+library.hs = $(library.mods:%=mercury.%.h)
+
+#-----------------------------------------------------------------------------#
+
 # Stuff for Windows DLLS using gnu-win32
 
 ifeq ($(USE_DLLS),yes)
@@ -223,6 +234,7 @@
 #-----------------------------------------------------------------------------#
 
 realclean_local:
+	rm -f $(library.mods:%=%.h)
 	rm -f lib$(STD_LIB_NAME).a lib$(STD_LIB_NAME).so $(STD_LIB_NAME).init
 	rm -f tags
 
@@ -245,45 +257,21 @@
 install_all: install_mercury
 
 .PHONY: install_mercury
-install_mercury: install_ints install_init install_library
-
-.PHONY: install_dirs
-install_dirs:
-	#-[ -d $(INSTALL_INT_DIR) ] || mkdir -p $(INSTALL_INT_DIR)
-	-[ -d $(INSTALL_INT_DIR)/Mercury ] || \
-		mkdir -p $(INSTALL_INT_DIR)/Mercury
-	-[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
-	-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
+install_mercury: install_ints install_hdrs install_init install_library
 
 .PHONY: install_ints
-install_ints: $(library.ints) $(library.int3s) \
-		$(library.opts) $(library.trans_opts) install_dirs
-	for file in $(library.ints) $(library.int3s) \
-			$(library.opts) $(library.trans_opts); \
-	do \
-		target=$(INSTALL_INT_DIR)/`basename $$file`; \
-		if cmp -s $$file $$target; then \
-			echo "$$target unchanged"; \
-		else \
-			echo "installing $$target"; \
-			cp $$file $$target; \
-		fi; \
-	done
-	# The following is needed to support the `--use-subdirs' option
-	# We try using `ln -s', but if that fails, then we just use `cp'.
-	for ext in int int2 int3 opt trans_opt; do \
-		dir=$${ext}s; \
-		rm -f $(INSTALL_INT_DIR)/Mercury/$$dir; \
-		ln -s .. $(INSTALL_INT_DIR)/Mercury/$$dir || { \
-			[ -d $(INSTALL_INT_DIR)/Mercury/$$dir ] || \
-				mkdir -p $(INSTALL_INT_DIR)/Mercury/$$dir; \
-			cp $(INSTALL_INT_DIR)/*.$$ext \
-				$(INSTALL_INT_DIR)/Mercury/$$dir; \
-		} || exit 1; \
-	done
+install_ints: liblibrary.install_ints
 
+.PHONY: install_hdrs
+install_hdrs: liblibrary.install_hdrs
+
+# The following rules are hand-coded, rather than using the
+# liblibrary.* targets automatically generated by `mmake depend',
+# because they override the name used for the standard library:
+# they use $(STD_LIB_NAME) rather than `library'.
+
 .PHONY: install_init
-install_init: $(STD_LIB_NAME).init install_dirs
+install_init: $(STD_LIB_NAME).init install_lib_dirs
 	cp `vpath_find $(STD_LIB_NAME).init` $(INSTALL_MODULE_DIR)
 	# "$(STD_LIB_NAME).init" used to be called "library.init" or
 	# "libmercury.init". If there is still a version with an old name
@@ -294,7 +282,7 @@
 
 .PHONY: install_library
 install_library: lib$(STD_LIB_NAME).a \
-		lib$(STD_LIB_NAME).$(EXT_FOR_SHARED_LIB) install_dirs
+		lib$(STD_LIB_NAME).$(EXT_FOR_SHARED_LIB) install_grade_dirs
 	cp `vpath_find lib$(STD_LIB_NAME).a \
 		lib$(STD_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
 		$(INSTALL_MERC_LIB_DIR)
@@ -302,7 +290,7 @@
 # library.split.a is a version of lib$(STD_LIB_NAME).a that has been compiled
 # with `--split-c-files'.
 .PHONY: install_split_library
-install_split_library: library.split.a install_dirs
+install_split_library: library.split.a install_grade_dirs
 	cp `vpath_find library.split.a` \
 		$(INSTALL_MERC_LIB_DIR)/lib$(STD_LIB_NAME).a
 
@@ -321,6 +309,10 @@
 	echo "Can't do make install without LIBRARY_INTERMODULE=yes"
 
 .PHONY: install_ints
+install_ints:
+	echo "Can't do make install without LIBRARY_INTERMODULE=yes"
+
+.PHONY: install_hdrs
 install_ints:
 	echo "Can't do make install without LIBRARY_INTERMODULE=yes"
 
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.48
diff -u -d -r1.48 Mmakefile
--- Mmakefile	2000/02/22 01:38:05	1.48
+++ Mmakefile	2000/05/17 11:39:08
@@ -334,16 +334,18 @@
 	cd profiler && $(SUBDIR_MMAKE) install
 
 .PHONY: install_grades
-install_grades: scripts dep_library dep_browser
+install_grades: scripts
 	cd boehm_gc && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.o *.pic_o *.a *.so tmp_dir || true; }
 	cd runtime && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.o *.pic_o *.a *.so tmp_dir || true; }
 	cd library && rm -rf tmp_dir && mkdir tmp_dir && \
-		{ mv -f *.c *.o *.pic_o *.a *.so \
+		{ mv -f *.dep *.h *.c *.o *.pic_o *.a *.so \
+			Mercury/deps/*.dep \
 			Mercury/cs/*.c Mercury/os/*.o tmp_dir || true; }
 	cd browser && rm -rf tmp_dir && mkdir tmp_dir && \
-		{ mv -f *.c *.o *.pic_o *.a *.so \
+		{ mv -f *.dep *.h *.c *.o *.pic_o *.a *.so \
+			Mercury/deps/*.dep \
 			Mercury/cs/*.c Mercury/os/*.o tmp_dir || true; }
 	cd trace && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.o *.pic_o *.a *.so tmp_dir || true; }
@@ -362,16 +364,18 @@
 		( cd runtime && \
 		  $(SUBDIR_MMAKE) GRADE=$$grade install_lib ) && \
 		( cd library && \
+		  $(SUBDIR_MMAKE) GRADE=$$grade depend && \
 		  $(SUBDIR_MMAKE) GRADE=$$grade install_library ) && \
 		( cd browser && \
+		  $(SUBDIR_MMAKE) GRADE=$$grade depend && \
 		  $(SUBDIR_MMAKE) GRADE=$$grade install_library ) && \
 		( cd trace && \
 		  $(SUBDIR_MMAKE) GRADE=$$grade install_lib ) && \
 		( cd boehm_gc && rm -f *.o *.pic_o *.a *.so ) && \
 		( cd runtime && rm -f *.o *.pic_o *.a *.so ) && \
-		( cd library && rm -f *.c *.o *.pic_o *.a *.so \
+		( cd library && rm -f *.dep *.h *.c *.o *.pic_o *.a *.so \
 				Mercury/cs/*.c Mercury/os/*.o ) && \
-		( cd browser && rm -f *.c *.o *.pic_o *.a *.so \
+		( cd browser && rm -f *.dep *.h *.c *.o *.pic_o *.a *.so \
 				Mercury/cs/*.c Mercury/os/*.o ) && \
 		( cd trace && rm -f *.o *.pic_o *.a *.so ) && \
 		true \
@@ -382,9 +386,11 @@
 	cd runtime  && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd library  && { [ -d Mercury/cs ] && mv tmp_dir/*.c Mercury/cs; \
 			 [ -d Mercury/os ] && mv tmp_dir/*.o Mercury/os; \
+			 [ -d Mercury/deps ] && mv tmp_dir/*.dep Mercury/deps;\
 			 mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd browser  && { [ -d Mercury/cs ] && mv tmp_dir/*.c Mercury/cs; \
 			 [ -d Mercury/os ] && mv tmp_dir/*.o Mercury/os; \
+			 [ -d Mercury/deps ] && mv tmp_dir/*.dep Mercury/deps;\
 			 mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd trace    && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 
@@ -393,16 +399,17 @@
 	cd library && \
 	rm -rf tmp_dir && \
 	mkdir tmp_dir && \
-	{ mv -f *.dir *.c *.o *.pic_o *.a *.so \
+	{ mv -f *.dir *.dep *.h *.c *.o *.pic_o *.a *.so \
 		Mercury/cs/*.c Mercury/os/*.o tmp_dir || true; } && \
 	for grade in $(GRADE) $(LIBGRADES); do \
 	        $(SUBDIR_MMAKE) GRADE=$$grade install_split_library || \
 			{ scripts/mercury_cleanup_install; exit 1; }; \
-	        rm -rf *.dir *.c *.o *.pic_o *.a *.so \
+	        rm -rf *.dir *.dep *.h *.c *.o *.pic_o *.a *.so \
 			Mercury/cs/*.c Mercury/os/*.o; \
 	done && \
-	{ [ -d Mercury/cs ] && mv tmp_dir/cs/*.c Mercury/cs; \
-	  [ -d Mercury/os ] && mv tmp_dir/os/*.o Mercury/os; \
+	{ [ -d Mercury/cs ] && mv tmp_dir/*.c Mercury/cs; \
+	  [ -d Mercury/os ] && mv tmp_dir/*.o Mercury/os; \
+	  [ -d Mercury/deps ] && mv tmp_dir/*.dep Mercury/deps; \
 	  mv tmp_dir/* . ; rmdir tmp_dir; true; }
 
 #-----------------------------------------------------------------------------#
Index: scripts/mercury_cleanup_install
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mercury_cleanup_install,v
retrieving revision 1.1
diff -u -d -r1.1 mercury_cleanup_install
--- scripts/mercury_cleanup_install	1999/10/21 14:36:34	1.1
+++ scripts/mercury_cleanup_install	2000/05/17 11:37:53
@@ -65,6 +65,7 @@
 	    [ -d Mercury/dirs ] && mv tmp_dir/*.dir $dirs_subdir
 	    [ -d Mercury/cs ] && mv -f tmp_dir/*.c Mercury/cs
 	    [ -d Mercury/os ] && mv -f tmp_dir/*.o tmp_dir/*.pic_o Mercury/os
+	    [ -d Mercury/deps ] && mv -f tmp_dir/*.dep Mercury/deps
 	    mv -f tmp_dir/* .
 	    rmdir tmp_dir
 	)
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.78
diff -u -d -r1.78 Mmake.rules
--- scripts/Mmake.rules	2000/05/11 03:46:23	1.78
+++ scripts/Mmake.rules	2000/05/17 11:45:22
@@ -327,10 +327,13 @@
 
 # Note: the `lib%.install_ints' rule is generated in each module's `.dep'
 # file so it can be more easily customised based on the desired level of
-# intermodule optimisation.
+# intermodule optimisation.  Likewise the `lib%.install_hdrs' is also
+# generated in the `.dep' file, since it depends on the setting of
+# the `--high-level-code' option.
 
 .PHONY: lib%.install
-lib%.install: lib%.install_ints lib%.install_init lib%.install_library
+lib%.install: lib%.install_ints lib%.install_hdrs lib%.install_init \
+		lib%.install_library
 	$(MMAKE) lib$*.install_grades || { mercury_cleanup_install && exit 1; }
 
 .PHONY: lib%.install_split
@@ -354,31 +357,41 @@
 lib%.install_grades:
 	rm -rf tmp_dir && \
 	mkdir tmp_dir && \
-	{ mv -f $($*.cs) $($*.os) $($*.pic_os) *.a *.so tmp_dir || true; } && \
+	{ mv -f $(deps_subdir)$*.dep $($*.hs) $($*.cs) $($*.os) $($*.pic_os) \
+		*.a *.so tmp_dir || true; } && \
 	for grade in x $(ALL_LIBGRADES); do \
 		if [ "$$grade" != "x" ]; then \
+			$(MMAKE) GRADE=$$grade lib$*.depend || \
+				exit 1; \
 			$(MMAKE) GRADE=$$grade lib$*.install_library || \
 				exit 1; \
-			rm -f $($*.cs) $($*.os) $($*.pic_os) *.a *.so; \
+			rm -f $(deps_subdir)$*.dep $($*.hs) $($*.cs) $($*.os) \
+				$($*.pic_os) *.a *.so; \
 		fi; \
 	done && \
 	{ mv tmp_dir/*.c $(cs_subdir). ; \
 	  mv tmp_dir/*.o $(os_subdir). ; \
 	  mv tmp_dir/*.pic_o $(os_subdir). ; \
+	  mv tmp_dir/*.dep $(deps_subdir). ; \
 	  mv tmp_dir/* . ; rmdir tmp_dir ; true; }
 
 lib%.install_split_grades:
 	rm -rf tmp_dir && \
 	mkdir tmp_dir && \
-	{ mv -f $($*.dirs) *.a *.so tmp_dir || true; } && \
+	{ mv -f $(deps_subdir)$*.dep $($*.hs) $($*.dirs) *.a *.so \
+		tmp_dir || true; } && \
 	for grade in x $(ALL_LIBGRADES); do \
 		if [ "$$grade" != "x" ]; then \
+			$(MMAKE) GRADE=$$grade lib$*.depend || \
+				exit 1; \
 			$(MMAKE) GRADE=$$grade lib$*.install_split_library || \
 				exit 1; \
-			rm -rf $($*.dirs) *.a *.so; \
+			rm -rf $(deps_subdir)$*.dep $($*.hs) $($*.dirs) \
+				*.a *.so; \
 		fi; \
 	done && \
 	{ mv tmp_dir/*.dir $(dirs_subdir). ; \
+	  mv tmp_dir/*.dep $(deps_subdir). ; \
 	  mv tmp_dir/* . ; rmdir tmp_dir ; true; }
 
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list