[comp.unix.sysv386] bug in SCO UNIX makefiles ?

aed@netcom.UUCP (Andrew Davidson) (01/01/91)

hi
I was wondering if someone has any idea how to fix this make file. I am working
in C++. As a result I have decide to use .cc and .hh as the sufixes for my 
files so that I would not confuse them with reqular C code. This make file work
correctly on a SUN work stations, but does not work on SCO UNIX
here is the output from the make file

	% make

        g++ -o coinTest -g coin.o test1.o -lg++ -lm
	ld fatal: Can't read 1st word of file coin.o
	*** Error code 1

	Stop.

it appears that it never finds the production rule
.cc.o:. (there are no *.o files in this directory)

here is the makefile

CC= 	g++
OBJS=	coin.o test1.o
SRCS = coin.cc test1.cc
LIBS= 	-lg++ -lm
INCLUDE= -I/usr/local/lib/g++-include

.cc.o: 
	$(CC) -c -g $<

coinTest : $(OBJS) coin.hh genericlt.hh
	$(CC) -o $@ -g $(OBJS) $(LIBS)

clean :
	rm -f coinTest *.o


#
# notes
#

#
#  $@ the name of the current target
#

#
# $< the name of a dependency file, derived as if selected
# for use with an implicit rule
#

depend : 
	makedepend -- $(CFLAGS) -- $(INCLUDE) -- $(SRCS)
# DO NOT DELETE THIS LINE -- make depend depends on it.

coin.o: /usr/local/lib/g++-include/stream.h
coin.o: /usr/local/lib/g++-include/ostream.h
coin.o: /usr/local/lib/g++-include/File.h
coin.o: /usr/local/lib/g++-include/builtin.h
coin.o: /usr/local/lib/g++-include/stddef.h /usr/local/lib/g++-include/std.h
coin.o: /usr/local/lib/g++-include/stdio.h /usr/local/lib/g++-include/math.h
coin.o: /usr/local/lib/g++-include/values.h
coin.o: /usr/local/lib/g++-include/streambuf.h
coin.o: /usr/local/lib/g++-include/istream.h coin.hh
test1.o: /usr/local/lib/g++-include/stream.h
test1.o: /usr/local/lib/g++-include/ostream.h
test1.o: /usr/local/lib/g++-include/File.h
test1.o: /usr/local/lib/g++-include/builtin.h
test1.o: /usr/local/lib/g++-include/stddef.h /usr/local/lib/g++-include/std.h
test1.o: /usr/local/lib/g++-include/stdio.h /usr/local/lib/g++-include/math.h
test1.o: /usr/local/lib/g++-include/values.h
test1.o: /usr/local/lib/g++-include/streambuf.h
test1.o: /usr/local/lib/g++-include/istream.h coin.hh genericlt.hh
test1.o: /usr/local/lib/g++-include/generic.h

thanks Andy

-- 
-----------------------------------------------------------------
                  "bede-bede-bede Thats all Folks"
				Porky Pig
Andy Davidson
Woodside CA.
aed@netcom
-----------------------------------------------------------------

tim@delluk.uucp (Tim Wright) (01/03/91)

In <19746@netcom.UUCP> aed@netcom.UUCP (Andrew Davidson) writes:

>hi
>I was wondering if someone has any idea how to fix this make file. I am working
>in C++. As a result I have decide to use .cc and .hh as the sufixes for my 
>files so that I would not confuse them with reqular C code. This make file work
>correctly on a SUN work stations, but does not work on SCO UNIX
...

>it appears that it never finds the production rule
>.cc.o:. (there are no *.o files in this directory)

>here is the makefile

...
>.cc.o: 
>	$(CC) -c -g $<

RTFM.
Suffixes have to be declared with ".SUFFIXES" before you can use them i.e.
you need a line of the form
.SUFFIXES: .cc .hh
before you can setup rules of the above form. I don't why this strangeness
is in Sys V but it is !

Tim
--
Tim Wright, Dell Computer Corp. (UK) | Email address
Bracknell, Berkshire, RG12 1RW       | Domain: tim@dell.co.uk
Tel: +44-344-860456                  | Uucp: ...!ukc!delluk!tim
"What's the problem? You've got an IQ of six thousand, haven't you?"

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (01/04/91)

As quoted from <tim.662894618@holly> by tim@delluk.uucp (Tim Wright):
+---------------
| Suffixes have to be declared with ".SUFFIXES" before you can use them i.e.
| you need a line of the form
| .SUFFIXES: .cc .hh
| before you can setup rules of the above form. I don't why this strangeness
| is in Sys V but it is !
+---------------

When I responded to him (via mail) I explained not only what but what I
suspect is why.  Maybe the why needs to be aired more publicly....

The problem with make recognizing suffix rules on its own is that it won't do
the right thing with "dot-files".  I've seen Makefiles that, for example,
eschew the "all" rule (where "all" isn't a file, it's just used as a rule
name) in favor of an actual file name that gets "touch"ed when everything is
up to date --- and use a file like ".all" to do it.  (Actually, there is an
"all" rule:

	all: .all

I've never needed that kind of hack --- but I have needed another hack that
used .-files to track update times of archive entries in archive formats make
knows nothing about (ACMB, anyone?).)

If make grabs anything starting with a dot as a suffix rule, then you can't
"make" a file starting with a dot.  If it requires two dots, the problem is
lessened at the expense of suffix rules like:

	.c:
		$(CC) $(CFLAGS) -o $* $<

It can, of course, intuit the proper behavior by checking for a file with the
right name --- but then someone else can break that, either unintentionally or
maliciously, by saying "cp /dev/null .c.o".  The .SUFFIXES target lets you be
more explicit about how to recognize suffix rules without having to explicitly
define individual suffix rules as such (".SUFFIXRULE: .c.o" would be safest,
but much more of a pain than just specifying the list of suffixes and then
combining them as desired).

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY