[m-rev.] for review: derive getopt.m and getopt_io.m from same template

Julien Fischer jfischer at opturion.com
Fri Sep 18 17:08:09 AEST 2020



On Fri, 18 Sep 2020, Zoltan Somogyi wrote:

> Build getopt.m and getopt_io.m from a template.

...

> diff --git a/library/Mmakefile b/library/Mmakefile
> index f2c3bfd8f..a4ac45f87 100644
> --- a/library/Mmakefile
> +++ b/library/Mmakefile
> @@ -176,18 +176,23 @@ endif
>
>  #-----------------------------------------------------------------------------#
> 
> +GENERATED_SOURCES = getopt.m getopt_io.m

> +
> +#-----------------------------------------------------------------------------#
> +
>  # targets
>
>  .PHONY: all
>  all:	mercury all-ints $(TAGS_FILE_EXISTS) check_doc_undoc
>
>  .PHONY: mercury
> -mercury: lib_std
> +mercury: $(GENERATED_SOURCES) lib_std
>
>  #-----------------------------------------------------------------------------#
>
>  .PHONY: depend
> -depend:	LIB_FLAGS copy_java_runtime_files $(STD_LIB_NAME).depend
> +depend:	LIB_FLAGS $(GENERATED_SOURCES) copy_java_runtime_files \
> +		$(STD_LIB_NAME).depend
>
>  .PHONY: check
>  check:	$(STD_LIB_NAME).check
> @@ -219,6 +224,31 @@ $(STD_LIB_NAME).trans_opts: $($(STD_LIB_NAME).trans_opts)
>
>  #-----------------------------------------------------------------------------#
> 
> +getopt_io.m: getopt_template
> +	-chmod u+w getopt_io.m
> +	sed \
> +		-e '/TEMPLATE_ONLY_START/,/TEMPLATE_ONLY_END/d' \
> +		-e '/GETOPT_ONLY_START/,/GETOPT_ONLY_END/d' \
> +		-e '/GETOPT_IO_ONLY_START/d' \
> +		-e '/GETOPT_IO_ONLY_END/d' \
> +		< getopt_template > getopt_io.m
> +	chmod a-w getopt_io.m

I suggest defining the following variable somewhere in this Mmakefile

    SED=sed

and using the variable in these rules insteaed of hardcoding it as sed.
(That gives us the option of choosing which sed to use on systems where
the default sed may not be the one to use.)

> +
> +getopt.m: getopt_template
> +	-chmod u+w getopt.m
> +	sed \
> +		-e '/TEMPLATE_ONLY_START/,/TEMPLATE_ONLY_END/d' \
> +		-e '/GETOPT_IO_ONLY_START/,/GETOPT_IO_ONLY_END/d' \
> +		-e '/GETOPT_ONLY_START/d' \
> +		-e '/GETOPT_ONLY_END/d' \
> +		-e 's/getopt_io/getopt/' \
> +		-e 's/, io::di, io::uo//' \
> +		-e 's/, !IO//' \
> +		< getopt_template > getopt.m
> +	chmod a-w getopt.m

...

> +#-----------------------------------------------------------------------------#
> +
>  .PHONY: check_doc_undoc
>  check_doc_undoc: MODULES_DOC MODULES_UNDOC *.m
>  	@{								  \
> @@ -234,7 +264,7 @@ check_doc_undoc: MODULES_DOC MODULES_UNDOC *.m
>
>  #-----------------------------------------------------------------------------#
> 
> -tags:	$(MTAGS) $(wildcard *.m)
> +tags:	$(MTAGS) $(GENERATED_SOURCES) $(wildcard *.m)
>  	$(MTAGS) $(wildcard *.m)

I would expect to see one of the clean targets being modified to clean up
$(GENERATED_SOURCES), realclean_local?

The rest looks fine.  Has this change been tested when building with --use-mmc-make?
Has a source distribution based on it been built and does that source
distribution successfully install?

Julien.


More information about the reviews mailing list