LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-25-2012, 01:48 AM   #1
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Rep: Reputation: Disabled
"$?" not picking up files


hi,
I am new to shell scripting and need help.
I have the following command in makefile;

$(CC) -DLOGFLAG=1 $(CFLAGS) -o $@ -c $?

when I run the make file, I get the output like

gcc -Wall -DLOGFLAG=1 -I../ -I/appl/oraclient/product/11g/precomp/public -w -I/opt/profile/OraAlert_test/code/pwutils -I/opt/profile/OraAlert_test/code/jslib/src -o oraGen.o -c /opt/profile/OraAlert_test/code/database/src

$@ is substituted by the name of .o file. I expect @? to pick up the name of C file. but it is picking up only the location of the C file and not the exact file. How can this be solved?

Thanks.
 
Old 05-25-2012, 01:51 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,922

Rep: Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305
probably you wanted to write $< instead of $?, but it also depends on the target: line of your makefile
 
Old 05-25-2012, 01:59 AM   #3
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi pan64,
Even after replacing $? by $< , I get the same error.

This is complete line in the makefile:

$(MCB_OBJS) $(ARC_OBJS) $(SYS_OBJS) $(SCRIPT_OBJS) $(ALERTDOBJS): $(SRCDIR)$(@:.o=.c)
$(CC) -DLOGFLAG=1 $(CFLAGS) -o $@ -c $<
 
Old 05-25-2012, 02:10 AM   #4
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,922

Rep: Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305
see man page of gnu make, maybe this will work:
Code:
(MCB_OBJS) $(ARC_OBJS) $(SYS_OBJS) $(SCRIPT_OBJS) $(ALERTDOBJS): %.o: $(SRCDIR)%.c
<tab>$(CC) -DLOGFLAG=1 $(CFLAGS) -o $@ -c $(SRCDIR)$<
I do not know if $(SRCDIR) - the red text - required, so try
 
Old 05-25-2012, 02:45 AM   #5
Tinyspark
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
It works fine now. Thanks!
 
Old 05-25-2012, 02:50 AM   #6
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,922

Rep: Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305
great!




_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
 
  


Reply

Tags
linux, shell script


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
How to add the "More Apps" and "Find Files" buttons to the 11.10 Launcher Larry James Ubuntu 0 10-19-2011 12:42 AM
[SOLVED] Missing "Search for Files..." in Gnome "Places" menu austinium Linux - Newbie 11 04-12-2011 04:38 AM
"Permission denied" and "recursive directory loop" when searching for string in files mack1e Linux - Newbie 5 06-12-2008 07:38 AM
Shell and batch operations on hidden files but not on ".." & "." danielsbrewer Linux - Software 5 09-12-2007 08:06 AM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM


All times are GMT -5. The time now is 07:58 AM.

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