What makes make make?

A description file, some options, some general templates, some targets to be made, and some macro defnitions.

Make is a command generator, file maintainer, a project backbone able to tie together the execution or build environment.

The natural use of make is to sort out dependency relations among files; also make is commonly used to determine any pieces needed to be produced/updated, and issue any necessary commands.

The description file is also referred to as the makefile.  Its purpose is to describe some of the relationships amongst the files
and state any commands needed to update the files or bind the files together into an entity [a library or an application or ...].

 

make [-f descrfile] [options] [targets] [macro definitions]

 Some standard options :

-b Accept description files from previous implementations of make
-c dir Change to directory dir before reading the makefile(s) or doing anything else.
-d Debug mode -print detailed info about internal flags & the last-modified times of files
-e Let environment variables override macro defnitions inside descrip files.
-f Following argument is name of the description file (if the argument is a hyphen then standard in is used)
-i Ignore error codes
-I dir Specify a directory dir to search for included makefiles.
-k Error terminates work on current branch of the build heirarchy, but not on other build branches.
-n Echo command lines, not executing them
-o file Do not remake the file file even if it is older than its dependencies; also do not remake anything on account of changes in file.
-p Print out macro definitions, suffixes, suffix rules & explicit description file entries.
-q Return 0 or non-0 exit status based on whether the target is up to date or not.
-r Do not use the default rules
-s Do not echo commands as they are executed.
-t Touch target files, without executing any other commands.

Operation Summary

Description File Lines

 

    Suffix Rule :

        .suffix[.suffix] :[:]

 

    Dependency line :

      targets :[:] [ prerequisites ] [; [command] ]

 

    Command :

    tab [- @] command

 

    Macro definition :

     name = string

 

    Include statement :

      include file

 

   Macros :

 

$? List of prerequisites that have been changed more recently than the current target.  Can be used only in normal description file entries; can NOT be used in suffix rules.
$@ The name of the current target, except in description file entries for making libraries, where it becomes the library name.  Can be used in both normal description file entries and suffix rules.
$$@ The name of the current target.  Can only be used to the right of the colon in dependency lines.
$* The name -- minus the suffix -- of the current prerequisite that has been modified more recently than the curr target.  Can be used only in suffix rules.
$< The name of the current prerequisite that has been modified more recently than the current target. Can only be used in suffix rules and the .DEFAULT entry
$% The name of the corresponding .o file when the current target is a library module.  Can be used in both normal description file entries

Macro Modifiers

D The directory portion of any internal macro except $?
Valid uses : ${*D}, $${@D}, ${@D}, ${<D}
F The file portion of any internal macro except $?
Valid uses: ${*F}, $${@F}, ${@F}, ${<D}

Special Macros

VPATH Specifies a list of directories that make searches to find prerequisites if they are not in the curr dir
SHELL Determines which shell is used to interpret commands.  If this macro is not defined in the description file, some implementations take the shell from the user's env variable.  Some versions set SHELL to /bin/sh by default.

 

Macro String Substitution 

${macro:s0=s1}

    Evaluates to the current definition of ${macro}, after substituting the string s1 for every occurrence of s0 that occurs either immediately before a blank or tab, or at the end of the macro definition.

 

Special Targets 

.DEFAULT Commands associated with this target are executed if make cannot find any description file entries or suffix rules to build a requested target
.IGNORE Ignore error codes
.PRECIOUS Files you specify for this target are NOT removed when you send a signal that aborts make, or when a command line in the description file returns an error.
.SILENT Execute commands but do not echo them
.SUFFIXES The prerequisites associated with this target are suffixes that become significant for make and can be associated with suffix rules.  If present but without any suffixes listed, this target then nullifies the existing suffix list.  Suffixes listed must be separated by spaces and/or tabs

 

 

nmake

 

makedepend

Sample Makefiles

(1)
program :  iodat.o main.o quo.o /usr/xkey/lib/crtn.a
    cc -o program iodat.o main.o quo.o /usr/xkey/lib/crtn.a

(2)
rplot :  prot.o; cc -o rplot prot.o

 

 

 

Last revision : 04-24-2000 by