[m-dev.] Automatic library dependencies
Warwick Harvey
wharvey at cs.monash.edu.au
Fri Jul 23 12:45:11 AEST 1999
I've been trying to get automatic dependencies on libraries working, as per
Fergus's suggestion in a review of one of my alternate installation dir
proposals, now that it (seems) practical (with the split `.dv'/`.dep'
dependency files). I'd almost got it too, but of course none of this stuff
is ever that straightforward and I ran into a snag while testing --- I was
depending on the base name of the library, not the actual file name. The
problem is that one does not know whether to depend on the `.a' or the `.so'
version of the library. I don't have time to figure out how to solve this
one (I need to stop mucking around with this stuff and do some HAL
development) so I plan to orphan this change unless somebody comes up with a
quick and easy solution.
Warwick
Estimated hours taken: 2
compiler/modules.m:
Change the generation of `.dep' files so that dependencies on
library files are specified.
Also change the dependencies on `$(MLOBJS)' and `$(MLPICOBJS)' to be
explicit rather than using the `MLOBJS_DEPS' / `MLPICOBJS_DEPS'
hacks, since the hacks aren't necessary any more.
scripts/Mmake.vars.in:
Introduce the variable `ALL_MLLIBS_DEP' which provides a list of
dependencies based on the contents of the `ALL_MLLIBS' variable.
XXX This needs to be fixed to depend on the appropriate `.a' or
`.so' versions of the libraries.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.103
diff -u -r1.103 modules.m
--- modules.m 1999/07/20 03:39:16 1.103
+++ modules.m 1999/07/23 02:24:14
@@ -2474,11 +2474,29 @@
module_name_to_file_name(ModuleName, "_init.pic_o", yes,
InitPicObjFileName),
+ % Note we have to do some ``interesting'' hacks to get
+ % `$(ALL_MLLIBS_DEP)' and `$(ALL_C2INITARGS)' to work in the
+ % dependency list (and not complain about undefined variables).
+ % These hacks rely on features of GNU Make, so should not be used
+ % if we cannot assume we are using GNU Make.
+ globals__io_lookup_bool_option(assume_gmake, Gmake),
+ { Gmake = yes ->
+ append_list(["\\\n\t\t$(foreach @,", MakeVarName,
+ ",$(ALL_MLLIBS_DEP))"],
+ All_MLLibsDepString),
+ append_list(["\\\n\t\t$(foreach @,undefined,$(foreach *,",
+ MakeVarName, ",$(ALL_C2INITARGS)))"],
+ All_C2InitArgsDepString)
+ ;
+ All_MLLibsDepString = "$(ALL_MLLIBS_DEP)",
+ All_C2InitArgsDepString = "$(ALL_C2INITARGS)"
+ },
+
module_name_to_file_name(SourceModuleName, "", no, ExeFileName),
io__write_strings(DepStream, [
- "MLOBJS_DEPS += ", ExeFileName, "\n",
ExeFileName, " : $(", MakeVarName, ".os) ",
- InitObjFileName, "\n",
+ InitObjFileName, " $(MLOBJS) ", All_MLLibsDepString,
+ "\n",
"\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o ",
ExeFileName, " ", InitObjFileName, " \\\n",
"\t $(", MakeVarName, ".os) $(MLOBJS) $(ALL_MLLIBS)\n\n"
@@ -2489,15 +2507,14 @@
module_name_to_file_name(ModuleName, ".split.a", yes, SplitLibFileName),
io__write_strings(DepStream, [
SplitExeFileName, " : ", SplitLibFileName, " ",
- InitObjFileName, "\n",
+ InitObjFileName, " ", All_MLLibsDepString, "\n",
"\t$(ML) $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) -o ",
SplitExeFileName, " ", InitObjFileName, " \\\n",
"\t ", SplitLibFileName, " $(ALL_MLLIBS)\n\n"
]),
io__write_strings(DepStream, [
- "MLOBJS_DEPS += ", SplitLibFileName, "\n",
- SplitLibFileName, " : $(", MakeVarName, ".dir_os)\n",
+ SplitLibFileName, " : $(", MakeVarName, ".dir_os) $(MLOBJS)\n",
"\trm -f ", SplitLibFileName, "\n",
"\t$(AR) $(ALL_ARFLAGS) ", SplitLibFileName, " $(MLOBJS)\n",
"\tfor dir in $(", MakeVarName, ".dirs); do \\\n",
@@ -2524,8 +2541,8 @@
]),
io__write_strings(DepStream, [
- "MLPICOBJS_DEPS += ", SharedLibFileName, "\n",
- SharedLibFileName, " : $(", MakeVarName, ".pic_os)\n",
+ SharedLibFileName, " : $(", MakeVarName,
+ ".pic_os) $(MLPICOBJS) ", All_MLLibsDepString, "\n",
"\t$(ML) --make-shared-lib $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) ",
"-o ", SharedLibFileName, " \\\n",
"\t\t$(", MakeVarName, ".pic_os) $(MLPICOBJS) ",
@@ -2533,8 +2550,7 @@
]),
io__write_strings(DepStream, [
- "MLOBJS_DEPS += ", LibFileName, "\n",
- LibFileName, " : $(", MakeVarName, ".os)\n",
+ LibFileName, " : $(", MakeVarName, ".os) $(MLOBJS)\n",
"\trm -f ", LibFileName, "\n",
"\t$(AR) $(ALL_ARFLAGS) ", LibFileName, " ",
"$(", MakeVarName, ".os) $(MLOBJS)\n",
@@ -2550,22 +2566,9 @@
list__foldl(append_to_init_list(DepStream, InitFileName), Modules),
io__write_string(DepStream, "\n"),
- io__write_strings(DepStream, [
- InitCFileName, " : ", DepFileName, " ", DvFileName
- ]),
- globals__io_lookup_bool_option(assume_gmake, Gmake),
- ( { Gmake = yes } ->
- % Note we have to do some ``interesting'' hacks to get
- % `$(ALL_C2INITARGS)' to work in the dependency list (and
- % not complain about undefined variables).
- io__write_strings(DepStream, [
- " $(foreach @,undefined,$(foreach *,", MakeVarName,
- ",$(ALL_C2INITARGS)))\n"
- ])
- ;
- io__write_string(DepStream, " $(ALL_C2INITARGS)\n")
- ),
io__write_strings(DepStream, [
+ InitCFileName, " : ", DepFileName, " ", DvFileName, " ",
+ All_C2InitArgsDepString, "\n",
"\t$(C2INIT) $(ALL_GRADEFLAGS) $(ALL_C2INITFLAGS) $(",
MakeVarName, ".init_cs) $(ALL_C2INITARGS) > ",
InitCFileName, "\n\n"
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.26
diff -u -r1.26 Mmake.vars.in
--- Mmake.vars.in 1999/07/20 03:39:18 1.26
+++ Mmake.vars.in 1999/07/23 02:24:18
@@ -100,6 +100,7 @@
MLOBJS =
MLPICOBJS = $(MLOBJS:.o=.$(EXT_FOR_PIC_OBJECTS))
ALL_MLLIBS = $(MLLIBS) $(EXTRA_MLLIBS) $(TARGET_MLLIBS)
+ALL_MLLIBS_DEP = $(patsubst -l%,lib%.???,$(ALL_MLLIBS))
MLLIBS =
EXTRA_MLLIBS =
--------------------------------------------------------------------------
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