home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / make-3.75-bin.lha / info / make.info-7 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  38KB  |  797 lines

  1. This is Info file make.info, produced by Makeinfo-1.64 from the input
  2. file /ade-src/fsf/make/make.texinfo.
  3.    This file documents the GNU Make utility, which determines
  4. automatically which pieces of a large program need to be recompiled,
  5. and issues the commands to recompile them.
  6.    This is Edition 0.51, last updated 9 May 1996, of `The GNU Make
  7. Manual', for `make', Version 3.75 Beta.
  8.    Copyright (C) 1988, '89, '90, '91, '92, '93, '94, '95, '96
  9. Free Software Foundation, Inc.
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Free Software Foundation.
  21. File: make.info,  Node: Directory Variables,  Next: Standard Targets,  Prev: Command Variables,  Up: Makefile Conventions
  22. Variables for Installation Directories
  23. ======================================
  24.    Installation directories should always be named by variables, so it
  25. is easy to install in a nonstandard place.  The standard names for these
  26. variables are described below.  They are based on a standard filesystem
  27. layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and
  28. other modern operating systems.
  29.    These two variables set the root for the installation.  All the other
  30. installation directories should be subdirectories of one of these two,
  31. and nothing should be directly installed into these two directories.
  32. `prefix'
  33.      A prefix used in constructing the default values of the variables
  34.      listed below.  The default value of `prefix' should be
  35.      `/usr/local'.  When building the complete GNU system, the prefix
  36.      will be empty and `/usr' will be a symbolic link to `/'.  (If you
  37.      are using Autoconf, write it as `@prefix@'.)
  38. `exec_prefix'
  39.      A prefix used in constructing the default values of some of the
  40.      variables listed below.  The default value of `exec_prefix' should
  41.      be `$(prefix)'.  (If you are using Autoconf, write it as
  42.      `@exec_prefix@'.)
  43.      Generally, `$(exec_prefix)' is used for directories that contain
  44.      machine-specific files (such as executables and subroutine
  45.      libraries), while `$(prefix)' is used directly for other
  46.      directories.
  47.    Executable programs are installed in one of the following
  48. directories.
  49. `bindir'
  50.      The directory for installing executable programs that users can
  51.      run.  This should normally be `/usr/local/bin', but write it as
  52.      `$(exec_prefix)/bin'.  (If you are using Autoconf, write it as
  53.      `@bindir@'.)
  54. `sbindir'
  55.      The directory for installing executable programs that can be run
  56.      from the shell, but are only generally useful to system
  57.      administrators.  This should normally be `/usr/local/sbin', but
  58.      write it as `$(exec_prefix)/sbin'.  (If you are using Autoconf,
  59.      write it as `@sbindir@'.)
  60. `libexecdir'
  61.      The directory for installing executable programs to be run by other
  62.      programs rather than by users.  This directory should normally be
  63.      `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'.
  64.      (If you are using Autoconf, write it as `@libexecdir@'.)
  65.    Data files used by the program during its execution are divided into
  66. categories in two ways.
  67.    * Some files are normally modified by programs; others are never
  68.      normally modified (though users may edit some of these).
  69.    * Some files are architecture-independent and can be shared by all
  70.      machines at a site; some are architecture-dependent and can be
  71.      shared only by machines of the same kind and operating system;
  72.      others may never be shared between two machines.
  73.    This makes for six different possibilities.  However, we want to
  74. discourage the use of architecture-dependent files, aside from object
  75. files and libraries.  It is much cleaner to make other data files
  76. architecture-independent, and it is generally not hard.
  77.    Therefore, here are the variables Makefiles should use to specify
  78. directories:
  79. `datadir'
  80.      The directory for installing read-only architecture independent
  81.      data files.  This should normally be `/usr/local/share', but write
  82.      it as `$(prefix)/share'.  (If you are using Autoconf, write it as
  83.      `@datadir@'.) As a special exception, see `$(infodir)' and
  84.      `$(includedir)' below.
  85. `sysconfdir'
  86.      The directory for installing read-only data files that pertain to a
  87.      single machine-that is to say, files for configuring a host.
  88.      Mailer and network configuration files, `/etc/passwd', and so
  89.      forth belong here.  All the files in this directory should be
  90.      ordinary ASCII text files.  This directory should normally be
  91.      `/usr/local/etc', but write it as `$(prefix)/etc'.  (If you are
  92.      using Autoconf, write it as `@sysconfdir@'.)
  93.      Do not install executables in this directory (they probably belong
  94.      in `$(libexecdir)' or `$(sbindir)').  Also do not install files
  95.      that are modified in the normal course of their use (programs
  96.      whose purpose is to change the configuration of the system
  97.      excluded).  Those probably belong in `$(localstatedir)'.
  98. `sharedstatedir'
  99.      The directory for installing architecture-independent data files
  100.      which the programs modify while they run.  This should normally be
  101.      `/usr/local/com', but write it as `$(prefix)/com'.  (If you are
  102.      using Autoconf, write it as `@sharedstatedir@'.)
  103. `localstatedir'
  104.      The directory for installing data files which the programs modify
  105.      while they run, and that pertain to one specific machine.  Users
  106.      should never need to modify files in this directory to configure
  107.      the package's operation; put such configuration information in
  108.      separate files that go in `$(datadir)' or `$(sysconfdir)'.
  109.      `$(localstatedir)' should normally be `/usr/local/var', but write
  110.      it as `$(prefix)/var'.  (If you are using Autoconf, write it as
  111.      `@localstatedir@'.)
  112. `libdir'
  113.      The directory for object files and libraries of object code.  Do
  114.      not install executables here, they probably ought to go in
  115.      `$(libexecdir)' instead.  The value of `libdir' should normally be
  116.      `/usr/local/lib', but write it as `$(exec_prefix)/lib'.  (If you
  117.      are using Autoconf, write it as `@libdir@'.)
  118. `infodir'
  119.      The directory for installing the Info files for this package.  By
  120.      default, it should be `/usr/local/info', but it should be written
  121.      as `$(prefix)/info'.  (If you are using Autoconf, write it as
  122.      `@infodir@'.)
  123. `lispdir'
  124.      The directory for installing any Emacs Lisp files in this package.
  125.      By default, it should be `/usr/local/share/emacs/site-lisp', but
  126.      it should be written as `$(prefix)/share/emacs/site-lisp'.
  127.      If you are using Autoconf, write the default as `@lispdir@'.  In
  128.      order to make `@lispdir@' work, you need the following lines in
  129.      your `configure.in' file:
  130.           lispdir='${datadir}/emacs/site-lisp'
  131.           AC_SUBST(lispdir)
  132. `includedir'
  133.      The directory for installing header files to be included by user
  134.      programs with the C `#include' preprocessor directive.  This
  135.      should normally be `/usr/local/include', but write it as
  136.      `$(prefix)/include'.  (If you are using Autoconf, write it as
  137.      `@includedir@'.)
  138.      Most compilers other than GCC do not look for header files in
  139.      `/usr/local/include'.  So installing the header files this way is
  140.      only useful with GCC.  Sometimes this is not a problem because some
  141.      libraries are only really intended to work with GCC.  But some
  142.      libraries are intended to work with other compilers.  They should
  143.      install their header files in two places, one specified by
  144.      `includedir' and one specified by `oldincludedir'.
  145. `oldincludedir'
  146.      The directory for installing `#include' header files for use with
  147.      compilers other than GCC.  This should normally be `/usr/include'.
  148.      (If you are using Autoconf, you can write it as `@oldincludedir@'.)
  149.      The Makefile commands should check whether the value of
  150.      `oldincludedir' is empty.  If it is, they should not try to use
  151.      it; they should cancel the second installation of the header files.
  152.      A package should not replace an existing header in this directory
  153.      unless the header came from the same package.  Thus, if your Foo
  154.      package provides a header file `foo.h', then it should install the
  155.      header file in the `oldincludedir' directory if either (1) there
  156.      is no `foo.h' there or (2) the `foo.h' that exists came from the
  157.      Foo package.
  158.      To tell whether `foo.h' came from the Foo package, put a magic
  159.      string in the file--part of a comment--and `grep' for that string.
  160.    Unix-style man pages are installed in one of the following:
  161. `mandir'
  162.      The top-level directory for installing the man pages (if any) for
  163.      this package.  It will normally be `/usr/local/man', but you should
  164.      write it as `$(prefix)/man'.  (If you are using Autoconf, write it
  165.      as `@mandir@'.)
  166. `man1dir'
  167.      The directory for installing section 1 man pages.  Write it as
  168.      `$(mandir)/man1'.
  169. `man2dir'
  170.      The directory for installing section 2 man pages.  Write it as
  171.      `$(mandir)/man2'
  172. `...'
  173.      *Don't make the primary documentation for any GNU software be a
  174.      man page.  Write a manual in Texinfo instead.  Man pages are just
  175.      for the sake of people running GNU software on Unix, which is a
  176.      secondary application only.*
  177. `manext'
  178.      The file name extension for the installed man page.  This should
  179.      contain a period followed by the appropriate digit; it should
  180.      normally be `.1'.
  181. `man1ext'
  182.      The file name extension for installed section 1 man pages.
  183. `man2ext'
  184.      The file name extension for installed section 2 man pages.
  185. `...'
  186.      Use these names instead of `manext' if the package needs to
  187.      install man pages in more than one section of the manual.
  188.    And finally, you should set the following variable:
  189. `srcdir'
  190.      The directory for the sources being compiled.  The value of this
  191.      variable is normally inserted by the `configure' shell script.
  192.      (If you are using Autconf, use `srcdir = @srcdir@'.)
  193.    For example:
  194.      # Common prefix for installation directories.
  195.      # NOTE: This directory must exist when you start the install.
  196.      prefix = /usr/local
  197.      exec_prefix = $(prefix)
  198.      # Where to put the executable for the command `gcc'.
  199.      bindir = $(exec_prefix)/bin
  200.      # Where to put the directories used by the compiler.
  201.      libexecdir = $(exec_prefix)/libexec
  202.      # Where to put the Info files.
  203.      infodir = $(prefix)/info
  204.    If your program installs a large number of files into one of the
  205. standard user-specified directories, it might be useful to group them
  206. into a subdirectory particular to that program.  If you do this, you
  207. should write the `install' rule to create these subdirectories.
  208.    Do not expect the user to include the subdirectory name in the value
  209. of any of the variables listed above.  The idea of having a uniform set
  210. of variable names for installation directories is to enable the user to
  211. specify the exact same values for several different GNU packages.  In
  212. order for this to be useful, all the packages must be designed so that
  213. they will work sensibly when the user does so.
  214. File: make.info,  Node: Standard Targets,  Prev: Directory Variables,  Up: Makefile Conventions
  215. Standard Targets for Users
  216. ==========================
  217.    All GNU programs should have the following targets in their
  218. Makefiles:
  219. `all'
  220.      Compile the entire program.  This should be the default target.
  221.      This target need not rebuild any documentation files; Info files
  222.      should normally be included in the distribution, and DVI files
  223.      should be made only when explicitly asked for.
  224.      By default, the Make rules should compile and link with `-g', so
  225.      that executable programs have debugging symbols.  Users who don't
  226.      mind being helpless can strip the executables later if they wish.
  227. `install'
  228.      Compile the program and copy the executables, libraries, and so on
  229.      to the file names where they should reside for actual use.  If
  230.      there is a simple test to verify that a program is properly
  231.      installed, this target should run that test.
  232.      Do not strip executables when installing them.  Devil-may-care
  233.      users can use the `install-strip' target to do that.
  234.      If possible, write the `install' target rule so that it does not
  235.      modify anything in the directory where the program was built,
  236.      provided `make all' has just been done.  This is convenient for
  237.      building the program under one user name and installing it under
  238.      another.
  239.      The commands should create all the directories in which files are
  240.      to be installed, if they don't already exist.  This includes the
  241.      directories specified as the values of the variables `prefix' and
  242.      `exec_prefix', as well as all subdirectories that are needed.  One
  243.      way to do this is by means of an `installdirs' target as described
  244.      below.
  245.      Use `-' before any command for installing a man page, so that
  246.      `make' will ignore any errors.  This is in case there are systems
  247.      that don't have the Unix man page documentation system installed.
  248.      The way to install Info files is to copy them into `$(infodir)'
  249.      with `$(INSTALL_DATA)' (*note Command Variables::.), and then run
  250.      the `install-info' program if it is present.  `install-info' is a
  251.      program that edits the Info `dir' file to add or update the menu
  252.      entry for the given Info file; it is part of the Texinfo package.
  253.      Here is a sample rule to install an Info file:
  254.           $(infodir)/foo.info: foo.info
  255.           # There may be a newer info file in . than in srcdir.
  256.                   -if test -f foo.info; then d=.; \
  257.                    else d=$(srcdir); fi; \
  258.                   $(INSTALL_DATA) $$d/foo.info $@; \
  259.           # Run install-info only if it exists.
  260.           # Use `if' instead of just prepending `-' to the
  261.           # line so we notice real errors from install-info.
  262.           # We use `$(SHELL) -c' because some shells do not
  263.           # fail gracefully when there is an unknown command.
  264.                   if $(SHELL) -c 'install-info --version' \
  265.                      >/dev/null 2>&1; then \
  266.                     install-info --dir-file=$(infodir)/dir \
  267.                                  $(infodir)/foo.info; \
  268.                   else true; fi
  269. `uninstall'
  270.      Delete all the installed files that the `install' target would
  271.      create (but not the noninstalled files such as `make all' would
  272.      create).
  273.      This rule should not modify the directories where compilation is
  274.      done, only the directories where files are installed.
  275. `install-strip'
  276.      Like `install', but strip the executable files while installing
  277.      them.  The definition of this target can be very simple:
  278.           install-strip:
  279.                   $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
  280.                           install
  281.      Normally we do not recommend stripping an executable unless you
  282.      are sure the program has no bugs.  However, it can be reasonable
  283.      to install a stripped executable for actual execution while saving
  284.      the unstripped executable elsewhere in case there is a bug.
  285. `clean'
  286.      Delete all files from the current directory that are normally
  287.      created by building the program.  Don't delete the files that
  288.      record the configuration.  Also preserve files that could be made
  289.      by building, but normally aren't because the distribution comes
  290.      with them.
  291.      Delete `.dvi' files here if they are not part of the distribution.
  292. `distclean'
  293.      Delete all files from the current directory that are created by
  294.      configuring or building the program.  If you have unpacked the
  295.      source and built the program without creating any other files,
  296.      `make distclean' should leave only the files that were in the
  297.      distribution.
  298. `mostlyclean'
  299.      Like `clean', but may refrain from deleting a few files that people
  300.      normally don't want to recompile.  For example, the `mostlyclean'
  301.      target for GCC does not delete `libgcc.a', because recompiling it
  302.      is rarely necessary and takes a lot of time.
  303. `maintainer-clean'
  304.      Delete almost everything from the current directory that can be
  305.      reconstructed with this Makefile.  This typically includes
  306.      everything deleted by `distclean', plus more: C source files
  307.      produced by Bison, tags tables, Info files, and so on.
  308.      The reason we say "almost everything" is that running the command
  309.      `make maintainer-clean' should not delete `configure' even if
  310.      `configure' can be remade using a rule in the Makefile.  More
  311.      generally, `make maintainer-clean' should not delete anything that
  312.      needs to exist in order to run `configure' and then begin to build
  313.      the program.  This is the only exception; `maintainer-clean' should
  314.      delete everything else that can be rebuilt.
  315.      The `maintainer-clean' target is intended to be used by a
  316.      maintainer of the package, not by ordinary users.  You may need
  317.      special tools to reconstruct some of the files that `make
  318.      maintainer-clean' deletes.  Since these files are normally
  319.      included in the distribution, we don't take care to make them easy
  320.      to reconstruct.  If you find you need to unpack the full
  321.      distribution again, don't blame us.
  322.      To help make users aware of this, the commands for the special
  323.      `maintainer-clean' target should start with these two:
  324.           @echo 'This command is intended for maintainers to use; it'
  325.           @echo 'deletes files that may need special tools to rebuild.'
  326. `TAGS'
  327.      Update a tags table for this program.
  328. `info'
  329.      Generate any Info files needed.  The best way to write the rules
  330.      is as follows:
  331.           info: foo.info
  332.           
  333.           foo.info: foo.texi chap1.texi chap2.texi
  334.                   $(MAKEINFO) $(srcdir)/foo.texi
  335.      You must define the variable `MAKEINFO' in the Makefile.  It should
  336.      run the `makeinfo' program, which is part of the Texinfo
  337.      distribution.
  338. `dvi'
  339.      Generate DVI files for all Texinfo documentation.  For example:
  340.           dvi: foo.dvi
  341.           
  342.           foo.dvi: foo.texi chap1.texi chap2.texi
  343.                   $(TEXI2DVI) $(srcdir)/foo.texi
  344.      You must define the variable `TEXI2DVI' in the Makefile.  It should
  345.      run the program `texi2dvi', which is part of the Texinfo
  346.      distribution.(1)  Alternatively, write just the dependencies, and
  347.      allow GNU `make' to provide the command.
  348. `dist'
  349.      Create a distribution tar file for this program.  The tar file
  350.      should be set up so that the file names in the tar file start with
  351.      a subdirectory name which is the name of the package it is a
  352.      distribution for.  This name can include the version number.
  353.      For example, the distribution tar file of GCC version 1.40 unpacks
  354.      into a subdirectory named `gcc-1.40'.
  355.      The easiest way to do this is to create a subdirectory
  356.      appropriately named, use `ln' or `cp' to install the proper files
  357.      in it, and then `tar' that subdirectory.
  358.      Compress the tar file file with `gzip'.  For example, the actual
  359.      distribution file for GCC version 1.40 is called `gcc-1.40.tar.gz'.
  360.      The `dist' target should explicitly depend on all non-source files
  361.      that are in the distribution, to make sure they are up to date in
  362.      the distribution.  *Note Making Releases: (standards)Releases.
  363. `check'
  364.      Perform self-tests (if any).  The user must build the program
  365.      before running the tests, but need not install the program; you
  366.      should write the self-tests so that they work when the program is
  367.      built but not installed.
  368.    The following targets are suggested as conventional names, for
  369. programs in which they are useful.
  370. `installcheck'
  371.      Perform installation tests (if any).  The user must build and
  372.      install the program before running the tests.  You should not
  373.      assume that `$(bindir)' is in the search path.
  374. `installdirs'
  375.      It's useful to add a target named `installdirs' to create the
  376.      directories where files are installed, and their parent
  377.      directories.  There is a script called `mkinstalldirs' which is
  378.      convenient for this; you can find it in the Texinfo package.  You
  379.      can use a rule like this:
  380.           # Make sure all installation directories (e.g. $(bindir))
  381.           # actually exist by making them if necessary.
  382.           installdirs: mkinstalldirs
  383.                   $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
  384.                                           $(libdir) $(infodir) \
  385.                                           $(mandir)
  386.      This rule should not modify the directories where compilation is
  387.      done.  It should do nothing but create installation directories.
  388.    ---------- Footnotes ----------
  389.    (1)  `texi2dvi' uses TeX to do the real work of formatting. TeX is
  390. not distributed with Texinfo.
  391. File: make.info,  Node: Quick Reference,  Next: Complex Makefile,  Prev: Makefile Conventions,  Up: Top
  392. Quick Reference
  393. ***************
  394.    This appendix summarizes the directives, text manipulation functions,
  395. and special variables which GNU `make' understands.  *Note Special
  396. Targets::, *Note Catalogue of Implicit Rules: Catalogue of Rules, and
  397. *Note Summary of Options: Options Summary, for other summaries.
  398.    Here is a summary of the directives GNU `make' recognizes:
  399. `define VARIABLE'
  400. `endef'
  401.      Define a multi-line, recursively-expanded variable.
  402.      *Note Sequences::.
  403. `ifdef VARIABLE'
  404. `ifndef VARIABLE'
  405. `ifeq (A,B)'
  406. `ifeq "A" "B"'
  407. `ifeq 'A' 'B''
  408. `ifneq (A,B)'
  409. `ifneq "A" "B"'
  410. `ifneq 'A' 'B''
  411. `else'
  412. `endif'
  413.      Conditionally evaluate part of the makefile.
  414.      *Note Conditionals::.
  415. `include FILE'
  416.      Include another makefile.
  417.      *Note Including Other Makefiles: Include.
  418. `override VARIABLE = VALUE'
  419. `override VARIABLE := VALUE'
  420. `override VARIABLE += VALUE'
  421. `override define VARIABLE'
  422. `endef'
  423.      Define a variable, overriding any previous definition, even one
  424.      from the command line.
  425.      *Note The `override' Directive: Override Directive.
  426. `export'
  427.      Tell `make' to export all variables to child processes by default.
  428.      *Note Communicating Variables to a Sub-`make': Variables/Recursion.
  429. `export VARIABLE'
  430. `export VARIABLE = VALUE'
  431. `export VARIABLE := VALUE'
  432. `export VARIABLE += VALUE'
  433. `unexport VARIABLE'
  434.      Tell `make' whether or not to export a particular variable to child
  435.      processes.
  436.      *Note Communicating Variables to a Sub-`make': Variables/Recursion.
  437. `vpath PATTERN PATH'
  438.      Specify a search path for files matching a `%' pattern.
  439.      *Note The `vpath' Directive: Selective Search.
  440. `vpath PATTERN'
  441.      Remove all search paths previously specified for PATTERN.
  442. `vpath'
  443.      Remove all search paths previously specified in any `vpath'
  444.      directive.
  445.    Here is a summary of the text manipulation functions (*note
  446. Functions::.):
  447. `$(subst FROM,TO,TEXT)'
  448.      Replace FROM with TO in TEXT.
  449.      *Note Functions for String Substitution and Analysis: Text
  450.      Functions.
  451. `$(patsubst PATTERN,REPLACEMENT,TEXT)'
  452.      Replace words matching PATTERN with REPLACEMENT in TEXT.
  453.      *Note Functions for String Substitution and Analysis: Text
  454.      Functions.
  455. `$(strip STRING)'
  456.      Remove excess whitespace characters from STRING.
  457.      *Note Functions for String Substitution and Analysis: Text
  458.      Functions.
  459. `$(findstring FIND,TEXT)'
  460.      Locate FIND in TEXT.
  461.      *Note Functions for String Substitution and Analysis: Text
  462.      Functions.
  463. `$(filter PATTERN...,TEXT)'
  464.      Select words in TEXT that match one of the PATTERN words.
  465.      *Note Functions for String Substitution and Analysis: Text
  466.      Functions.
  467. `$(filter-out PATTERN...,TEXT)'
  468.      Select words in TEXT that *do not* match any of the PATTERN words.
  469.      *Note Functions for String Substitution and Analysis: Text
  470.      Functions.
  471. `$(sort LIST)'
  472.      Sort the words in LIST lexicographically, removing duplicates.
  473.      *Note Functions for String Substitution and Analysis: Text
  474.      Functions.
  475. `$(dir NAMES...)'
  476.      Extract the directory part of each file name.
  477.      *Note Functions for File Names: Filename Functions.
  478. `$(notdir NAMES...)'
  479.      Extract the non-directory part of each file name.
  480.      *Note Functions for File Names: Filename Functions.
  481. `$(suffix NAMES...)'
  482.      Extract the suffix (the last `.' and following characters) of each
  483.      file name.
  484.      *Note Functions for File Names: Filename Functions.
  485. `$(basename NAMES...)'
  486.      Extract the base name (name without suffix) of each file name.
  487.      *Note Functions for File Names: Filename Functions.
  488. `$(addsuffix SUFFIX,NAMES...)'
  489.      Append SUFFIX to each word in NAMES.
  490.      *Note Functions for File Names: Filename Functions.
  491. `$(addprefix PREFIX,NAMES...)'
  492.      Prepend PREFIX to each word in NAMES.
  493.      *Note Functions for File Names: Filename Functions.
  494. `$(join LIST1,LIST2)'
  495.      Join two parallel lists of words.
  496.      *Note Functions for File Names: Filename Functions.
  497. `$(word N,TEXT)'
  498.      Extract the Nth word (one-origin) of TEXT.
  499.      *Note Functions for File Names: Filename Functions.
  500. `$(words TEXT)'
  501.      Count the number of words in TEXT.
  502.      *Note Functions for File Names: Filename Functions.
  503. `$(firstword NAMES...)'
  504.      Extract the first word of NAMES.
  505.      *Note Functions for File Names: Filename Functions.
  506. `$(wildcard PATTERN...)'
  507.      Find file names matching a shell file name pattern (*not* a `%'
  508.      pattern).
  509.      *Note The Function `wildcard': Wildcard Function.
  510. `$(shell COMMAND)'
  511.      Execute a shell command and return its output.
  512.      *Note The `shell' Function: Shell Function.
  513. `$(origin VARIABLE)'
  514.      Return a string describing how the `make' variable VARIABLE was
  515.      defined.
  516.      *Note The `origin' Function: Origin Function.
  517. `$(foreach VAR,WORDS,TEXT)'
  518.      Evaluate TEXT with VAR bound to each word in WORDS, and
  519.      concatenate the results.
  520.      *Note The `foreach' Function: Foreach Function.
  521.    Here is a summary of the automatic variables.  *Note Automatic
  522. Variables: Automatic, for full information.
  523.      The file name of the target.
  524.      The target member name, when the target is an archive member.
  525.      The name of the first dependency.
  526.      The names of all the dependencies that are newer than the target,
  527.      with spaces between them.  For dependencies which are archive
  528.      members, only the member named is used (*note Archives::.).
  529.      The names of all the dependencies, with spaces between them.  For
  530.      dependencies which are archive members, only the member named is
  531.      used (*note Archives::.).  The value of `$^' omits duplicate
  532.      dependencies, while `$+' retains them and preserves their order.
  533.      The stem with which an implicit rule matches (*note How Patterns
  534.      Match: Pattern Match.).
  535. `$(@D)'
  536. `$(@F)'
  537.      The directory part and the file-within-directory part of `$@'.
  538. `$(*D)'
  539. `$(*F)'
  540.      The directory part and the file-within-directory part of `$*'.
  541. `$(%D)'
  542. `$(%F)'
  543.      The directory part and the file-within-directory part of `$%'.
  544. `$(<D)'
  545. `$(<F)'
  546.      The directory part and the file-within-directory part of `$<'.
  547. `$(^D)'
  548. `$(^F)'
  549.      The directory part and the file-within-directory part of `$^'.
  550. `$(+D)'
  551. `$(+F)'
  552.      The directory part and the file-within-directory part of `$+'.
  553. `$(?D)'
  554. `$(?F)'
  555.      The directory part and the file-within-directory part of `$?'.
  556.    These variables are used specially by GNU `make':
  557. `MAKEFILES'
  558.      Makefiles to be read on every invocation of `make'.
  559.      *Note The Variable `MAKEFILES': MAKEFILES Variable.
  560. `VPATH'
  561.      Directory search path for files not found in the current directory.
  562.      *Note `VPATH' Search Path for All Dependencies: General Search.
  563. `SHELL'
  564.      The name of the system default command interpreter, usually
  565.      `/bin/sh'.  You can set `SHELL' in the makefile to change the
  566.      shell used to run commands.  *Note Command Execution: Execution.
  567. `MAKE'
  568.      The name with which `make' was invoked.  Using this variable in
  569.      commands has special meaning.  *Note How the `MAKE' Variable
  570.      Works: MAKE Variable.
  571. `MAKELEVEL'
  572.      The number of levels of recursion (sub-`make's).
  573.      *Note Variables/Recursion::.
  574. `MAKEFLAGS'
  575.      The flags given to `make'.  You can set this in the environment or
  576.      a makefile to set flags.
  577.      *Note Communicating Options to a Sub-`make': Options/Recursion.
  578. `SUFFIXES'
  579.      The default list of suffixes before `make' reads any makefiles.
  580. File: make.info,  Node: Complex Makefile,  Next: Concept Index,  Prev: Quick Reference,  Up: Top
  581. Complex Makefile Example
  582. ************************
  583.    Here is the makefile for the GNU `tar' program.  This is a
  584. moderately complex makefile.
  585.    Because it is the first target, the default goal is `all'.  An
  586. interesting feature of this makefile is that `testpad.h' is a source
  587. file automatically created by the `testpad' program, itself compiled
  588. from `testpad.c'.
  589.    If you type `make' or `make all', then `make' creates the `tar'
  590. executable, the `rmt' daemon that provides remote tape access, and the
  591. `tar.info' Info file.
  592.    If you type `make install', then `make' not only creates `tar',
  593. `rmt', and `tar.info', but also installs them.
  594.    If you type `make clean', then `make' removes the `.o' files, and
  595. the `tar', `rmt', `testpad', `testpad.h', and `core' files.
  596.    If you type `make distclean', then `make' not only removes the same
  597. files as does `make clean' but also the `TAGS', `Makefile', and
  598. `config.status' files.  (Although it is not evident, this makefile (and
  599. `config.status') is generated by the user with the `configure' program,
  600. which is provided in the `tar' distribution, but is not shown here.)
  601.    If you type `make realclean', then `make' removes the same files as
  602. does `make distclean' and also removes the Info files generated from
  603. `tar.texinfo'.
  604.    In addition, there are targets `shar' and `dist' that create
  605. distribution kits.
  606.      # Generated automatically from Makefile.in by configure.
  607.      # Un*x Makefile for GNU tar program.
  608.      # Copyright (C) 1991 Free Software Foundation, Inc.
  609.      
  610.      # This program is free software; you can redistribute
  611.      # it and/or modify it under the terms of the GNU
  612.      # General Public License ...
  613.      ...
  614.      ...
  615.      
  616.      SHELL = /bin/sh
  617.      
  618.      #### Start of system configuration section. ####
  619.      
  620.      srcdir = .
  621.      
  622.      # If you use gcc, you should either run the
  623.      # fixincludes script that comes with it or else use
  624.      # gcc with the -traditional option.  Otherwise ioctl
  625.      # calls will be compiled incorrectly on some systems.
  626.      CC = gcc -O
  627.      YACC = bison -y
  628.      INSTALL = /usr/local/bin/install -c
  629.      INSTALLDATA = /usr/local/bin/install -c -m 644
  630.      
  631.      # Things you might add to DEFS:
  632.      # -DSTDC_HEADERS        If you have ANSI C headers and
  633.      #                       libraries.
  634.      # -DPOSIX               If you have POSIX.1 headers and
  635.      #                       libraries.
  636.      # -DBSD42               If you have sys/dir.h (unless
  637.      #                       you use -DPOSIX), sys/file.h,
  638.      #                       and st_blocks in `struct stat'.
  639.      # -DUSG                 If you have System V/ANSI C
  640.      #                       string and memory functions
  641.      #                       and headers, sys/sysmacros.h,
  642.      #                       fcntl.h, getcwd, no valloc,
  643.      #                       and ndir.h (unless
  644.      #                       you use -DDIRENT).
  645.      # -DNO_MEMORY_H         If USG or STDC_HEADERS but do not
  646.      #                       include memory.h.
  647.      # -DDIRENT              If USG and you have dirent.h
  648.      #                       instead of ndir.h.
  649.      # -DSIGTYPE=int         If your signal handlers
  650.      #                       return int, not void.
  651.      # -DNO_MTIO             If you lack sys/mtio.h
  652.      #                       (magtape ioctls).
  653.      # -DNO_REMOTE           If you do not have a remote shell
  654.      #                       or rexec.
  655.      # -DUSE_REXEC           To use rexec for remote tape
  656.      #                       operations instead of
  657.      #                       forking rsh or remsh.
  658.      # -DVPRINTF_MISSING     If you lack vprintf function
  659.      #                       (but have _doprnt).
  660.      # -DDOPRNT_MISSING      If you lack _doprnt function.
  661.      #                       Also need to define
  662.      #                       -DVPRINTF_MISSING.
  663.      # -DFTIME_MISSING       If you lack ftime system call.
  664.      # -DSTRSTR_MISSING      If you lack strstr function.
  665.      # -DVALLOC_MISSING      If you lack valloc function.
  666.      # -DMKDIR_MISSING       If you lack mkdir and
  667.      #                       rmdir system calls.
  668.      # -DRENAME_MISSING      If you lack rename system call.
  669.      # -DFTRUNCATE_MISSING   If you lack ftruncate
  670.      #                       system call.
  671.      # -DV7                  On Version 7 Unix (not
  672.      #                       tested in a long time).
  673.      # -DEMUL_OPEN3          If you lack a 3-argument version
  674.      #                       of open, and want to emulate it
  675.      #                       with system calls you do have.
  676.      # -DNO_OPEN3            If you lack the 3-argument open
  677.      #                       and want to disable the tar -k
  678.      #                       option instead of emulating open.
  679.      # -DXENIX               If you have sys/inode.h
  680.      #                       and need it 94 to be included.
  681.      
  682.      DEFS =  -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \
  683.              -DVPRINTF_MISSING -DBSD42
  684.      # Set this to rtapelib.o unless you defined NO_REMOTE,
  685.      # in which case make it empty.
  686.      RTAPELIB = rtapelib.o
  687.      LIBS =
  688.      DEF_AR_FILE = /dev/rmt8
  689.      DEFBLOCKING = 20
  690.      
  691.      CDEBUG = -g
  692.      CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
  693.              -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
  694.              -DDEFBLOCKING=$(DEFBLOCKING)
  695.      LDFLAGS = -g
  696.      
  697.      prefix = /usr/local
  698.      # Prefix for each installed program,
  699.      # normally empty or `g'.
  700.      binprefix =
  701.      
  702.      # The directory to install tar in.
  703.      bindir = $(prefix)/bin
  704.      
  705.      # The directory to install the info files in.
  706.      infodir = $(prefix)/info
  707.      
  708.      #### End of system configuration section. ####
  709.      
  710.      SRC1 =  tar.c create.c extract.c buffer.c \
  711.              getoldopt.c update.c gnu.c mangle.c
  712.      SRC2 =  version.c list.c names.c diffarch.c \
  713.              port.c wildmat.c getopt.c
  714.      SRC3 =  getopt1.c regex.c getdate.y
  715.      SRCS =  $(SRC1) $(SRC2) $(SRC3)
  716.      OBJ1 =  tar.o create.o extract.o buffer.o \
  717.              getoldopt.o update.o gnu.o mangle.o
  718.      OBJ2 =  version.o list.o names.o diffarch.o \
  719.              port.o wildmat.o getopt.o
  720.      OBJ3 =  getopt1.o regex.o getdate.o $(RTAPELIB)
  721.      OBJS =  $(OBJ1) $(OBJ2) $(OBJ3)
  722.      AUX =   README COPYING ChangeLog Makefile.in  \
  723.              makefile.pc configure configure.in \
  724.              tar.texinfo tar.info* texinfo.tex \
  725.              tar.h port.h open3.h getopt.h regex.h \
  726.              rmt.h rmt.c rtapelib.c alloca.c \
  727.              msd_dir.h msd_dir.c tcexparg.c \
  728.              level-0 level-1 backup-specs testpad.c
  729.      
  730.      all:    tar rmt tar.info
  731.      
  732.      tar:    $(OBJS)
  733.              $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  734.      
  735.      rmt:    rmt.c
  736.              $(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c
  737.      
  738.      tar.info: tar.texinfo
  739.              makeinfo tar.texinfo
  740.      
  741.      install: all
  742.              $(INSTALL) tar $(bindir)/$(binprefix)tar
  743.              -test ! -f rmt || $(INSTALL) rmt /etc/rmt
  744.              $(INSTALLDATA) $(srcdir)/tar.info* $(infodir)
  745.      
  746.      $(OBJS): tar.h port.h testpad.h
  747.      regex.o buffer.o tar.o: regex.h
  748.      # getdate.y has 8 shift/reduce conflicts.
  749.      
  750.      testpad.h: testpad
  751.              ./testpad
  752.      
  753.      testpad: testpad.o
  754.              $(CC) -o $@ testpad.o
  755.      
  756.      TAGS:   $(SRCS)
  757.              etags $(SRCS)
  758.      
  759.      clean:
  760.              rm -f *.o tar rmt testpad testpad.h core
  761.      
  762.      distclean: clean
  763.              rm -f TAGS Makefile config.status
  764.      
  765.      realclean: distclean
  766.              rm -f tar.info*
  767.      
  768.      shar: $(SRCS) $(AUX)
  769.              shar $(SRCS) $(AUX) | compress \
  770.                > tar-`sed -e '/version_string/!d' \
  771.                           -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
  772.                           -e q
  773.                           version.c`.shar.Z
  774.      
  775.      dist: $(SRCS) $(AUX)
  776.              echo tar-`sed \
  777.                   -e '/version_string/!d' \
  778.                   -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
  779.                   -e q
  780.                   version.c` > .fname
  781.              -rm -rf `cat .fname`
  782.              mkdir `cat .fname`
  783.              ln $(SRCS) $(AUX) `cat .fname`
  784.              -rm -rf `cat .fname` .fname
  785.              tar chZf `cat .fname`.tar.Z `cat .fname`
  786.      
  787.      tar.zoo: $(SRCS) $(AUX)
  788.              -rm -rf tmp.dir
  789.              -mkdir tmp.dir
  790.              -rm tar.zoo
  791.              for X in $(SRCS) $(AUX) ; do \
  792.                  echo $$X ; \
  793.                  sed 's/$$/^M/' $$X \
  794.                  > tmp.dir/$$X ; done
  795.              cd tmp.dir ; zoo aM ../tar.zoo *
  796.              -rm -rf tmp.dir
  797.