[m-rev.] diff: using `mmc --make' with mmake

Simon Taylor stayl at cs.mu.OZ.AU
Thu May 2 03:13:45 AEST 2002


Estimated hours taken: 2.5
Branches: main

Allow `mmc --make' to be used with Mmake.

scripts/mmake.in:
	Add an option `--use-mmc-make', which tells mmake
	to use `mmc --make' to build Mercury targets.

scripts/Mmake.vars.in:
	Add a variable MC_MAKE_FILES, which should contain
	files (e.g. generated header files) which should be
	build with `mmc --make'.

	Add a variable MERCURY_MAIN_MODULES which should
	contain the top-level module names of the programs
	or libraries in the directory. The targets for
	the modules appearing in MERCURY_MAIN_MODULES
	are added to MC_MAKE_FILES.

	Add a variable MC_MAKE_FLAGS, which is like
	MCFLAGS, but is only passed to `mmc --make'.

scripts/Mmake.rules:
	Disable Mercury-specific rules when `--use-mmc-make'
	is passed to mmake.

	Use `mmc --make' for targets for which there are no
	rules, or for targets appearing in MC_MAKE_FILES.

Index: Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.118
diff -u -u -r1.118 Mmake.rules
--- Mmake.rules	30 Apr 2002 03:49:50 -0000	1.118
+++ Mmake.rules	1 May 2002 16:57:24 -0000
@@ -154,6 +154,8 @@
 # duplicated in compiler/modules.m.
 #
 
+ifeq ($(MMAKE_USE_MMC_MAKE), no)
+
 $(date0s_subdir)%.date0 : %.m
 	$(MCPI) $(ALL_MCPIFLAGS) $<
 
@@ -193,6 +195,8 @@
 $(trans_opts_subdir)%.trans_opt : $(trans_opt_dates_subdir)%.trans_opt_date
 	@:
 
+endif	# MMAKE_USE_MMC_MAKE == no
+
 #-----------------------------------------------------------------------------#
 #
 # Rules for compiling Mercury source files
@@ -200,6 +204,8 @@
 # duplicated in compiler/modules.m.
 #
 
+ifeq ($(MMAKE_USE_MMC_MAKE), no)
+
 ifeq ($(TARGET_ASM),yes)
 
 # `--target asm' back-end
@@ -325,6 +331,8 @@
 .m.ugly:
 	$(MC) --convert-to-mercury $(ALL_MCFLAGS) $<
 
+endif	# MMAKE_USE_MMC_MAKE == no
+
 #-----------------------------------------------------------------------------#
 #
 # Rules for compiling C files in the user's source directory.
@@ -356,6 +364,8 @@
 # the user may have some C files of their own which need to be compiled.
 #
 
+ifeq ($(MMAKE_USE_MMC_MAKE),no)
+
 ifneq ("$(cs_subdir)","")
 
 $(os_subdir)%.$O : $(cs_subdir)%.c
@@ -377,6 +387,8 @@
 
 endif # $(cs_subdir) != ""
 
+endif # $(MMAKE_USE_MMC_MAKE) == no
+
 #-----------------------------------------------------------------------------#
 #
 # Rules for compiling IL files in the user's source directory.
@@ -416,6 +428,24 @@
 		$(CSHARP_ASSEMBLY_REFS-$*) $(EXTRA_CSCFLAGS) $<
 
 endif # $(findstring il,$(GRADE)) != ""
+
+#-----------------------------------------------------------------------------#
+
+ifeq ($(MMAKE_USE_MMC_MAKE),yes)
+
+# Always attempt to rebuild these files, even if they exist.
+.PHONY: $(ALL_MC_MAKE_FILES) *.err
+$(ALL_MC_MAKE_FILES) %.err:
+	$(MCM) $(ALL_GRADEFLAGS) $(ALL_MC_MAKE_FLAGS) $@
+
+# If we don't know how to make the file, try using `mmc --make'.
+.DEFAULT:
+	$(MCM) $(ALL_GRADEFLAGS) $(ALL_MC_MAKE_FLAGS) $@
+
+clean_local: $(MERCURY_MAIN_MODULES:%=%.clean)
+realclean_local: $(MERCURY_MAIN_MODULES:%=%.realclean)
+
+endif # $(MMAKE_USE_MMC_MAKE) == yes
 
 #-----------------------------------------------------------------------------#
 #
Index: Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.67
diff -u -u -r1.67 Mmake.vars.in
--- Mmake.vars.in	29 Apr 2002 08:22:04 -0000	1.67
+++ Mmake.vars.in	1 May 2002 15:19:54 -0000
@@ -56,6 +56,23 @@
 ASM_OPT  =
 endif
 
+MERCURY_MAIN_MODULES =
+
+#
+# Files which should be built using `mmc --make' rather than `make'
+# when `--use-mmc-make' is passed on the mmake command line.
+# XXX Once `mmc --make' allows library installation we should add
+# %.depend and %.install to the list below
+#
+ALL_MC_MAKE_FILES = $(MERCURY_MAIN_MODULES:%=%$(EXT_FOR_EXE)) \
+			$(MERCURY_MAIN_MODULES:%=lib%.$A) \
+			$(MERCURY_MAIN_MODULES:%=lib%.so) \
+			$(MERCURY_MAIN_MODULES:%=%.clean) \
+			$(MERCURY_MAIN_MODULES:%=%.realclean) \
+			$(MERCURY_MAIN_MODULES:%=%.depend) \
+			$(MC_MAKE_FILES)
+MC_MAKE_FILES =
+
 #-----------------------------------------------------------------------------#
 #-----------------------------------------------------------------------------#
 #
@@ -79,6 +96,11 @@
 EXTRA_MCFLAGS	=
 LIB_MCFLAGS	= $(patsubst %,-I %,$(EXTRA_INT_DIRS))
 
+# Flags for use with `mmc --make'.
+ALL_MC_MAKE_FLAGS = $(ALL_MCFLAGS) $(MC_MAKE_FLAGS) $(EXTRA_MC_MAKE_FLAGS)
+MC_MAKE_FLAGS	=
+EXTRA_MC_MAKE_FLAGS =
+
 MCS		= $(MC) --split-c-files --compile-only
 MCG		= $(MC) --compile-to-c
 MCE		= $(MC) --errorcheck-only
@@ -89,6 +111,7 @@
 MCOI		= $(MC) --make-optimization-interface
 MCTOI		= $(MC) --make-transitive-optimization-interface
 MCOGS		= $(MC) --output-grade-string
+MCM		= $(MC) --make
 
 ALL_MCIFLAGS	= $(MCIFLAGS) $(EXTRA_MCIFLAGS) $(TARGET_MCFLAGS) \
 		  $(LIB_MCFLAGS)
Index: mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.39
diff -u -u -r1.39 mmake.in
--- mmake.in	20 Apr 2002 15:00:32 -0000	1.39
+++ mmake.in	1 May 2002 16:24:41 -0000
@@ -19,6 +19,9 @@
 Name: mmake -- Mercury Make
 Usage: mmake [<mmake options>] [-- <make options>] <target>...
 Options:
+	--use-mmc-make:
+		Use \`mmc --make' to build Mercury targets.
+		Implies \`--use-subdirs'.
 	--use-subdirs:
 		Build intermediate files in a \`Mercury' subdirectory,
 		rather than in the current directory.
@@ -92,6 +95,7 @@
 else
 	use_subdirs=${MMAKE_USE_SUBDIRS=no}
 fi
+use_mmc_make=${MMAKE_USE_MMC_MAKE=no}
 warn_undefined_vars=true
 target_asm=${MMAKE_TARGET_ASM=default}
 
@@ -109,6 +113,14 @@
 			use_subdirs=no
 			shift
 			;;
+		--use-mmc-make)
+			use_mmc_make=yes
+			shift
+			;;
+		--no-mmc-make)
+			use_mmc_make=no
+			shift
+			;;
 		--target)
 			case "$2" in
 				asm)	target_asm=yes ;;
@@ -178,6 +190,12 @@
 	esac
 done
 
+# With `mmc --make' we need to use subdirs to avoid make trying to
+# use Mmake rules to build the `.o' files for Mercury modules.
+case $use_mmc_make in
+	yes)	use_subdirs=yes ;;		
+esac
+
 if [ "$MERCURY_STDLIB_DIR" != "" ]
 then
 	MMAKE_DIR=${MMAKE_DIR=$MERCURY_STDLIB_DIR/mmake}
@@ -237,6 +255,7 @@
 esac
 
 MMAKE_USE_SUBDIRS=$use_subdirs
+MMAKE_USE_MMC_MAKE=$use_mmc_make
 
 if $save_makefile; then
 	tmp=Mmake.makefile
@@ -310,6 +329,8 @@
 	echo export MMAKE_MAKE_CMD
 	echo MMAKE_USE_SUBDIRS=$MMAKE_USE_SUBDIRS
 	echo export MMAKE_USE_SUBDIRS
+	echo MMAKE_USE_MMC_MAKE=$MMAKE_USE_MMC_MAKE
+	echo export MMAKE_USE_MMC_MAKE
 	echo MERCURY_DEFAULT_GRADE=$MERCURY_DEFAULT_GRADE
 	echo export MERCURY_DEFAULT_GRADE
 	echo cat ${MMAKE_VARS} $dvs $ds $include_makefile $mmake $deps \
@@ -319,6 +340,7 @@
 export MMAKE
 export MMAKE_MAKE_CMD
 export MMAKE_USE_SUBDIRS
+export MMAKE_USE_MMC_MAKE
 export MERCURY_DEFAULT_GRADE
 # XXX The $dvs and $ds variables can be so long as to overflow the
 # command line size limits, so we use xargs.  However echo doesn't quote
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list