help-make
[Top][All Lists]
Advanced

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

help on Makefile


From: Yin Lei
Subject: help on Makefile
Date: Mon, 4 Jun 2001 16:42:28 -0700 (PDT)

Hi, Paul:

Sorry for disturbing you again. :)

Based on your suggestion, our new make system is shown in following:

proj1.mk
--------
MODNAME = proj1
$(MODNAME)_SUBDIRS = sub1 sub2 sub3

$(MODNAME)_FILES = $(foreach f, $($(MODNAME)_SUBDIRS),\
                 src/$(f)/$(ARCH)/$(notdir $(f)))
$(MODNAME)_OBJS = $($(MODNAME)_FILES:%=%.o)

$(MODNAME):     $($(MODNAME)_OBJS)

$($(MODNAME)_OBJS): $($(MODNAME)_SUBDIRS)

$($(MODNAME)_OBJS): $($(MODNAME)_SUBDIRS)
        $(MAKE) -C $@


proj2.mk
--------
MODNAME = proj2
$(MODNAME)_SUBDIRS = sub1 sub2 sub4

$(MODNAME)_FILES = $(foreach f, $($(MODNAME)_SUBDIRS),\
                src/$(f)/$(ARCH)/$(notdir $(f)))
$(MODNAME)_OBJS = $($(MODNAME)_FILES:%=%.o)

$(MODNAME):     $($(MODNAME)_OBJS)

$($(MODNAME)_OBJS): $($(MODNAME)_SUBDIRS)
        $(MAKE) -C $@


top-level Makefile
------------------
... (build macro)

.PHONY: all
all:

PROJECTS = proj1 proj2

include $(PROJECTS:%=%.mk)

$(PROJECTS):
        address@hidden "====> Making $@ ..."
        $(CC) $(address@hidden) -o $@

all:    $(PROJECTS)


Currently the problems are:
1. When both "proj1" and "proj2" are using the same subdirectories,
   such as "sub1" and "sub2" list in this example, this strategy
   doesn't work. Because the dependency of "sub1" and "sub2" are
   both "proj1" and "proj2", seems that "make" was confused during
   making. So how to solve this problem?

2. For solving above problem, I modified top-level Makefile as following:

new top-level Makefile
----------------------
... (build macro)

.PHONY: all
all:

PROJECTS = proj1 proj2

include $(PROJECTS:%=%.mk)

SUBDIRS = $(sort $(filter-out /%, $(foreach f, $(PROJECTS), \
                $($(f)_SUBDIRS))))
ALL_ARCH_OBJS = $(sort $(filter-out /%, $(foreach f, $(PROJECTS), \
                $($(f)_ARCH_OBJS))))

$(ALL_ARCH_OBJS):
        address@hidden
        $(MAKE) -C src/$(patsubst %.o,%,$(notdir $*))

$(PROJECTS):
        address@hidden "====> Making $@ ..."
        $(CC) $(address@hidden) -o $@

all:    $(PROJECTS)

Seems above solution can work, but the problem is, if you modified
one source files in one of sub-directory(e.g. sub1). This solution
will not rebuild this directory.

So, if there is any better solution for my problems?

Thanks.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lei Yin, Ph.D
Celestry Design Technologies, Inc
1982A Zanker Road, San Jose, CA 95112
Tel: (408)501-2313(O) | Fax: (408)501-2607
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"I'd change the world but God won't give me the source code" -- Anonymous





reply via email to

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