LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2017, 11:42 AM   #1
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102
Blog Entries: 1

Rep: Reputation: Disabled
Post how to generate the intermediate files (i.e.,*.s, *.i ) in a different directory ?


my question is on how to force generate the default generated files location to a certain location ?

Lets say I have the below rule in my makefile(Clearmake):
Quote:
.c.o: $(SOURCE_TOOLS)
$(CC) \
$(STANDARD_OPTIONS) \
$(VARIABLE_OPTIONS) \
$(CODE_LOCATION_OPTIONS) \
$(COMPILE_SWITCHES) \
$(INCLUDE_PATH) \
-c -dg $< -o $@ \
2>&1
I run the makefile at /home/user/ . So, the ".o" file generate at the corresponding location of ".c" files, this is as expected.

When I pass the "-dg" highlighted in bold in the above code, it generates "*.c.100.dg" file at the current working directory. So, I need this intermediate file in /home/user/debug_files/. I can not change the path of running the makefile.

Last edited by rpittala; 05-12-2017 at 11:45 AM.
 
Old 05-12-2017, 11:52 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,924

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
this is not related to clearcase, but the compiler you use. if there was no other way you can add a line:
<tab>mv *dg /home/user/debug_files/
or similar
 
2 members found this post helpful.
Old 05-12-2017, 12:13 PM   #3
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi Pan64,

That`s a quick thought. I have tried it as
Quote:
.c.o: $(SOURCE_TOOLS)
$(CC) \
$(STANDARD_OPTIONS) \
$(VARIABLE_OPTIONS) \
$(CODE_LOCATION_OPTIONS) \
$(COMPILE_SWITCHES) \
$(INCLUDE_PATH) \
-c -dg $< -o $@ \
2>&1
$(MV) -f *.c.100.dg $(DEBUG_PATH)/
and it fails saying mv: cannot stat `*.c.100.dg': No such file or directory

am I placing the right "mv" command at right place ? is it possible (or) do we have a rule to move/generate the files as and when the *.c.100.dg files generated ?

Last edited by rpittala; 05-12-2017 at 12:58 PM.
 
Old 05-12-2017, 05:00 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Naah, that seems to me to be a red-herring dead end: you don't want to move the files. You just gotta see if your compiler has a command-line option that will specify where its output files should be placed.
 
Old 05-12-2017, 06:16 PM   #5
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Yes, I referred the user manual for the same and I did not find any of such option and the compiler is HIGHTEC GCC
 
Old 05-12-2017, 11:58 PM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,924

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
I do not really know that compiler, so I don't know where should you put that line. You posted one line of a makefile, that will not help a lot....
Also I do not know if moving those files is a good idea or not. But if those files were generated during execution of .c.o rules (together with .o files) the mv command should be ok, although I would use $<.100.dg probably, and also insert a - before the command.
 
Old 05-13-2017, 03:06 AM   #7
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Great !

It’s possible that I’m going crazy because that time it did fail and now, it is moving the files. But, still some error messages as:

mv: cannot stat `os_msc_init.c.100.dg': No such file or directory

Any ways it is moving the files to the desired location. Tried suppressing the error messages as:

Tried with $(MV) -f *.c.100.dg $(DEBUG_PATH) 2>/dev/null
failed with error code 1

Looks like delaying the MV command would resolve the issue. How can I check the the file existence:

Tried with this:
Quote:
if [ -e "*.c.100.dg" ]; then \
$(MV) -f *.c.100.dg $(DEBUG_PATH) 2>/dev/null; \
fi
Now again,it is not moving the files.

Last edited by rpittala; 05-13-2017 at 04:02 AM.
 
Old 05-13-2017, 03:56 AM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
First, use command ls -ltr to find out the names of generated files, then edit you Makefile... Sg like this
Code:
.c.o: $(SOURCE_TOOLS)
        $(CC) \
        $(STANDARD_OPTIONS) \
        $(VARIABLE_OPTIONS) \
        $(CODE_LOCATION_OPTIONS) \
        $(COMPILE_SWITCHES) \
        $(INCLUDE_PATH) \
        -c -dg $< -o $@ \
        2>&1
        -$(MV) -f *.dg $(DEBUG_PATH)/
 
Old 05-13-2017, 05:24 AM   #9
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
I am not interested in the names. But, with their extension(*.dg).

Why do we need file names ?
Quote:
if [ -e "*.c.100.dg" ]; then \
$(MV) -f *.c.100.dg $(DEBUG_PATH) 2>/dev/null; \
fi
If you can suggest me on how to make the above condition successful that would be very helpful
 
Old 05-13-2017, 05:27 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,924

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
without knowing the compiler and knowing what's really happening .....
You ought to be strict, so move only the "current" .dg file(s), not the one created by another target (otherwise you may have very strange error messages)
 
Old 05-13-2017, 05:53 AM   #11
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Mine is a HITECH compiler which runs on Linux server and still using the Clearmake Makefile

I think there won`t be much difference in from the GNU compiler.
 
Old 05-13-2017, 06:32 AM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
> I am not interested in the names. But, with their extension(*.dg).

Trouble is, you know neither. Or if you know, you cannot properly tell. Also you fail to see difference between [quote] and [code] Nonetheless, here is your code:

Code:
.c.o: $(SOURCE_TOOLS)
        $(CC) \
        $(STANDARD_OPTIONS) \
        $(VARIABLE_OPTIONS) \
        $(CODE_LOCATION_OPTIONS) \
        $(COMPILE_SWITCHES) \
        $(INCLUDE_PATH) \
        -c -dg $< -o $@ \
        2>&1
        -$(MV) -f *.dg $(DEBUG_PATH)/ 2>/dev/null
 
Old 05-13-2017, 10:15 AM   #13
rpittala
Member
 
Registered: Jan 2012
Location: PUNE
Distribution: SunOS sun4v sparc sun4v Solaris
Posts: 102

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Okay fine.

I tried
Code:
$(basename $(@F))
Code:
if [ -e "*.c.100.dg" ]; then \
$(MV) -f *.c.100.dg $(DEBUG_PATH) 2>/dev/null; \
fi
to get the file name and did not work. So, I just continued with the above IF condition.

Thanks for pointing out the difference between [QUOTE] and [CODE].
Quote:
Trouble is, you know neither. Or if you know, you cannot properly tell.
What else you want to know other than my above reply's

Last edited by rpittala; 05-13-2017 at 10:16 AM.
 
Old 05-13-2017, 10:53 AM   #14
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Please let's start from the very beginning: What is in your Makefile? What do you expect to happen? What happens instead of that? Is there an error message?
 
Old 05-13-2017, 10:57 AM   #15
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,924

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
Quote:
if [ -e "*.c.100.dg" ]; then
this is definitely wrong, there is no file named *.c.100.dg. Would be nice to give us some real file names, examples about what's happened.
 
  


Reply



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
[SOLVED] how to list files in directory or generate links for files in a directory darksaurian Programming 7 08-08-2015 01:28 PM
[SOLVED] Command for Generate Files name in a Directory to TXT file. hack3rcon Linux - Newbie 5 02-01-2015 08:36 AM
how to generate file and directory access logs? dushyantgohil Linux - Server 5 10-29-2012 04:50 AM
Easiest way to transfer files through an intermediate computer farnsy Linux - Networking 4 08-01-2012 05:15 PM
OpenSSL: generate Intermediate CA? new_to_open_ssl Linux - Security 15 01-24-2006 07:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:08 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration