LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   creating log file (https://www.linuxquestions.org/questions/programming-9/creating-log-file-606267/)

RudraB 12-12-2007 06:13 AM

creating log file
 
hello friends,
i am a bit trouble and looking some help. i have written a makefile ,that compiles a number of profram using fortran compiler,g95.
i have switched -Wall tag so it gives some warnning as well.
this the output of my make: $ make run "flag= -Wall"
as u can understand, blue lines are general make output and red lines are output of -Wall.
g95 -O3 -Wall -c main.f90
g95 -O3 -Wall -c map.f90

In file map.f90:10

integer::i,j,k,dx,dy,d2
1
Warning (137): Variable 'dx' at (1) is never used and never set
In file map.f90:10

integer::i,j,k,dx,dy,d2
1
Warning (137): Variable 'd2' at (1) is never used and never set
In file map.f90:10

integer::i,j,k,dx,dy,d2
1
Warning (137): Variable 'dy' at (1) is never used and never set
g95 -O3 -Wall -c coeff.f90
In file coeff.f90:6

integer,parameter::eps=.138,t=-1
1
Warning (141): Implicit conversion at (1) causes precision loss

g95 -O3 -Wall main.o map.o coeff.o -o run

i have managed to seperate these two types of prompt using
make run 2>warnning.log
but is there any way to edit my make file so that it will create the log file itself without specifying 2>log eachtime while 'make' it?
looking for your kind help.
Regards
advanced

matthewg42 12-12-2007 06:52 AM

Just add 2>&1 to the end of the gcc invocation lines in your Makefile. e.g. note the lines which use $(CC) here:
Code:

CC = gcc
CFLAGS = -g -Wall
LFLAGS =

SOURCES = main.c extra.c
OBJECTS = $(SOURCES:.c=.o)
BINARY = myprog

$(BINARY) : $(OBJECTS)
        $(CC) $(LFLAGS) $(OBJECTS) -o $(BINARY) 2>&1

.PHONY: clean
clean :
        rm $(BINARY) $(OBJECTS)

%.o : %.c
        $(CC) -c $(CFLAGS) -o $@ $< 2>&1


RudraB 12-12-2007 11:35 PM

dera friend, thanks for your reply...but it doesnt work...
firstly, i want the warnnings to be put on a different file...error.log(say)
when i put 2>&1,it still prints the warnning on screen.
on the other hand, if i put 2>w.log, wgenever compiler is invoked, its prompting nothin to that file....thats what is puzzellin me.....plz. chek


All times are GMT -5. The time now is 01:48 AM.