[comp.mail.sendmail] UkSendmail1.5 dom,chn Makefiles fall over on Ultrix

robert@vax1.computing-maths.cardiff.ac.uk (Robert Evans) (07/29/88)

The Makefiles in ./dom and ./chn in the UK Sendmail-1.5 distribution
fall over in certain circumstances under make on Ultrix.
Rules of the form:
	-@if [ some test ]; then statement; fi
emit error code 1 (which is ignored by make) if sometest is false.
Without the "-", the error causes make to fail.
The second test in the Makefiles (for host.{chn,dom} being non-empty)
didn't have the "-" and so stopped the make.  A solution is to put a "-"
at the front of the command:
	-@if [ ! -s $@ ] ; \
Another improvement is to put a dummy "else" part into these if commands.
This stops the "Error code 1 (ignored)" message if `some test' is false.

I don't know if this applies to version of UN*X other than Ultrix.  I've
met this problem before when building software written for UNIX System V
on Ultrix.   Two replacement Makefiles follow:

--------- ./dom/Makefile ---- cut here
#########################################################################
#	UK-1.5(glasgow) Sendmail Configuration Package 			#
#	Author: Jem Taylor <taylor@uk.ac.glasgow.cs>			#
#	File: ./dom/Makefile						#
#	Role: generate dom/$site.dom from dom/$site.tab/*.dom files	#
#########################################################################

.SUFFIXES: .dom .tab
.PRECIOUS: *.dom

.tab.dom: $<.tab/*.dom Makefile
	-@if [ -s $@ ]; then rm -f $@.BCK && mv $@ $@.BCK; else :; fi
	./MAKE $* $</*.dom 
	-@if [ ! -s $@ ] ; \
		then	echo "$@ null - Abort" ;\
			if [ -s $@.BCK ] ; then mv $@.BCK $@ ; fi;\
			exit 99 ; else :; fi
	-@if cmp $@.BCK $@ > /dev/null 2>&1 ;\
		then	rm -f $@.BCK ; \
			echo "$@ not changed since last made." ; \
		else	echo "Saving old ../dom/$@ as ../dom/$@.OLD ..." ; \
			rm -f $@.OLD && mv $@.BCK $@.OLD ; fi
--------- ---- cut here
--------- ./chn/Makefile ---- cut here
#!/bin/make -f
#########################################################################
#	UK-1.5(glasgow) Sendmail Configuration Package 			#
#	Author: Jem Taylor <taylor@uk.ac.glasgow.cs>			#
#	File: ./chn/Makefile						#
#	Role: generate chn/$host.chn from chn/$host.tab/*.chn files	#
#########################################################################

.SUFFIXES: .chn .tab
.PRECIOUS: *.chn

.tab.chn: $</*.chn Makefile
	-@if [ -s $@ ]; then rm -f $@.BCK && mv $@ $@.BCK; else :; fi
	./MAKE $* $</*.chn 
	-@if [ ! -s $@ ] ; \
		then	echo "$@ null - Abort" ;\
			if [ -s $@.BCK ] ; then mv $@.BCK $@ ; fi;\
			exit 99 ; else :; fi
	-@if cmp $@.BCK $@ > /dev/null 2>&1 ;\
		then	rm -f $@.BCK ; \
			echo "$@ not changed since last made." ; \
		else	echo "Saving old ../chn/$@ as ../chn/$@.OLD ..." ; \
			rm -f $@.OLD && mv $@.BCK $@.OLD ; fi
--------- ---- cut here

-- 
-- 
  Robert Evans, Dept of Computing Maths, University College Cardiff,
  PO Box 916, Cardiff, Wales, UK, CF2 4YN.  Tel: +44 (0)222 874000 x 5518
  E-mail: R.Evans@computing-maths.cardiff.ac.uk     UUCP: R.Evans@cf-cm.UUCP

taylor@cs.glasgow.ac.uk (Jem Taylor) (07/30/88)

	The Makefiles in ./dom and ./chn in the UK Sendmail-1.5 distribution
	fall over in certain circumstances under make on Ultrix.
	Rules of the form:
		-@if [ some test ]; then statement; fi
	emit error code 1 (which is ignored by make) if sometest is false.
	Without the "-", the error causes make to fail.
	The second test in the Makefiles (for host.{chn,dom} being non-empty)
	didn't have the "-" and so stopped the make.  A solution is to put a "-"
	at the front of the command:
		-@if [ ! -s $@ ] ; \
But the intention *is* to stop the make if the generated file is null ...
are you saying the make stops when the file is non-null ? That is, when
the test fails ? This is really nasty ! 
To abort  when the file is null, we need to invert the test.

	Another improvement is to put a dummy "else" part into these if commands.
	This stops the "Error code 1 (ignored)" message if `some test' is false.

Good idea.	

I suggest the following fragment.

        @if [ -s $@ ] ; \
                then :; \
                else    echo "$@ null - Abort" ;\
                        if [ -s $@.BCK ] ; then mv $@.BCK $@ ; fi;\
                        exit 99 ; fi

robert@vax1.computing-maths.cardiff.ac.uk (Robert Evans) (07/30/88)

| 		-@if [ ! -s $@ ] ; \
| But the intention *is* to stop the make if the generated file is null ...
| are you saying the make stops when the file is non-null ? That is, when
| the test fails ? This is really nasty ! 
| To abort  when the file is null, we need to invert the test.
Yes.

| I suggest the following fragment.
| 
|         @if [ -s $@ ] ; \
|                 then :; \
|                 else    echo "$@ null - Abort" ;\
|                         if [ -s $@.BCK ] ; then mv $@.BCK $@ ; fi;\
|                         exit 99 ; fi
That would have the desired effect but the make aborts as a side effect of the
test "[ -s $@ ]" being false rather than because of the exit! (Hard to believe
but I just tried it to see).

Robert