# A tool for running "make" from makelib.
#
# (C) 2000 Lucent Technologies, Bell Laboratories
#
# Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
# Compiled by:
#
src/app/makelib/tools/make/make-tool.libstipulate
package mld = makelib_defaults; # makelib_defaults is from
src/app/makelib/stuff/makelib-defaults.pkgherein
package make_tool {
#
stipulate
include package tools;
package c = mld::make_tool;
tool = "Make-Command"; # the name of this tool
ilk = "make"; # the name of the ilk
kw_ilk = "ilk";
kw_options = "options";
fun err m
=
raise exception TOOL_ERROR { tool, msg => m };
fun rule { spec, context, native2pathmaker, default_ilk_of, sysinfo }
=
{ spec -> { name => str, make_path, tool_options => too, ... } : Spec;
my (tilk, topts, mopts)
=
case too
#
NULL => (NULL, NULL, []);
THE tool_options
=>
{ my { matches, remaining_options }
=
parse_options
{ tool,
keywords => [kw_ilk, kw_options],
tool_options
};
( case (matches kw_ilk)
#
THE [STRING { name, ... } ]
=>
THE name;
NULL => NULL;
_ => err "invalid ilk specification";
esac,
matches kw_options,
remaining_options
);
};
esac;
p = srcpath (make_path ());
tname = native_spec p; # for passing to "make"
partial_expansion
=
# The "make" ilk is odd in that it has only a target
# but no sources. We use "str" and "make_path", that is,
# we retain the distinction between native and standard
# paths instead of going native in all cases.
( { source_files => [], makelib_files => [], sources => [] },
[ { name => str,
make_path,
#
ilk => tilk,
tool_options => topts,
#
derived => TRUE
}
]
);
fun runcmd ()
=
{ cmdname
=
resolve_command_path (c::command.get ());
compiledfile_directory
=
"";
tname
=
if (winix__premicrothread::path::is_absolute tname)
#
winix__premicrothread::path::make_relative
{ path => tname,
relative_to => winix__premicrothread::file::current_directory ()
};
else
tname;
fi;
cmd = cat (cmdname ! fold_backward (\\ (x, l) = " " ! x ! l)
[compiledfile_directory, " ", tname] mopts);
say {. cat ["[", cmd, "]\n"]; };
if (winix__premicrothread::process::bin_sh' cmd != winix__premicrothread::process::success)
#
err cmd;
fi;
};
fun rulefn ()
=
{ runcmd ();
#
partial_expansion;
};
context rulefn;
};
herein
my _ = note_ilk (ilk, rule);
package control = c;
end;
};
end;