[m-rev.] diff: handle MLOBJS-target make variables
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Jan 7 18:26:42 AEDT 2002
On 07-Jan-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 06-Jan-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> >
> > Allow MLOBJS-module Mmake variables.
>
> Test case?
Done.
> The documentation in doc/user_guide.texi should document this
> new feature (by mentioning EXTRA_MLOBJS).
Done.
> > scripts/Mmake.rules:
> > compiler/modules.m:
> > Use ALL_MLOBJS and ALL_MLPICOBJS instead of
> > MLOBJS and MLPICOBJS.
>
> It would be a good idea to grep through the Mercury distribution
> looking for other occurrences of these variables which should
> also be changed, if you haven't done so already.
It's only uses, not assignments of the variables which need to be updated.
Simon.
Estimated hours taken: 1
Branches: main
Fix bugs in my change to allow MLOBJS-module Mmake variables.
compiler/modules.m:
$@ make variables are not set in the dependencies of
a rule, so we need to manually expand the MLOBJS-$@
in ALL_MLOBJS.
doc/user_guide.texi:
Document EXTRA_MLOBJS.
tests/hard_coded/Mmakefile:
tests/hard_coded/target_mlobjs.m:
tests/hard_coded/target_mlobjs_c.h:
tests/hard_coded/target_mlobjs_c.c:
Test case.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.211
diff -u -u -r1.211 modules.m
--- compiler/modules.m 5 Jan 2002 14:12:30 -0000 1.211
+++ compiler/modules.m 7 Jan 2002 06:51:38 -0000
@@ -3514,9 +3514,18 @@
{ Gmake = yes ->
append_list(["\\\n\t\t$(foreach @,", MakeVarName,
",$(ALL_MLLIBS_DEP))"],
- All_MLLibsDepString)
+ All_MLLibsDepString),
+ append_list(["\\\n\t\t$(foreach @,", MakeVarName,
+ ",$(ALL_MLOBJS))"],
+ All_MLObjsString),
+ append_list([
+ "\\\n\t\t$(patsubst %.o,%.$(EXT_FOR_PIC_OBJECTS),$(foreach @,",
+ MakeVarName, ",$(ALL_MLOBJS)))"],
+ All_MLPicObjsString)
;
- All_MLLibsDepString = "$(ALL_MLLIBS_DEP)"
+ All_MLLibsDepString = "$(ALL_MLLIBS_DEP)",
+ All_MLObjsString = "$(ALL_MLOBJS)",
+ All_MLPicObjsString = "$(ALL_MLPICOBJS)"
},
%
@@ -3543,11 +3552,12 @@
{ MainRule =
[ExeFileName, " : $(", MakeVarName, ".cs_or_ss) ",
"$(", MakeVarName, ".os) ",
- InitObjFileName, " $(ALL_MLOBJS) ",
+ InitObjFileName, " ", All_MLObjsString, " ",
All_MLLibsDepString, "\n",
"\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o ",
ExeFileName, " ", InitObjFileName, " \\\n",
- "\t $(", MakeVarName, ".os) $(ALL_MLOBJS) $(ALL_MLLIBS)\n"]
+ "\t $(", MakeVarName, ".os) ", All_MLObjsString,
+ " $(ALL_MLLIBS)\n"]
},
{ EndIf = ["endif\n"] },
@@ -3576,11 +3586,11 @@
]),
io__write_strings(DepStream, [
- SplitLibFileName,
- " : $(", MakeVarName, ".dir_os) $(ALL_MLOBJS)\n",
+ SplitLibFileName, " : $(", MakeVarName, ".dir_os) ",
+ All_MLObjsString, "\n",
"\trm -f ", SplitLibFileName, "\n",
- "\t$(AR) $(ALL_ARFLAGS) $(AR_LIBFILE_OPT)",
- SplitLibFileName, " $(ALL_MLOBJS)\n",
+ "\t$(AR) $(ALL_ARFLAGS) $(AR_LIBFILE_OPT) ",
+ SplitLibFileName, " ", All_MLObjsString, "\n",
"\tfind $(", MakeVarName, ".dirs) -name ""*.$O"" -print | \\\n",
"\t xargs $(AR) q ", SplitLibFileName, "\n",
"\t$(RANLIB) $(ALL_RANLIBFLAGS) ", SplitLibFileName, "\n\n"
@@ -3637,19 +3647,19 @@
io__write_strings(DepStream, [
SharedLibFileName, " : $(", MakeVarName, ".cs_or_ss) ",
"$(", MakeVarName, ".pic_os) ",
- "$(ALL_MLPICOBJS) ", All_MLLibsDepString, "\n",
+ All_MLPicObjsString, " ", All_MLLibsDepString, "\n",
"\t$(ML) --make-shared-lib $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) ",
"-o ", SharedLibFileName, " \\\n",
- "\t\t$(", MakeVarName, ".pic_os) $(ALL_MLPICOBJS) ",
- "$(ALL_MLLIBS)\n\n"
+ "\t\t$(", MakeVarName, ".pic_os) ", All_MLPicObjsString,
+ " $(ALL_MLLIBS)\n\n"
]),
io__write_strings(DepStream, [
LibFileName, " : $(", MakeVarName, ".cs_or_ss) ",
- "$(", MakeVarName, ".os) $(ALL_MLOBJS)\n",
+ "$(", MakeVarName, ".os) ", All_MLObjsString, "\n",
"\trm -f ", LibFileName, "\n",
"\t$(AR) $(ALL_ARFLAGS) $(AR_LIBFILE_OPT)", LibFileName, " ",
- "$(", MakeVarName, ".os) $(ALL_MLOBJS)\n",
+ "$(", MakeVarName, ".os) ", All_MLObjsString, "\n",
"\t$(RANLIB) $(ALL_RANLIBFLAGS) ", LibFileName, "\n\n"
]),
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.283
diff -u -u -r1.283 user_guide.texi
--- doc/user_guide.texi 18 Dec 2001 12:13:09 -0000 1.283
+++ doc/user_guide.texi 7 Jan 2002 04:53:13 -0000
@@ -665,9 +665,10 @@
A list of @samp{-l} options specifying libraries used by the program
(or library) that you are building. @xref{Using libraries}.
- at item MLOBJS
+ at item MLOBJS and EXTRA_MLOBJS
@vindex MLOBJS
-A list of extra object files to link into any programs or libraries
+ at vindex EXTRA_MLOBJS
+A list of extra object files to link into the program (or library)
that you are building.
@item C2INITFLAGS and EXTRA_C2INITFLAGS
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.138
diff -u -u -r1.138 Mmakefile
--- tests/hard_coded/Mmakefile 19 Dec 2001 15:08:30 -0000 1.138
+++ tests/hard_coded/Mmakefile 7 Jan 2002 07:06:12 -0000
@@ -118,6 +118,7 @@
string_alignment \
string_alignment_bug \
string_loop \
+ target_mlobjs \
term_io_test \
term_to_univ_test \
test_bitset \
@@ -247,6 +248,8 @@
MCFLAGS-parse = --trace deep
MCFLAGS-unused_float_box_test = --infer-all
+MLOBJS-target_mlobjs = target_mlobjs_c.o
+
# In grade `none' with options `-O1 --opt-space' on kryten
# (a sparc-sun-solaris2.5 system), mode_choice needs to be linked
# with `--no-strip', otherwise it gets a seg fault.
@@ -298,6 +301,9 @@
depend_local: $(DEPENDS)
check_local: $(OUTS) $(RESS)
all_local: $(PROGS) $(SPLIT_PROGS:%=%.split)
+
+clean_local:
+ rm -f target_mlobjs_c.o
#-----------------------------------------------------------------------------#
Index: tests/hard_coded/target_mlobjs.exp
===================================================================
RCS file: tests/hard_coded/target_mlobjs.exp
diff -N tests/hard_coded/target_mlobjs.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/target_mlobjs.exp 7 Jan 2002 07:06:35 -0000
@@ -0,0 +1 @@
+Hello, world
Index: tests/hard_coded/target_mlobjs.m
===================================================================
RCS file: tests/hard_coded/target_mlobjs.m
diff -N tests/hard_coded/target_mlobjs.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/target_mlobjs.m 7 Jan 2002 05:26:01 -0000
@@ -0,0 +1,19 @@
+:- module target_mlobjs.
+:- interface.
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+main -->
+ c_write_string("Hello, world\n").
+
+:- pragma c_header_code("#include ""target_mlobjs_c.h""").
+
+:- pred c_write_string(string::in, io__state::di, io__state::uo) is det.
+:- pragma c_code(c_write_string(Message::in, IO0::di, IO::uo), "
+ c_write_string(Message);
+ IO = IO0;
+").
+
Index: tests/hard_coded/target_mlobjs_c.c
===================================================================
RCS file: tests/hard_coded/target_mlobjs_c.c
diff -N tests/hard_coded/target_mlobjs_c.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/target_mlobjs_c.c 7 Jan 2002 06:25:18 -0000
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include "target_mlobjs_c.h"
+
+void c_write_string(char *string)
+{
+ printf(string);
+}
Index: tests/hard_coded/target_mlobjs_c.h
===================================================================
RCS file: tests/hard_coded/target_mlobjs_c.h
diff -N tests/hard_coded/target_mlobjs_c.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/target_mlobjs_c.h 7 Jan 2002 05:23:30 -0000
@@ -0,0 +1 @@
+void c_write_string(char *string);
--------------------------------------------------------------------------
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