Capture makefile output

This is a discussion on Capture makefile output within the C Programming forums, part of the General Programming Boards category; Hi - When I do a "make", all its output is displayed on the screen...and there is one part where ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    1

    Capture makefile output

    Hi - When I do a "make", all its output is displayed on the screen...and there is one part where it calculates and dispalys the size of the firmware...

    Is it possible to include a command in the makefile that captures that line of the make output? I would like to save the firmware file size to a size.out file.

    Please help!
    thanks!

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,468
    just redirect output to file - and then grep file in some way
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You'll probably also want to capture the output of stderr. (GCC errors and warnings, for example, are printed on stderr.)
    Code:
    make >make.out 2>&1
    Or perhaps something like this . . .
    Code:
    make 2>&1 | grep firmware > size.out
    (That saves every line in the make output that contains the word "firmware".)

    Or, if you want to see the output on the screen as well as save it:
    Code:
    make 2>&1 | tee make.out
    The possibilities are endless . . .

    [edit] BTW: as this isn't really a C programming question, next time post it in the Tech Board. [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    If you want to have a lot of output from make, use the -d switch
    like
    Code:
    make -d
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling an external program + capture output?
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2008, 12:49 AM
  2. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  3. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  4. Can we use select() to capture output from execl()?
    By Nessarose in forum Networking/Device Communication
    Replies: 5
    Last Post: 07-05-2005, 12:53 AM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21