Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code provided compiles and do not need to be checked so I won't put them here. I'm just having trouble with the makefiles themselves.
=====
The directory tree you will be working with has the following root:
makefile_assignment/: <== You are here.
The directory "makefile_assignment/" contains the following four
subdirectories:
bin/ c/ cpp/ java/
Except for "makefile_assignment/bin/", each subdirectory above
represents a subtask. Be aware that there are further subtasks in
"C and SPARC assembly subtask" and "C++ and archiving subtask"! These subtasks
will be described before the rest of "Makefile task", because "Makefile task"
depends on all of them as subtasks.
=====
BEGIN: C subtask
The directory "makefile_assignment/c/" contains a C header file, "functions.h",
and a single C file, "main.c", in addition to one subdirectory:
cfiles/
=====
BEGIN: C dependencies subtask
The directory "makefile_assignment/c/cfiles/" contains the following C source
files:
factorial.c fibonacci.c hanoi.c print_string.c sum_4_nums.c summation.c
For this subtask ("C subtask"), you must write a Makefile to do the following:
default target:
-
Compile all source files into object code files.
-
Copy all object code files into the parent directory.
clean target:
-
Delete all object code files.
-
Delete all core dumps.
new target:
-
"make" the "clean" target.
-
"make" the "default" target.
=====
END: C dependencies subtask
For this subtask ("C subtask"), you must write a Makefile to
do the following:
default target:
-
"make" the "cfiles/" directory contents.
-
Compile the source file in this directory, "main.c", into an object
code file. -
Link all object code files into a executable named "c.exe".
Remember that the "C dependencies subtask" creates object files on which
"main.c" depends. -
Copy "c.exe" into the directory "makefile_assignment/bin/".
clean target:
-
Clean the "cfiles/" directory.
-
Delete all object code files in this directory.
-
Delete all core dumps in this directory.
new target:
-
"make" the "clean" target.
-
"make" the "default" target.
=====
END: C subtask
=====
BEGIN: C++ and archiving subtask
The directory "makefile_assignment/cpp/" contains a C++ header file, "main.h",
and a single C++ file, "main.cpp", in addition to a lone subdirectory:
lib/
=====
BEGIN: Archiving subtask
The directory "makefile_assignment/cpp/lib/" contains the following C++ source
and header files:
factorial.h sum_4_numbers.h summation.h
factorial.cpp sum_4_numbers.cpp summation.cpp
For this subtask ("Archiving subtask"), you must write a Makefile to do the
following:
default target:
-
Compile all source files into object code files.
-
Using the archiver "ar", archive the object code files into an
archive named "libFunctions.a".
clean target:
-
Delete the archive "libFunctions.a".
-
Delete all object code files.
-
Delete all core dumps.
new target:
-
"make" the "clean" target.
-
"make" the "default" target.
=====
END: Archiving subtask
For this subtask ("C++ subtask"), you must write a Makefile to do
the following:
default target:
-
"make" the "lib/" directory contents.
-
Compile the source file in this directory, "main.cpp", into an
object code file. -
Link all object code files into a executable named "cpp.exe".
Remember that the "Archiving subtask" creates an archive on which
"main.cpp" depends. -
Copy "cpp.exe" into the directory "makefile_assignment/bin/".
clean target:
-
Clean the "lib" directory.
-
Delete the object code files in this directory.
-
Delete all core dumps in this directory.
new target:
-
"make" the "clean" target.
-
"make" the "default" target.
=====
END: C++ and archiving subtask
=====
BEGIN: Java subtask
The directory "makefile_assignment/java/" contains a single Java source file,
"Main.java", and no subdirectories.
For this subtask ("Java subtask"), you must write a Makefile to do the
following:
default target:
-
Compile the Java source file in this directory, "Main.java", into a
Java class file. -
Copy "Main.class" into the directory "makefile_assignment/bin/".
clean target:
-
Delete the Java class files in this directory.
-
Delete all core dumps in this directory.
new target:
-
"make" the "clean" target.
-
"make" the "default" target.
=====
END: Java subtask
This is the rest of "Makefile task", which has you producing yet another
Makefile to tie all the subtasks together. This Makefile must be capable of
carrying out the following:
default target:
- "make" the targets "c", "cpp", and "java".
c target:
- "make" the contents of the directory "makefile_assignment/c/".
cpp target:
- "make" the contents of the directory "makefile_assignment/cpp/".
java target:
- "make" the contents of the directory "makefile_assignment/java/".
clean target:
-
Clean the "c/" directory.
-
Clean the "cpp/" directory.
-
Clean the "java/" directory.
-
Delete all executables in the "bin/" directory.
-
Delete all core dumps in the "bin/" directory.
new target:
-
"make" the "clean" target.
-
"make" the "default" target.
=====
END: Makefile task
- Relevant commands, code, scripts, algorithms:
Won't be providing the .c, .cpp, .java files as they all compile just fine.
- The attempts at a solution (include all code and scripts):
makefile for /cfiles
OBJS = factorial.o fibonacci.o hanoi.o print_string.o sum_4_nums.o summation .o
default: C_Subtask.o
cp factorial.o ..
cp fibonacci.o ..
cp hanoi.o ..
cp print_string.o ..
cp sum_4_nums.o ..
cp summation.o ..
C_Subtask.o: $(OBJS)
gcc -o C_Subtask.o -c $(OBJS)
factorial.o: factorial.c
gcc -c factorial.c
fibonacci.o: fibonacci.c
gcc -c fibonacci.c
hanoi.o: hanoi.c
gcc -c hanoi.c
print_string.o: print_string.c
gcc -c print_string.c
sum_4_nums.o: sum_4_nums.c
gcc -c sum_4_nums.c
summation.o: summation.c
gcc -c summation.c
clean:
rm *.o core
new:
make default
make clean
makefile for /c
default: c.exe
cp c.exe makefile_assignment/bin/
c.exe: C_Subtask.o main.o
gcc -c main.o
C_Subtask.o:
cd ./cfiles ; make C_Subtask.o
main.o: main.c functions.h
gcc -c main.c
clean:
rm *.o core
cd ./cfiles ; make clean
new:
make clean
make default
makefile for /lib
OBJS=factorial.o sum_4_numbers.o summation.o
default: Archiving_subtask.o
Archiving_subtask.o: $(OBJS)
g++ -c $(OBJS)
ar rcs libFuntions.a $(OBJS)
factorial.o: factorial.cpp factorial.h
g++ -c factorial.cpp
sum_4_numbers.o: sum_4_numbers.cpp sum_4_numbers.h
g++ -c sum_4_numbers.cpp
summation.o: summation.cpp summation.h
g++ -c summation.cpp
clean:
rm *.o core libFunctions.a
new:
make default
make clean
makefile for /cpp
default: cpp
cp cpp ~/makefile_assignment/bin/
cpp: Archiving_subtask.o main.o
g++ -c main.o
Archiving_subtask.o:
cd ./lib ; make Archiving_subtask.o
main.o: main.cpp main.h
g++ -c main.cpp
clean:
rm *.o core
cd ./lib ; make clean
new:
make default
make clean
makefile for /java
default: java
cp Main.class makefile_assignment/bin
java: Main.class
Main.class: Main.java
javac Main.java
clean:
rm *.class core
new:
make default
make clean
makefile for /makefile_assignment
TYPES=c.exe cpp.exe java.exe
default: $(TYPES)
c.exe:
make -C c
cpp.exe:
make -C cpp
java.exe:
make -C java
clean:
rm -f *.o *~ *.exe core
cd ./c ; make clean
cd ./cpp ; make clean
cd ./java ; make clean
new:
make default
make clean
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of San Diego, California (UCSD)
La Jolla, San Diego
USA
Professor Gary Gillespie
CSE80
ieng6.ucsd.edu/~cs80w/UCSD_CSE_80_-_WI_2011/Welcome.html
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).