Utilizing the Make Command


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Utilizing the Make Command
# 1  
Old 04-23-2013
[Solved] Utilizing the Make Command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
  • Compile cpp2html.c to produce cpp2html.o.
    ( Important: the source code in these files is C, not C++, and so must be compiled and linked with gcc, not g++.)
  • Run the command

    flex cppscanner.l

    to produce the file lex.yy.c from the language description in cppscanner.l.
  • Compile lex.yy.c to produce lex.yy.o. (This often produces a warning message about extra tokens. Ignore it.)
  • Link the the .o files to produce an executable program named cpp2html
  • Write a makefile that will carry out these steps. Your makefile should result in only the minimum required amount of steps when any input file to this process is changed.


2. Relevant commands, code, scripts, algorithms:
Nothing outside of the UNIX command library


3. The attempts at a solution (include all code and scripts):
My makefile

Code:
cpp2html.o: cpp2html.c
	gcc -g -DDEBUG -c cpp2html.c
	flex cppscanner.l

lex.yy.o: lex.yy.c
	gcc -g -DDEBUG -c lex.yy.c

cpp2html: cpp2html.o lex.yy.o
	gcc -g -DDEBUG cpp2html.o lex.yy.o
	mv a.out cpp2html

And here is the error I get when I get my makefile checked for completion:

Your makefile does not build 'cpp2html' when invoked:
gcc -g -DDEBUG -c cpp2html.c
flex cppscanner.l



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Old Dominion University, Norfolk (Virginia), USA, Mr. Zeil, CS 252

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).
# 2  
Old 04-23-2013
Your makefile contains rules for creating cpp2html.o from cpp2html.c, lex.yy.o from lex.yy.c, and cpp2html from cpp2html.o and lex.yy.o.

The second bullet in your problem statement talks about creating lex.yy.c. Do you have a rule that builds lex.yy.c if the contents of its dependencies have changed since the last time you ran make?

When you ran make, did it produce any error messages?
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 04-23-2013
Quote:
Originally Posted by Don Cragun
Your makefile contains rules for creating cpp2html.o from cpp2html.c, lex.yy.o from lex.yy.c, and cpp2html from cpp2html.o and lex.yy.o.

The second bullet in your problem statement talks about creating lex.yy.c. Do you have a rule that builds lex.yy.c if the contents of its dependencies have changed since the last time you ran make?

When you ran make, did it produce any error messages?
I removed this line "flex cppscanner.l" from the makefile and ran it through the shell and it produced the lex.yy.c file. So then I save and do "make" to update everything and then "make cpp2html" to produce the program which after doing "ls" in shell I see it produced but when I run the checker I get the same error:

Your makefile does not build 'cpp2html' when invoked:
gcc -g -DDEBUG -c cpp2html.c

I guess I need to do a command to make lex.yy.c in the makefile but just typing flex cppscanner.l in the makefile and running doesn't do it.

EDIT: I was able to solve and complete this task. Thanks for you help.

Last edited by lamentofking; 04-23-2013 at 07:19 PM..
# 4  
Old 04-23-2013
Yes, you need a rule to make lex.yy.c in the makefile. If you manually type:
Code:
flex cppscanner.l

before invoking make, that kind of defeats the purpose of using make, doesn't it?

If you invoke make without specifying a target operand on the command line, how does make decide what target(s) need(s) to be built?
# 5  
Old 04-23-2013
Quote:
Originally Posted by Don Cragun
Yes, you need a rule to make lex.yy.c in the makefile. If you manually type:
Code:
flex cppscanner.l

before invoking make, that kind of defeats the purpose of using make, doesn't it?

If you invoke make without specifying a target operand on the command line, how does make decide what target(s) need(s) to be built?
Yeah. I just misread the instructions. Thanks Don !
# 6  
Old 06-23-2013
Linux

How did you compete this? This problem is driving me mad! I wish this class was taught in a classroom.
# 7  
Old 07-28-2013
Moderator's Comments:
Mod Comment Since this thread is discussing a class assignment, no one but the submitter (if anyone) should post THE answer.

Last edited by Don Cragun; 07-28-2013 at 11:47 AM.. Reason: Remove class assignment solution posted by 3rd party.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to make df command?

in RHEL 6.10, how can we make the the df -k return the output without wrapping. And wihout using the df -Pk option. After we patched a Linux server from 6.5 to 6.10: The df -k on RHAT 6.10 it wraps the line for ex: 6.10: /dev/mapper/vgapp01-vendor ... (2 Replies)
Discussion started by: mrn6430
2 Replies

2. HP-UX

NFSd command utilizing more cpu

Hi, I see following 'nfsd' command is using more CPU. Could someone please comment on it's pros and cons of it? CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND 5 ? 16890 root 152 20 34696K 12036K run 57166:48 856.13 854.64 nfsd OS -- HP-UX One... (4 Replies)
Discussion started by: Maddy123
4 Replies

3. Homework & Coursework Questions

Utilizing the Make Command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: ]Compile cpp2html.c to produce cpp2html.o. ( Important: the source code in these files is C, not C++, and so... (1 Reply)
Discussion started by: bgnaranjo1
1 Replies

4. Solaris

Ram not utilizing

We are using oracle database on solaris 10 sparc 64 bit on M5000 machine. we facing performance related issues. We diagnose using prstat -a command that oracle user not utilizing the ram more than 30 gb total we have 64 gb ram available as in project max-shm-memory set to 42 gb . We are running... (2 Replies)
Discussion started by: zeeshan047
2 Replies

5. UNIX for Dummies Questions & Answers

Unknown process utilizing CPU.

Hi i recently observed my cpu being used 100% due to which load average on machine get increased to < 5. I have no idea what the process is? Appreciate any help in this regard. root 15859 99.9 0.0 5668 1592 pts/4 R+ 12:28 660:06 \_ pvs root 7334 99.9 ... (2 Replies)
Discussion started by: pinga123
2 Replies

6. Shell Programming and Scripting

Utilizing libraries when you aren't root.

I'm having a bit of trouble trying to make use of Net::SSH::Expect. I've started getting dependent libraries and set PERL5LIB to add my custom path because I don't have root access. I tried using cpan, but it always tries to use paths I don't have access to. Next, I tried just moving the .pm... (1 Reply)
Discussion started by: mrwatkin
1 Replies

7. Solaris

how to make all of this in one command

dears what i need to make is cp -irp file_name filename tar cvf filename.tar filename gzip filename.tar in one commane using exec it that prossible and how can i do that (4 Replies)
Discussion started by: xxmasrawy
4 Replies

8. Shell Programming and Scripting

Utilizing func keys in scripts

I would like to have the function keys available to me in my scripts. Anyone have any ideas on how to map these to functionality I design? :confused: (3 Replies)
Discussion started by: fjjlee
3 Replies

9. Shell Programming and Scripting

command utilizing high CPU

Can anybody please help me on how to optimize following command as it use up a lot of CPU : tail -f $DIR3$DATE4.log |\ while read line do echo $line | egrep "Processing incoming SMS message" | sed 's/\,/ /g' \ | awk '{print $2}' >> $DIR2/LIST1.$DATE4.log && echo... (6 Replies)
Discussion started by: azmanw2004
6 Replies

10. UNIX for Dummies Questions & Answers

make command

Dear Guys , Kindly note that i have sun solaries 8 intel machine . i installed apache and it is working fine . i am installing perl5 , MD5 and CGI . but whenever i execute the commands , make , make test and make install i get error message : not found # make make: not found also i... (2 Replies)
Discussion started by: tamemi
2 Replies
Login or Register to Ask a Question