Path: utzoo!attcan!uunet!husc6!bloom-beacon!gatech!hubcap!ncrcae!ncr-sd!hp-sdd!hplabs!hpda!hpsemc!bd From: bd@hpsemc.HP.COM (bob desinger) Newsgroups: comp.sys.hp Subject: Re: problems with make Message-ID: <1250006@hpsemc.HP.COM> Date: 16 May 88 07:43:59 GMT References: <12407@sri-spam.istc.sri.com> Organization: HP Technology Access Center, Cupertino, CA Lines: 78 > you can also get more refined by not looking at > the kernel, but rather: > IFHP300 = test ! -f /bin/hp9000s300 > IFSUN3 = test ! -f /bin/sun3 > IFBSD = test ! -f /vmunix > IFHPUX = test ! -f /hp-ux > and so on. Yes, but be careful about merely checking the existence of the programs in /bin/hp9000s*00; they're actually links to true(1) and false(1) to return an exit status corresponding to the machine. In other words, on the Series 300 and 800 both /bin/hp9000s300 and /bin/hp9000s800 exist. On the Series 300, /bin/hp9000s300 returns true and /bin/hp9000s800 returns false. On the Series 800, /bin/hp9000s300 returns false and /bin/hp9000s800 returns true. To get concrete about it, they're intended to be used in scripts as: /bin/hp9000s300 && echo "Here I am on my s300" /bin/hp9000s800 && echo "This executes on my s800" The make command will complain about "Exit status 255" and stop prematurely if the makefile uses them that way and the rule for the `false' machine is executed. (/bin/false is simply `exit 255'; cat the file out and see.) So you have to use them somewhat counter- intuitively in the makefile, but it's nothing really strange for those who have been following this newsgroup: # Which machine are we on? (second version) IFHP300 = if hp9000s300 2>/dev/null; then IFHP800 = if hp9000s800 2>/dev/null; then IFSUN3 = if sun3 2>/dev/null; then target: $(IFHP300) echo Series 300; fi $(IFHP800) echo Series 800; fi $(IFSUN3) echo Sun 3; fi @echo Done (The "2>/dev/null" keeps you from seeing complaints from the shell about "sh: sun3: Command not found".) As a matter of taste, you might prefer an extra makefile line of FI = ; fi with a cosmetic change to the target's rules: target: $(IFHP300) echo Series 300 $(FI) $(IFHP800) echo Series 800 $(FI) $(IFSUN3) echo Sun 3 $(FI) @echo Done However you prefer the appearance, this solution gives you finer control over your makes. I like this solution better because it's the cleanest so far. (I wrote the earlier hack of peering at the kernels because I didn't know that Sun offered /bin/sun3. But since they do, it's better to use the tools provided.) >>By the way, your original makefile fragment works correctly on my >>hp9000s800 (running 2.0). > because i bet you use ksh which knows about "]". Caught in the act! > since you're thinking about makefiles now, how would you accomplish > something like > > --bw Could you repost that last fragment again? The above four lines are all I found on my machine. -- bd