LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "$?" not picking up files (https://www.linuxquestions.org/questions/linux-newbie-8/%24-not-picking-up-files-946759/)

Tinyspark 05-25-2012 01:48 AM

"$?" 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.

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:

$(MCB_OBJS) $(ARC_OBJS) $(SYS_OBJS) $(SCRIPT_OBJS) $(ALERTDOBJS): $(SRCDIR)$(@:.o=.c)
$(CC) -DLOGFLAG=1 $(CFLAGS) -o $@ -c $<

pan64 05-25-2012 02:10 AM

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

Tinyspark 05-25-2012 02:45 AM

It works fine now. Thanks!

pan64 05-25-2012 02:50 AM

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


All times are GMT -5. The time now is 12:14 AM.