Unix/Linux Go Back    


Homework & Coursework Questions Students must use and complete the template provided. If you do not use the template your post may be deleted! Special homework rules apply here.

Makefile helps

Homework & Coursework Questions


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 5 Days Ago   -   Original Discussion by dhnguyen0708
dhnguyen0708's Unix or Linux Image
dhnguyen0708 dhnguyen0708 is offline
Registered User
 
Join Date: Apr 2018
Last Activity: 16 April 2018, 10:58 AM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Makefile helps

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:
The code in project2 is for a program that formats C++ code into HTML for presentation in a webpage. For example, here is the web page produced by running the command



Code:
./cpp2html < ~/UnixCourse/compileAsst/guess.cpp > guess.html

(once the program has been successfully compiled, of course).

This program would have been a massive undertaking to write in pure C or C++, but was actually put together quite quickly using a software tool called “flex” that was originally developed for use in building compilers. Whats interesting about flex is that it actually writes out the program code for a substantial portion of a compiler (the “scanner” or “lexical analyzer”) from a (relatively speaking) simple description of what the language being processed looks like.

The steps necessary to produce this program are:

Compile cpp2html.c to produce cpp2html.o. ( Important: the source code in this project is C, not C++, and so must be compiled and linked with gcc, not g++.)

Run the command



Code:
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. (Note: you will probably not be able to base this makefile upon my self-updating makefile as in the earlier part of the assignment. Instead, you will probably find it necessary to write this one from scratch.





2. The attempts at a solution (include all code and scripts):



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

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

lex.yy.c:
        flex cppscanner.l

cpp2html.o: cpp2html.c
        gcc -g -DDEBUG -c cpp2html.c

when i ran the code to check my makefile it gave the error

Code:
"Your makefile does not invoke flex when only cppscanner.l has been changed:
make: `cpp2html' is up to date."

Moderator's Comments:
Makefile helps Please use CODE tags as required by forum rules!




3. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Old Dominion University, Norfolk Virginia, United States. Professor Steven 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).

Last edited by RudiC; 5 Days Ago at 11:58 AM.. Reason: Changed CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 5 Days Ago   -   Original Discussion by dhnguyen0708
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 20 April 2018, 2:49 PM EDT
Location: Saskatchewan
Posts: 22,636
Thanks: 1,172
Thanked 4,306 Times in 3,972 Posts
List cppscanner.l as a dependency of lex.yy.c, a la

Code:
lex.yy.c:cppscanner.l

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with Simple Multi-Level Makefile (Extremely New at Makefile) Tatl Homework & Coursework Questions 1 03-09-2011 03:48 AM
Makefile problem - How to run module load in a Makefile hernandinho UNIX for Advanced & Expert Users 2 04-13-2009 10:20 AM
How does an Administrator helps Progremmers sol8admin Solaris 2 02-09-2005 04:35 PM
this helps me out big time jerzey4life UNIX for Dummies Questions & Answers 4 09-21-2001 02:48 PM



All times are GMT -4. The time now is 07:24 PM.