[comp.lang.c] Problems with Makefile executing "make" in sub directories

jpoplaws@telesci.UUCP (Joseph E Poplawski) (01/19/90)

Hello.  I am trying to write a program that keeps the different executables in
three seperate directories.  At the top level directory, I have a Makefile that
in turn cd's to the appropriate directory and then executes a make in that 
directory.  Actually, that is what it is supposed to do, but the way I have it
setup doesn't work.  I have RTFM and tried some different methods but to no
avail.  No matter what, for the one directory, it always says it is up to date
even though there are NO files in the directory whatsoever, then for the other
executable directory, it stops with an "error code 1".  This and the other 
errors are shown in the script included below my signature.

If you have any ideas about what is happening, PLEASE let me know via e-mail
as soon as possible.  My system is an 80386 running UNIX V.3 (ISC 1.0.5).

Thanks in advance.

-Jo
--
Joseph E Poplawski (Jo)
Home:  5 Sussex Drive, Willingboro, NJ  08046-1407    Phone:  +1 609 835-2846
UUCP:  ...{rutgers!rochester!moscom,princeton,pyrnj}!telesci!fantasci!jep
       jep@fantasci.uucp   jpoplaws@telesci.uucp

Script started Thu Jan 18 22:50:39 1990

$ cat Makefile

# Makefile

CC		=	/bin/cc
CP		=	/bin/cp
RM		=	/bin/rm -f
SHELL		=	/bin/ksh

qccs:		lib
		cd \
			qccs
			$(MAKE)

qmas:
		( cd qmas ; make )

lib:
		( cd libs ; make )


$ make lib
	( cd libs ; make )
*** Error code 1

Stop.

$ ls -l libs
total 9
-rw-r-----   1 jep      softdev     1187 Jan 18 04:32 Makefile
-rw-r-----   1 jep      softdev      909 Jan 18 03:53 keyret.c
-rw-r-----   1 jep      softdev      750 Jan 17 23:24 random.c
-rw-r-----   1 jep      softdev      830 Jan 17 23:25 sort.c

$ make qccs
	( cd libs ; make )
*** Error code 1

Stop.

$ ls -l qccs

[it lists the Makefile and all the *.c files but there is no executable or
  .o files whatsoever!]

$ make qmas
`qmas' is up to date.

$ ls -l qmas
total 0

Script done Thu Jan 18 22:51:40 1990

cpcahil@virtech.uucp (Conor P. Cahill) (01/22/90)

In article <926@telesci.UUCP>, jpoplaws@telesci.UUCP (Joseph E Poplawski) writes:
> qccs:		lib
> 		cd \
> 			qccs
> 			$(MAKE)

this wont work.  The $(MAKE) will run in the current directory, not in 
the sub-directory.

> qmas:
> 		( cd qmas ; make )

The reason for the problem with this is that qmas exists in the current
directory and since it has no dependencies it doesn't need to be made.
A second issue, while not a real problem, is that the parens are not needed
for this.  All you need is:  cd wherever; make
	
> lib:
> 		( cd libs ; make )

> $ make lib
> 	( cd libs ; make )
> *** Error code 1

Since you dont show the Makefile in libs, I can't tell you why you get
this error.  There is nothing wrong with the lines in this makefile.

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+