CSE-112 • Fall 2020 •
Program 4 • Perl and Rapid Development
Scripting is a style of programming whereby small programs are developed rapidly.
This is also sometimes called rapid prototyping. Perl is a language which supports
this particular programming paradigm very well because it is a very powerful and
interpreted language. There is no need to do the usual compile-run cycle, since the
program is compiled every time it is run.
The make(1) utility determines automatically which pieces of a large program need
to be recompiled, and issue the commands to recompile them. This project will also
enhance your knowledge of make and Makefiles, as presented in prerequisite courses.
Every programmer should have a detailed knowledge of make.
2. An implementation of a subset of make
In this assignment, you will use Perl to write a replacement for a subset of make.
pmake — perl implementation of a subset of make
pmake [-d] [target]
The pmake utility executes a list of shell commands associated with each target,
typically to create or update files of the same name. The Makefile contains
entries that describe how to bring a target up to date with respect to those on
which it depends, which are called prerequisites.
The following options are supported. All options must precede all operands,
and all options are scanned by Getopt::Std::getopts (perldoc).
-d Displays debugging information. Output is readable only to the implementor. Other debugging flags may also be added, but none are production flags.
The following operand is recognized.
An attempt is made to build each target in sequence in the order they are
given on the command line. If no target is specified, the first target in
the Makefile is built. This is usually, but not necessarily, the target all.
Reads the file called Makefile in the current directory. If the file does not exist,
pmake exits with an error message.
0 No errors were detected.
1 An error in the Makefile was detected. Or if any subprocess returned a
non-zero exit status or failed on a signal, and the command was not preceded by the minus sign (-) marker.
Generally, whitespace delimits words, but in addition, punctuation is recognized as well. Each line of input is a comment, an empty line,adependency,
or a command.
# Any line with begins with a hash, possibly preceded by whitespace (spaces and tabs) is ignored. Empty lines consisting only of whitespace are
macro = value
Macro definitions are kept in a symbol (hash) table, to be substituted
target… : prerequisite …
Each target’s time stamp is checked against the time stamps of each of
the prerequisites. If the target or prerequisite contains a percent sign
(%), it is substituted consistently. If any target is obsolete, the following
commands are executed. A target is obsolete if it is a file that is older
than the prerequisites or does not exist. A prerequisite is either a file or
another target. If a file, its time stamp is checked. If not, the target to
which is refers is made recursively. No target is made more than once.
A command is any line for which the first character is a tab . The line is
echoed to STDOUT before executing the command. The line is then passed
to the system function call for execution by the shell. The resulting exit
status and signal is then tested. If either is non-zero, pmake exits at that
Behaves like command, except that the command is not echoed to STDOUT
before being executed.
Behaves like command, except that a non-zero exit status or signal does
not cause pmake to exit at that point.
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: email@example.com 微信号:vipnxx