Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: Makefile Message-ID: <438@auspex.UUCP> Date: 11 Nov 88 22:14:09 GMT References: <3165@mipos3.intel.com> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 52 >Is it possible to use the inbuilt commands of the shell >from a makefile ? The shell is csh. Well, I would suggest you not use "csh", unless you know you're always going to be on a system that has it, but that's a separate issue. "make" tends to pass commands containing shell meta-characters to a shell, rather than running them itself. This means such commands could include built-in commands, etc., as long as the command line also contains such a meta-character. However, many "make"s always pass them to "/bin/sh". Others pass them to the shell specified by the SHELL Makefile variable, which is generally inherited from the environment. Thus, while you can usually guarantee that the Bourne shell will get the commands, you're less likely to be able to guarantee that the C shell will get them. (Then again, with UNIX systems, you can usually guarantee that there's a Bourne shell available, but you're less likely to be able to guarantee that there's a C shell available.) Furthermore, some commands won't do what you expect; e.g., "cd". If your Makefile contains cd ; The will be executed in the same directory as the , the "cd" nonwithstanding; the will either be executed directly by "make" or by a subshell, the "cd" will be executed by a different subshell (the ";" is there to ensure that "make" doesn't try to execute a program named "cd"), and the will either be executed by "make" (which hasn't changed its current directory) or by a different subshell run from "make" (which will inherit "make"s current directory). Also, "make" passes commands to the shell with the "-c" flag; it passes a single command line to the shell. You can put the command on multiple lines in the Makefile, using backslashes at the end of the lines to continue the command, so that you can put a Bourne shell construct on multiple lines: for i in $(MAKEVARIABLE); do \ command $$i; \ done which gets passed to the shell as /bin/sh -c "for i in ; do command $i; done" The Bourne shell doesn't mind this; I don't know if the C shell does or not.