Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 37e222326095a93978d54b1564dd9954 > files > 37

apcupsd-3.10.5-1mdk.ppc.rpm

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Riccardo Facchetti">
   <meta name="GENERATOR" content="Mozilla/4.74 [en] (X11; U; Linux 2.4.3 i586) [Netscape]">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EF" vlink="#51188E" alink="#FF0000">

<h2>
Makefiles subsystem</h2>

<p><br>The Makefiles subsystem is designed to optimize the local Makefile
with global Rules and Targets. There are two general Makefile fragments
that are included during generation of Makefile from Makefile.in. All Makefiles
must include these two general fragments that furnish general variables
and general target rules. Inclusion is done with the keywords @RULES@ and
@TARGETS@ in the Makefile.in. If you need to write a new Makefile, please
look at an existing Makefile for general information on how to organize
the Makefile. The fragments are in autoconf/Rules.mak.in and autoconf/Targets.mak.
For a complete understanding of the inner working, please look at these
two fragments and at the Makefiles.
<p>There are some local variables to the Makefiles used by fragments. These
variables are:
<br>&nbsp;
<ul>
<li>
<font color="#FF0000">subdirs</font> subdirectories that contain a Makefile.in</li>

<li>
<font color="#FF0000">allexe</font> contains all the binaries generated
locally (libs and exes)</li>

<li>
<font color="#FF0000">LOCALDEFS</font> local defines: -Dsomething</li>
</ul>

<p><br>The targets needed by each local Makefile are listed in the "all-targets"
directive.
<br>&nbsp;

<h2>New Makefile.in design.</h2>

<p>
This new design is made to ease Makefile.in management.
To reach this objective all the common Makefile variables
and rules are included from two common files at configure
time.

<p>
To include these files, you must start your Makefile.in
with the following fragment:

<p>
<pre>
# Default variables
@VARIABLES@
# TOP source directory.
topdir = @top_srcdir@
top_builddir = $(topdir)
</pre>

<p>
The directive @VARIABLES@ includes the file variables.mak,
then, to define correctly the topdir and top_builddir
variables, that are the root sources directory relative to
the current path, the following two assignments must be done.

<p>
Now, to automate the traversing of subdirectories you must
list all the subdirectories that contain a Makefile in the
subdirs variable:

<p>
<pre>
#
# this is a list of all subdirectories that contain Makefiles
#
subdirs = @INTLSUB@ @POSUB@ drivers @WIN32@ src @CGI@
</pre>

<p>
This to allow the Makefile subsystem to know where it must
go to generate libraries and executables prior to make the
current directory.

<p>
Following the subdirs directive, all the common targets must
be included:

<p>
<pre>
# Include the default make targets: to be put before the all-targets: rule.
@TARGETS@
</pre>

<p>
These @TARGETS@ include also the 'all:' target for convenience. To
define all the targets to be made in the current directory you
must specify them with the following directive:

<p>
<pre>
all-targets: Makefile apcupsd apctest
</pre>

<p>
After defining the all-targets you can define the make rules.
Remembering that the generic '.c.o:' rule is already defined in
targets.mak, we can simply define the rules to make the
executables:

<p>
<pre>
dobjs = daemonobj.o
gobjs = genericobj.o
apcupsd: $(dobjs) $(gobjs) $(LIBS)
    $(CC) $(LDFLAGS) $(dobjs) $(gobjs) $(LIBS) $(WINAPC) $(WINLIBS) \
        -o apcupsd
</pre>

<p>
In this example $(dobjs) and $(gobjs) are defined locally because they
are local rules and dependancies for the apcupsd executable and not
generic rules for all the package.

<p>
After that you must add the install and uninstall rules. Note that
these rules are mandatory and if you have nothing to (un)install in
the current directory you must define them as dummy targets.

<p>
<pre>
install:

uninstall:
</pre>

<p>
Obviously this is a simple description on how to write a Makefile.in
for apcupsd. If you follow these rules your Makefile.in files will be
short, clean, readable and, I did my best for this, simple.

<h2>Generic variables in variables.mak.in</h2>

<h3>$(allexe)</h3>

<p>
If one or more of your targets are executables, assign them to
the $(allexe) variable and then add to all-targets: dependancy.

<h2>Generic targets in targets.in</h2>

<h3>$(LIBRARY)</h3>

<p>
All the libraries are specified in the targets with their dependancies
so any reference to a library will automatically generate a dependancy
check.

</body>
</html>