bcarb@KSP.Unisys.COM (Brian Carb) (09/26/89)
I'm having a problem using a 'for' statement with 'make'. Consider the following trivial makefile: test: for i in 1 2 3 4; do echo "hello"; done This always generates an error such as Syntax error: do: command not found If I type the for command directly into the shell (or run it in a shell script), it performs without error. I get the same error on an NCR tower, a Convergent, and SCO 3.2. Am I missing something? Brian A. Carb (bcarb@ksp.unisys.com) Unisys - Knowledge Systems Frazer, PA
davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (09/27/89)
In article <715@bbking.KSP.Unisys.COM>, bcarb@KSP.Unisys.COM (Brian Carb) writes: | I'm having a problem using a 'for' statement with 'make'. Consider | the following trivial makefile: | | test: | for i in 1 2 3 4; do echo "hello"; done I tried this on three SysV machines and it worked on all of them. You are doing something other than what you think you are, because this flies on Xenix, Stellar, and Unicos. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon
gwyn@smoke.BRL.MIL (Doug Gwyn) (09/28/89)
In article <715@bbking.KSP.Unisys.COM> bcarb@KSP.Unisys.COM (Brian Carb) writes: >test: > for i in 1 2 3 4; do echo "hello"; done >This always generates an error such as >Syntax error: do: command not found There's nothing wrong with that Makefile. (I.e. I tried it and it worked fine for me.) Perhaps you have the SHELL variable set to a bogus shell? (Check both the Makefile and the environment.)
rae98@wash08.uucp (Robert A. Earl) (09/29/89)
In article <11169@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <715@bbking.KSP.Unisys.COM> bcarb@KSP.Unisys.COM (Brian Carb) writes: >>test: >> for i in 1 2 3 4; do echo "hello"; done >>This always generates an error such as >>Syntax error: do: command not found > >There's nothing wrong with that Makefile. >(I.e. I tried it and it worked fine for me.) This worked for me also (NCR Tower 32/850 SVR2). I have a secondary question concerning makefiles: Can you read in a variable for use in the makefile? i.e.: read a;echo $(a) Alternatively, can you pass args through make to be used in the makefile? What I really want to do is: make tar (system_name) and have the makefile generate a tar file and send it to system_name. the tar is easy.....any way to do the rest? -- =========================================================== Name: Bob Earl Phone: (202) 872-6018 (wk) UUCP: ...!uunet!wash08!rae98 BITNET: rae98@CAS
guy@auspex.auspex.com (Guy Harris) (09/30/89)
>| I'm having a problem using a 'for' statement with 'make'. Consider >| the following trivial makefile: >| >| test: >| for i in 1 2 3 4; do echo "hello"; done > > I tried this on three SysV machines and it worked on all of them. You >are doing something other than what you think you are, because this >flies on Xenix, Stellar, and Unicos. What he's doing is using the C shell as his login shell, and using a "make" that imports the SHELL environment variable as the "make" variable SHELL and uses the latter to select which shell should be used to run commands that can't be run directly by "make". If it works for you, either 1) you're using a Bourne-compatible shell as your login shell, 2) have a "make" that doesn't use import the SHELL environment variable or doesn't use it to select which shell to use to run commands, or 3) stuck SHELL=/bin/sh or something like that at the front of the Makefile. (In SunOS, "make" imports SHELL, along with other environment variables, but doesn't use it to select the shell to run - it always uses "/bin/sh" - while in BSD, "make" neither imports environment variables nor uses SHELL to select which shell to run. I can't speak for Xenix, Stellix, nor Unicos.) Not all users can necessarily do 1) or 2), or would want to. However, most authors of Makefiles can do 3), and I'd suggest that they do so, if they want to make sure their Makefiles run on as many systems as possible when run by as many users as possible.
davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (09/30/89)
In article <1989Sep29.164831.26616@wash08.uucp>, rae98@wash08.uucp (Robert A. Earl) writes: | Alternatively, can you pass args through make to be used in the makefile? | What I really want to do is: | | make tar (system_name) | and have the makefile generate a tar file and send it to system_name. | | the tar is easy.....any way to do the rest? I have several thoughts which may work or give you inspiration. If the number of systems is small you could have a makerule for each. Alternatively you can specify the system name as a parameter on the make command line. $ make tar SYSNAME=wimpy where the makefile has somthing like: # make tar here # # now send it to the remote, your favorite way rsh $(SYSNAME) cat ">/spool/new.tar" < tar # also you can: # uucp tar $(SYSNAME)!~/tarspool/new.tar If you don't need an interactive prompt you may be able to do this. The nice thing is that it can go in a script to run offhours. $ for sys in wimpy popeye olive sweetp > do make tar SYSNAME=$sys > done -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon
gwyn@smoke.BRL.MIL (Doug Gwyn) (09/30/89)
In article <1989Sep29.164831.26616@wash08.uucp> rae98@wash08.UUCP (Robert A. Earl) writes: >Can you read in a variable for use in the makefile? If I understood your question correctly, what you want is make target VAR=value which will override any definition for the "VAR" variable defined in the Makefile.
cpcahil@virtech.UUCP (Conor P. Cahill) (09/30/89)
In article <1989Sep29.164831.26616@wash08.uucp>, rae98@wash08.uucp (Robert A. Earl) writes: > Can you read in a variable for use in the makefile? > i.e.: > read a;echo $(a) sort of. You can read in a shell variable, but not a makefile variable. The mechanism is something like the following: target: echo "enter system name: \c"; \ read sysname; \ echo "sysname is $$sysname" Note that each line ends with a line continuation '\' so that make passes all three lines to the same shell. > Alternatively, can you pass args through make to be used in the makefile? > What I really want to do is: > > make tar (system_name) > and have the makefile generate a tar file and send it to system_name. How about: make tar sys=uunet and in the makefile: tar: /* stuff to generate file */ if [ -z "$(sys)" ]; then \ echo "No sys specified, file not transferred.";\ else \ echo "transferring file to $(sys)"; \ uucp tarfile $(sys)!tarfile; \ fi -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+
morrell@hpsal2.HP.COM (Michael Morrell) (10/03/89)
/ hpsal2:comp.unix.questions / guy@auspex.auspex.com (Guy Harris) / 3:08 pm Sep 29, 1989 / >| I'm having a problem using a 'for' statement with 'make'. Consider >| the following trivial makefile: >| >| test: >| for i in 1 2 3 4; do echo "hello"; done >| >| This always generates an error such as >| Syntax error: do: command not found > > I tried this on three SysV machines and it worked on all of them. You >are doing something other than what you think you are, because this >flies on Xenix, Stellar, and Unicos. What he's doing is using the C shell as his login shell, and using a "make" that imports the SHELL environment variable as the "make" variable SHELL and uses the latter to select which shell should be used to run commands that can't be run directly by "make". ---------- Strange. HP-UX uses a version of "make" which imports SHELL, but I get a different error message: for: Command not found. Maybe that's just due to the differences in the csh's.
andre@targon.UUCP (andre) (10/06/89)
In article <1989Sep29.164831.26616@wash08.uucp> rae98@wash08.UUCP (Robert A. Earl) writes: >In article <11169@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >>In article <715@bbking.KSP.Unisys.COM> bcarb@KSP.Unisys.COM (Brian Carb) writes: >>>test: >>> for i in 1 2 3 4; do echo "hello"; done >>>This always generates an error such as >>>Syntax error: do: command not found >> >This worked for me also (NCR Tower 32/850 SVR2). He probably uses the c-shell. >I have a secondary question concerning makefiles: >Can you read in a variable for use in the makefile? >read a;echo $(a) >Alternatively, can you pass args through make to be used in the makefile? >What I really want to do is: > >make tar (system_name) >and have the makefile generate a tar file and send it to system_name. You can get make macros from your environment, system=system_name ; export system ; make tar easier if you have to do it only once, pass it on the command line make system=system_name tar and if you really want to ask from the makefile and make must use the variable use first: read a ; make system="$a" tar -- \---| AAA DDDD It's not the kill, but the thrill of the chase. \ | AA AAvv vvDD DD Ketchup is a vegetable. /\ \ | AAAAAAAvv vvDD DD {nixbur|nixtor}!adalen.via _/__\__\| AAA AAAvvvDDDDDD Andre van Dalen, uunet!hp4nl!targon!andre