[comp.unix.questions] Q: Problem with null suffix rules

scott@spectra.com (Tim Scott) (01/16/90)

This seems like it should be trivial to do. I hope I can 
explain it clearly enough. 

I have a directory full of C programs: (say: a.c, b.c, c.c, ...)
each one builds an executable (a, b, c, ...) using the same
commands. Due to a "feature" of the *ix I I use, I have to do a 
couple syncs after the load (if you really want to know why,
send me mail. It's too awful to describe on a public net that
children may be reading :-) Thus I can't use the default null
suffix rules.

The following makefile correctly builds a from a.c if the latter
is newer than the former:

LIBS = /usr/lib/mylib.o  /usr/lib/notherlib.a
CFLAGS = -lfm

.c: 	
	cc -o $@ $@.o $(LIBS) $(CFLAGS)
	sync; sync

Fine for that. HOWEVER, what I want to do is have the makefile 
just do the load ONLY if a.o already exists and is newer than either 
a or a.c. (Sometimes I manually compile a.c for various reasons...)
I have tried a bunch of things, and read the O'Reilly book backwards 
and forwards and can't get it to work.

The whole idea of null suffixes is good, since that way I don't
have to modify the makefile each time I add, remove or change the
name of a program.c in the directory. 

Please, can anyone shed any light on this? I'd be very grateful.

(Email if you can, but I'll check this group if you feel it's of
general interest or can't get mail to me.)

[P.S. Does it matter that I'm using AIX 2.2.1 on an IBM PC-RT?]

Disclaimer: So what's to disclaim already?!

dold@mitisft.Convergent.COM (Clarence Dold) (01/17/90)

in article <307@spectra.COM>, scott@spectra.com (Tim Scott) says:

> The whole idea of null suffixes is good, since that way I don't
> have to modify the makefile each time I add, remove or change the
> name of a program.c in the directory. 

You can clear out all predefined suffixes with (pg 6 of make(1)):
.SUFFIXES:
with no dependencies clears the list of suffixes.
Put your own back in with:
.SUFFIXES: .o
You might also try undefining the rule regarding the .c to .o conversion:
.o.c:;

-- 
---
Clarence A Dold - dold@tsmiti.Convergent.COM            (408) 435-5293
               ...pyramid!ctnews!tsmiti!dold        FAX (408) 435-3105
               P.O.Box 6685, San Jose, CA 95150-6685         MS#10-007