TASK 1
Your first task is to create a Makefile for a project. A project has been provided to you in the compressed file CSCI124-Lab3.zip. In this file you will find numerous headers and source files. You can ignore the fact the program is implemented using classes. The program once compiled takes a source file name and prints out the symbols in the file and line numbers they appear on. The function is largely irrelevant to the task at hand.
The program can be compiled easily by using:
$ g++ *.cp
That said this is not desirable. Your job is to create a Makefile, called makefile.txt which builds all the targets associated with the project and links them together to build the executable foobar. To do this you will need to review the files and understand the dependencies.
Your makefile should have a clean target to remove all objects and executables.
Place your solution in the file makefile.txt.
TASK 2
Your second task is to write a program, which does some pattern matching. Pattern matching is commonly used when we want to identify something in a file.
Your mission is to write a C++ program which can find header dependencies in C++ source files i.e. .cpp files.
An include can be of any of the following forms:
#include <iostream>
include <iostream>
#include “myheader.h
include “myheader.h”
Between the #include there can be any number of white space characters (including tabs etc) followed by either a < or “. Within the < or “ there is a string which is known as the dependency – such strings may have white spaces in them. The header string is typically followed by a closing > or “.
Your job is to write a program which prompts the user for a C++ source file and prints out all the dependencies. A C++ source file ends with a .cpp extension. If this is not met print an error and terminate.
A sample run of the program using the main.cpp from csci124-lab3.zip should yield the following:
Enter Filename: main.cpp
Dependencies:
iostream
program.h
binarytree.h
Where includes do not meet the above specified form, exclude it from the summary list. You only need to look for includes in the source file specified. You can assume there will only ever be one include per line.
Place your code to solve this problem into the file depend.cpp and depend.h. Write a suitable driver function and place it in main.cpp.
So, this is the output for task 1 , i not sure whether its correct anot , i wrote all them create .o object file in a text file(.txt).
Identifier: binarytree
Line Numbers: 1 2 4 7 8
Identifier: c
Line Numbers: 5 8 11 14
Identifier: cpp
Line Numbers: 1 2 4 5 7 8 10 11 13 14
Identifier: g
Line Numbers: 2 5 8 11 14
Identifier: h
Line Numbers: 4 7 10 13
Identifier: linkedlist
Line Numbers: 1 2 4 10 11
Identifier: list
Line Numbers: 1 2 4 13 14
Identifier: main
Line Numbers: 1 2 4 5
Identifier: o
Line Numbers: 2 4 7 10 13
Identifier: prog
Line Numbers: 1 2
Identifier: program
Line Numbers: 1 2 4 13 14
Now , if task 1 is correct , what should i proceed with task 2?
Please give some idea ~ i nid to submit these in 2 day..