help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple submake


From: Boris Mayer St-Onge
Subject: Multiple submake
Date: Fri, 05 Jul 2002 18:19:56 -0400

Hi,

I have a system with several source and include directories, as

src/main/main.cxx
src/misc/test1.cxx
src/misc/image/picture.cxx
src/gui/panel1.cxx
include/main/main.h
include/misc/test1.h
include/misc/image/picture.h
include/gui/panel1.h

and I have makefile in each directory.  In the root directory:

MD      = ./
DIRS    = src
include $(MD)makeinclude

In src directory:

MD      = ../
DIRS    = main misc gui
include $(MD)makeinclude

In misc directory:

MD      = ../../
DIRS    = image
SOURCE  = picture.cxx
include $(MD)makeinclude

and so on.  The makeinclude is the following:

CXX             = g++
OBJDIR          = $(MD)obj/
INCDIR          = $(MD)include
CXXFLAGS        = -c -I$(INCDIR)
OBJECT          = $(SOURCE:%.cxx=$(OBJDIR)%.o)

all: $(OBJECT)
        @for dir in $(DIRS); do\
                (cd $$dir; $(MAKE) ) || break;\
        done

$(OBJDIR)%.o : %.cxx
        $(CXX) $< $(CXXFLAGS) -o $@


With this, I can compile all my source file without problem.  Now I want
to link them but I have 2 problems:

(1) I don't know how to write the rule that the link will be done only
if the bin file is older that objet file.  I have a problem with the for
command.  For the moment, the linkage is done each time, with this rule
:

all: help
        g++ obj/main.o obj/misc/... [skip] -o main

help: $(OBJECT)
        @for dir in $(DIRS); do\
                (cd $$dir; $(MAKE) help ) || break;\
        done

(2) The second problem is how to generate the list of the object file
that will be use by the linker.  The variable OBJECT is set in each
directory so when I link, this variable is empty.


I have tried several options, read manuals, but I can't figure how to
solve these two problems.  Any help with be greatly appreciated.

Boris



reply via email to

[Prev in Thread] Current Thread [Next in Thread]