Thread: Capture makefile output

  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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    just redirect output to file - and then grep file in some way
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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
    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, 04: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, 05:27 AM