-   Linux - Newbie (
-   -   "$?" not picking up files (

Tinyspark 05-25-2012 01:48 AM

"$?" not picking up files
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?


pan64 05-25-2012 01:51 AM

probably you wanted to write $< instead of $?, but it also depends on the target: line of your makefile

Tinyspark 05-25-2012 01:59 AM

Hi pan64,
Even after replacing $? by $< , I get the same error.

This is complete line in the makefile:

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

pan64 05-25-2012 02:10 AM

see man page of gnu make, maybe this will work:

<tab>$(CC) -DLOGFLAG=1 $(CFLAGS) -o $@ -c $(SRCDIR)$<

I do not know if $(SRCDIR) - the red text - required, so try

Tinyspark 05-25-2012 02:45 AM

It works fine now. Thanks!

pan64 05-25-2012 02:50 AM


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")

All times are GMT -5. The time now is 06:51 PM.