Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ames!pasteur!ucbvax!decwrl!hplabs!hpda!hpsemc!bd
From: bd@hpsemc.HP.COM (bob desinger)
Newsgroups: comp.sys.hp
Subject: Re: problems with make
Message-ID: <1250004@hpsemc.HP.COM>
Date: 11 May 88 00:38:25 GMT
References: <12407@sri-spam.istc.sri.com>
Organization: HP Technology Access Center, Cupertino, CA
Lines: 89

>   the hp9000s350 running 6.01 chokes on the following makefile fragment:
> 	$(LIBRARY):	$(OBJS)
> 			@echo -n "Loading $(LIBRARY) ... "
> 			@ar cru $(LIBRARY) $(OBJS)
> 			if [ "$(SYS)" != hp ]; then \
> 				ranlib $(LIBRARY); \
> 			fi
> 			@echo "done"
> the hp spits out:
> 	Missing ].
> 	*** Error code 1
> 	Stop.
>
>   note that i've had to create these "if" fragments to "script around"
>   the way that hp deals with ar, ranlib and install.

As a workaround, can you use a `test' construct to replace the `if'
with a one-liner?  Something to the effect of:

	test "$(SYS)" != hp && ranlib $(LIBRARY)

Another way to test what system you're on is to use the SVID programs
documented under machid(1).  The makefile would look something like:

	hp9000s300 || ranlib $(LIBRARY)

Be sure to use the `||' form instead of the `&&'; make will screech to
a halt if you use `&&' with a system that you're not on.

I doubt if the Sun has these System-V files, but you can create them
with the commands:

	cd /usr/local		# or wherever your Sun likes local stuff
	echo "exit 1" >hp9000s300	# return false
	chmod +x hp9000s300

Do a similar thing on your HP machine, except call the file "sun," for
future reference.

Here's yet another workaround.  It makes the makefile a little easier
to read, and you don't need to say "SYS=hp" or "SYS=sun" on the make
command line.  At the top of the makefile, put these three lines:

	  # Do conditional compilation from make's shell
	  IFHP	= test ! -f /hp-ux ||
	  IFSUN	= test ! -f /vmunix ||

Then write your target and rules to look something like:

	$(LIBRARY):
		$(IFHP) echo No need for ranlib
		$(IFSUN) ranlib $(LIBRARY)
		@echo "done"

This examines your kernel file to determine which system you're on.

>   the very polite
>   ranlib message about ar already producing the SYMTAB should be
>   suppressed and the install command is completely changed so that we
>   need to use this thing called cpset.

You can fix ranlib's wagon.  Get into a directory in your $PATH that's
before the one where ranlib lives:

	cd /usr/local		# or wherever
	echo 'exit 0' >ranlib	# ranlib always returns success
	chmod +x ranlib

Voila.  Ranlib for System V.  Now you can eliminate those `if'
statements from your makefiles.

I don't know where the HP `install' command came from---is it from
System V release 2?  This is from J. E. Lapin's book "Portable C and
Unix System Programming" (Prentice-Hall, 1987):

	install:
	This utility (supported on System III, System V release 1,
	and System V release 2) is one of the rare cases where
	features present in System V release 1 have been dropped from
	an otherwise compatible System V release 2 version.  The
	System V release 2 version is identical to System III.

The accompanying table shows that AT&T dropped the -g, -m, and -u
options from the SysV.2 version.

By the way, your original makefile fragment works correctly on my
hp9000s800 (running 2.0).

-- bd