LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-02-2009, 04:24 PM   #1
jiobo
Member
 
Registered: Nov 2008
Posts: 180

Rep: Reputation: 36
Redirect make output to file, make | tee not working


The usual output redirection is not working for redirecting the output of make...there is a simple explanation for it, I just have not found it yet.

GNU make 3.81
GNU bash 3.1.17

> make | tee outfile.txt

> make 2>&1 > outfile.txt

The echo from the Makefile is going to the outfile, but that is just a few echos from the Makefile. The remaining output is all going to the console.
 
Old 01-02-2009, 04:46 PM   #2
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
Quote:
Originally Posted by jiobo View Post
The usual output redirection is not working for redirecting the output of make...there is a simple explanation for it, I just have not found it yet.

GNU make 3.81
GNU bash 3.1.17

> make | tee outfile.txt

> make 2>&1 > outfile.txt

The echo from the Makefile is going to the outfile, but that is just a few echos from the Makefile. The remaining output is all going to the console.
the correct format would be make >> outfile.txt or make 2>&1 outfile.txt
 
Old 01-02-2009, 05:04 PM   #3
jiobo
Member
 
Registered: Nov 2008
Posts: 180

Original Poster
Rep: Reputation: 36
Nope...see below.

Quote:
make >> outfile.txt
, same results.
Quote:
make 2>&1 outfile.txt
make, nothing to be done for target 'outfile.txt'
 
Old 01-03-2009, 12:44 AM   #4
dquick1
LQ Newbie
 
Registered: Dec 2008
Location: Geelong, Australia
Distribution: Fedora
Posts: 8

Rep: Reputation: 0
I assume you have a makefile in your current directory and this file contains a target to make? (1st target in the makefile is the default if a named target is not provided as an argument.

I cannot replicate your problem, redirection with > or >> works on my system, as follows:

Without redirection
Code:
[dlq@localhost tohex]$ make tohex
g++ -Wno-deprecated tohex.cpp -o tohex
[dlq@localhost tohex]$ ls
makefile  tohex*  tohex.cpp
[dlq@localhost tohex]$ make clean
rm -rf a.out *.o tohex
With redirection and named target
Code:
[dlq@localhost tohex]$ make tohex > test.txt
[dlq@localhost tohex]$ make clean >> test.txt
[dlq@localhost tohex]$ cat test.txt
g++ -Wno-deprecated tohex.cpp -o tohex
rm -rf a.out *.o tohex
With redirection and default target
Code:
[dlq@localhost tohex]$ make > test2.txt
[dlq@localhost tohex]$ make clean >> test2.txt
[dlq@localhost tohex]$ cat test2.txt
g++ -Wno-deprecated tohex.cpp -o tohex
rm -rf a.out *.o tohex
[dlq@localhost tohex]$
When using a target that is not in the makefile
Quote:
[dlq@localhost tohex]$ make something > test.txt
make: *** No rule to make target `something'. Stop.
[dlq@localhost tohex]$ cat test.txt
[dlq@localhost tohex]$

Sample make file
Code:
[dlq@localhost tohex]$ cat makefile
COMPILER = g++
CCFLAGS =  -Wno-deprecated

tohex: tohex.cpp
        ${COMPILER} ${CCFLAGS} tohex.cpp -o tohex

clean:
        rm -rf a.out *.o tohex
Hope this helps.

Damien
 
Old 05-10-2014, 04:25 PM   #5
itoffshore
LQ Newbie
 
Registered: May 2014
Posts: 1

Rep: Reputation: Disabled
make build log

To generate a build log from make that contains everything that would have ordinarily been output to the console you need to use both tee & redirection:

Code:
make 2>&1 | tee build.log
 
Old 05-11-2014, 11:43 AM   #6
DJ Shaji
Member
 
Registered: Dec 2004
Location: India
Distribution: Debian Squeeze, Fedora 17
Posts: 440
Blog Entries: 15

Rep: Reputation: 80
You can prefix the command with nohup and all output will be lohged to nohup.out
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
redirecting make output to file babu198649 Linux - Newbie 20 09-02-2010 04:30 AM
redirecting make output not working - pl help mselvam Linux - Newbie 3 07-08-2005 06:38 PM
make redirect not working-pl help mselvam Linux - General 4 07-08-2005 05:01 PM
make output redirect not working-pl help mselvam Programming 1 07-06-2005 11:50 AM
How to direct output from make to a file? DDD25 Programming 6 07-25-2004 06:55 AM


All times are GMT -5. The time now is 11:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration