Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Makefile and csh

1,381 views
Skip to first unread message

Arun Sharma

unread,
Dec 9, 1994, 1:57:29 AM12/9/94
to
Hi,

I am having this problem with the makefile...
---------------
SHELL= /bin/csh

<lot of stuff here deleted>

clean:
foreach file (${SOURCES})\
if (-w $$file) then\
ci $$file\
else\
rm -f $$file\
endif\
end

Now, the problem is, foreach requires that the commands enclosed by it
be on a separate line, whereas makefile doesn't allow for a command to
span multiple lines..

I know this can be done easily using sh. But due to other
considerations I am forced to use csh. Can anyone help me with this
makefile and make it work ?

Thanks in advance,
Arun
--
ARUN SHARMA
ar...@cs.iastate.edu

Matus Uhlar Software

unread,
Dec 13, 1994, 6:14:15 AM12/13/94
to
Arun Sharma (ar...@psylock.cs.iastate.edu) wrote:

: Now, the problem is, foreach requires that the commands enclosed by it


: be on a separate line, whereas makefile doesn't allow for a command to
: span multiple lines..

: I know this can be done easily using sh. But due to other
: considerations I am forced to use csh. Can anyone help me with this
: makefile and make it work ?

Error, Make is not csh, it has its own command interpretter
--
Matus Uhlar,
Computer Centre of Technical University in Kosice, Slovakia

Michael Veksler

unread,
Dec 15, 1994, 8:34:12 AM12/15/94
to
Arun Sharma (ar...@psylock.cs.iastate.edu) wrote:

: Now, the problem is, foreach requires that the commands enclosed by it
: be on a separate line, whereas makefile doesn't allow for a command to
: span multiple lines..

: I know this can be done easily using sh. But due to other
: considerations I am forced to use csh. Can anyone help me with this
: makefile and make it work ?

Try GNU-make, I think it supports the "\" notation.
Unless you have a huge makefile with CSH commands (which is already there),
there is no reson to run csh from makefiles.

If you can't obtain a GNU-make (gmake) and you already have a huge makefile
with csh commands (very unlikely), try to run (in the same line) the
following code (ugly):
echo 'foreach ... (...) ; if (....) then ; .... ; else ; ... ; endif ; ... ; end ; ' | tr ";" "\012" | $(SHELL)

OR (a little bit less ugly, but slower):
echo "foreach...." > tmpfile
echo "if ...." >> tmpfile
....
...
echo "end" >> tmpfile
$(SHELL) tmpfile
rm tmpfile

Again, try to use "sh" not "csh"

hope this helps
Michael

David Weintraub

unread,
Dec 19, 1994, 11:39:47 PM12/19/94
to
> : I know this can be done easily using sh. But due to other
> : considerations I am forced to use csh. Can anyone help me with this
> : makefile and make it work ?
>
> Error, Make is not csh, it has its own command interpretter

Actually, Make uses Bourne shell by default. However, many versions of
Make allow you to setup a SHELL macro and *that* shell will be used for
executions.

SHELL = /bin/csh

Give it a try.

Another solution is to write a csh script and call it from your Makefile.

target : $(DEPENDENCIES)
csh my.shell.script $(param1) $(param2) $(param3)

If you need to work with the results of the shell script, use the backtick
syntax, many makes now take it:

target: $(DEPENDENCIES)
$(ANSWER) = `csh my.shell.script $(param1)`

--
David Weintraub dav...@cnj.digex.net

Clueless on the Internet? Send $1.00 for clues to:
Internet Clues, 1988 Rhodes Drive, Port Reading NJ 07814

0 new messages