help-make
[Top][All Lists]
Advanced

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

Re: How to capture a set of recurring rules?


From: Paul Smith
Subject: Re: How to capture a set of recurring rules?
Date: Fri, 05 Feb 2010 00:34:57 -0500

On Tue, 2010-02-02 at 07:58 -0600, Peng Yu wrote:
> That is because I want to keep everything related to a RData file
> close to each other. Otherwise, I have changed multiple distant places
> in a Makefile. When the number of RData is larger, it will be a
> nightmare to maintain the makefile.

Most experienced makefile authors will agree, I expect, that the Best
Practice way to write a complex makefile environment is to use the
variable assignment method.

That is, every makefile doesn't do anything but assign to variables.  No
rules are written at all.

So a makefile might look something like:

        PROGRAMS += myprog

        myprog_SRCS = myprog.c myio.c myprint.c
        myprog_CPPFLAGS = -I$(topdir)/include
        myprog_LIBS = -lm

etc.  This is all simple, straightforward, and easy to understand.  Any
developer and create and maintain these files.  Obviously, depending on
your situation, you might have to be more complicated than this.


Then you have your makefile guru create a set of "framework" makefiles
that use the variable values, plus some advanced make techniques that
include recursive variable definitions, $(eval) and $(call), and others,
and instantiate rules to allow all the work to happen.  This is deep
magic, often, but that's OK because only the magicians need to
understand it.  Use include or special wrapper scripts or whatever to
get the framework makefiles into make.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "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]