Make

From Christoph's Personal Wiki
Revision as of 01:25, 19 October 2006 by Christoph (Talk | contribs)

Jump to: navigation, search
The correct title of this article is make. The initial letter is capitalized due to technical restrictions.

In computing, make is a utility that automates the process of generating ("making") a file (or files). The make is most commonly used to generate an application. For each application, a programmer writes a file named "makefile" or (later) "Makefile", which tells make all the files and other tools involved in generating the final output file (or files).

PATH

You can store all of your personal makefiles in a single directory (e.g. /home/bob/makefiles) and set the environment variable MAKFILES to call these. Note that the make file itself, with the absolute path must be set in the environment, not just the path.

For an example, in bash you would add the following to your ~/.bashrc file:

export MAKEFILES=/home/bob/makefiles/makefile 

where makefile is your "master" makefile.

You can then call sub-makefiles (or dependencies) by adding their absolute path and filename to your master makefile:

include /home/bob/makefiles/Makeconfig
include /home/bob/makefiles/foo.mk

Example makefile

Note: A random mix of stuff for examples.

SHELL   = /bin/sh

AWK     = awk
SED     = sed
RM      = rm

# Clear out pre-defined suffixes
.SUFFIXES:
.SUFFIXES:      .seg .pdb .dat .log

%.seg:  %.log
        $(SED) -n '/^[0-9]/{n;p;}' $< | \
        $(SED) -e 's/  [0-9].*\.\(.*\)//' >$@

SEG     = 01 02 03 04 05

%.seg.s:        %.seg
        for n in $(SEG);\
        do \
        head -$$n $< | \
        tail -1 | \
        $(SED) 's/[)|;]/\n/g' - | \
        head -$$n | \
        $(SED) 's/[(('$(CH)':)| ]//g' - | \
        $(SED) 's/-/\t/g' - | \
        sort -nk1 - | \
        $(SED) = - | $(SED) 'N;s/\n/\t/' >$@$$n ;\
        done

show:
        @echo "***************************************"
        @echo SED       = $(SED)

LIST = one two three
blah:
        @for i in $(LIST); do \
                echo $$i; \
        done

clean:
        $(RM) *.seg.s*

Useful utilities

Core

cat cmp cp diff echo egrep expr false grep install-info
ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true

Extended

[ basename bash cat chgrp chmod chown cmp cp dd diff echo
egrep expand expr false fgrep find getopt grep gunzip gzip
hostname install install-info kill ldconfig ln ls md5sum
mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
test touch true uname xargs yes

External links