This assignment should be completed by submitting various types of source files (Makefiles, shell scripts,...) and by modifying and submitting this HTML file (needed for exercise 3). These files should be uploaded to D2L individually and should use the names mentioned below.
Submit via D2L by 5:00 p.m. on Monday, 4 April.
Consider the arith
project from lab 8. For that
lab you were required to write a Makefile which contained rules
for building object files lcm.o
,
main.o
, and gcd.o
, as well as the
executable arith_pgm
. You were also required to
introduce a clean
target.
In this exercise, your job is to create a new version of this
Makefile which has variables defined for the compiler
(gcc
), the object files (gcd.o
,
lcm.o
, and main.o
), and the program to
be built (arith_pgm
). These should occupy the first
three lines of the Makefile as follows:
CC = gcc
OBJS = gcd.o lcm.o main.o
PROG = arith_pgm
You should force yourself to use these variables by not directly referencing any of these files below. This will require you to define and use auto-conversions from .c to .o files and from .s to .o files, as well as a target for creating the executable. Overall, the behaviour of this Makefile should be the same as in lab 8. It will now just be more general-purpose and easily customizable.
Submit as Makefile
.
Note that compilation of gcd.o
from
gcd.s
may need to be done in the lab (or on another
similar machine).
bash
Script as MakefileThe purpose of this exercise is to create a bash script which
has the same functionality as the previous Makefile. It should
build only those files that need to be built based on timestamps.
To make it a bit easier, you can deal with the files
individually. As an optional improvement, you could have a single
loop handle all conversions from .c
to
.o
(for example).
Submit as make.sh
.
The following list of Java source files and one data file provides a voltage divider search program. The program will given a ratio, a data file, and the tolerance will attempt to find the pair of resistors with the choosen voltage divider ratio.
Assuming all the files are in the current directory (i.e., you
have changed into vds
), the system can be compiled
and tested with:
$ javac *.java
$ java VoltageDividerSearcher resistor.data 0.1 0.00001
18.0 0.125 2.0 0.125 0.1
27.0 0.125 3.0 0.125 0.1
180.0 0.125 20.0 0.125 0.1
270.0 0.125 30.0 0.125 0.1
1800.0 0.125 200.0 0.125 0.1
2700.0 0.125 300.0 0.125 0.1
18000.0 0.125 2000.0 0.125 0.1
27000.0 0.125 3000.0 0.125 0.1
180000.0 0.125 20000.0 0.125 0.1
270000.0 0.125 30000.0 0.125 0.1
1800000.0 0.125 200000.0 0.125 0.1
2700000.0 0.125 300000.0 0.125 0.1
A common java development setup moves all the source files
into a src
directory.
Create a src
directory and a
classes
directory and move the java files into
the src
directory. What commands did you
use?
Change this with your answer
Provide a javac
command that compiles the
files in the src
directory and places
class
files in the classes
directory.
Change this with your answer
From the vds
directory, provide the
java
command that runs the
VoltageDividerSearcher
main class with the
arugments resistor.data 0.2 0.00001
.
Change this with your answer
What is the program's output?
Change this with your answer
Create a manifest file that specifies
VoltageDividerSearcher
as the main class. Give
the contents of the manifest file below.
Change this with your answer
Provide the jar
command the creates an
executable vds.jar
file for the classes in the
classes
directory.
Change this with your answer
What is the java
command used to run the
vds.jar
program with the arguments
resistor.data 0.3 0.00001
?
Change this with your answer
What is the program's output?
Change this with your answer
Provide an ant
build script, called
build.xml
, with the targets: help, compile, jar,
run, and clean. Place the class files in the classes
directory, the source files are in the src
directory. The help task outputs a description of the targets,
compile will compile the java files, creating the classes
directory if necessary. The jar task will create a jar file. The
run task should run the program with arguments
resistor.data 0.2 0.0001
(see the examples of the
arg
element here). The
clean target will remove all the class files in the
classes
directory.
Test build.xml
by executing the following:
ant help
ant clean
ant compile
ant jar
ant run
Submit build.xml
.