%% "PATTON, BILLY \(SBCSI\)" <[EMAIL PROTECTED]> writes:

  pb> Here is a sample of code I have working in a shell script and it works
  pb> find.

  pb> #!/usr/bin/ksh

  pb> Now when I put it into my makefile

  pb> /bin/sh: Syntax error at line 1 : `|' is not expected.

If it works in a script and fails in the makefile, then 99.99% of the
time it's going to be quoting issues.

The only real quoting issues in make are making sure "$" is quoted
properly.

  pb> AR_ADD = $(NM) $$< | grep "main.*extern|entry.*CODE" > /dev/null ; \
  pb>         if [ $$? -ne 0 ] ; then $(AR) $(AR_OPT) $$(LIB) $$@ > /dev/null ; 
fi

This is _NOT_ quoted properly.

Remember you're quoting "$" that you want to PASS TO THE SHELL.  You
leave _unquoted_ "$" that you want MAKE TO EXPAND before invoking the
shell.

Don't quote $<; $< is a make variable, so it must be expanded before the
shell is invoked.

Similarly for $(LIB) and [EMAIL PROTECTED]

  pb> I get :
  pb> ... ; /usr/bin/nm $< | grep "main.*extern|entry.*CODE" > /dev/null ; if [ 
$? -ne 0 ] ; then ar rv $(LIB) $@ > /dev/null ; fi

Yes!  This is the exact text make is sending to the shell!

If you take that text and put it in a script or on the command line,
your shell will error out just as the one make does.

Try running just one bit:

    $ /usr/bin/nm $< | grep "foo"
    -bash: syntax error near unexpected token `|'

Hm!!!

Well, "<" is a special character to the shell, that's why: it's input
redirection.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to