help-make
[Top][All Lists]
Advanced

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

Re: urgent help on Makefile


From: Paul D. Smith
Subject: Re: urgent help on Makefile
Date: Sun, 6 May 2001 19:43:57 -0400

%% Yin Lei <address@hidden> writes:

  yl>   for each target, create a file named as $(target name).list
  yl>   in this file, I can put the list of source codes.
  yl>   In Makefile, there is a macro named as "MODULE_LIST", which
  yl>   contains the list of my targets. I hope that Makefile can
  yl>   check the source codes for each target automatically.

  yl> $(MODULE_LIST):%:
  yl>   override MODULE_SOURCE = $(sort $(filter-out /%, $(shell cat \
  yl>                            $*.list)))
  yl>   override MODULE_OBJS   = $(MODULE_SOURCE:%.c=%.o)

This can't work, because you can't put make commands (like variable
assignments) inside a command script.  The command script is passed to
the shell and run there, and make syntax is (except by accident) not
valid there.

Even if it were, values set in a subprocess like a shell cannot affect
the parent process.

Plus, this is broken in other ways.

  yl> could you please tell me how to do it?

There are several ways.  However, there are no perfect ways.  The
simplest, if you're willing to do it, is put the prerequisites in the
project makefiles themselves; something like:

  MODULE_LIST = proj1 proj2 proj3

  include $(MODULE_LIST:%=%.mk)

  $(MODULE_LIST):
        <do whatever to build a module>

Then in each proj1.mk, proj2.mk, proj3.mk, etc. you'd have:

  SRCS = foo.c bar.c baz.c

  proj1: $(SRCS:.c=.o)

If you're not willing to put the prerequisite into the project makefile,
then there are other things you can do.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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