GNU make

Automatic variables

Important variables set by make after a rule is matched:

$@ The filename representing the target
$< The filename of the first prerequisite
$? The names of all prerequisites that are newer than the target, separated by spaces
$^ The filenames of all the prerequisites, separated by spaces

Example Makefiles

Keep two cluster nodes in sync

# Sorgt für die Verteilung der folgenden Konfigurationsdateien
# auf vom MASTER auf den SLAVE, um DRBD und Heartbeat konsistent zu halten:
# /etc/xen/xd0/*
# /etc/xen/xd0-auto/*


# beim Slave werden die Konfigs drübergebügelt

# global
all: $(XEN)/$(XDn).pushed \
        $(XEN)/$(XDn)-auto.pushed \

        rm -f $(XEN)/$(XDn).pushed
        rm -f $(XEN)/$(XDn)-auto.pushed

# xen
$(XEN)/$(XDn).pushed: ;
        rsync -vrlt -e ssh --delete $(XEN)/$(XDn)/ $(SLAVE):$(XEN)/$(XDn)/
        @touch $@

$(XEN)/$(XDn)-auto.pushed: ;
        rsync -vrlt -e ssh --delete $(XEN)/$(XDn)-auto/ $(SLAVE):$(XEN)/$(XDn)-auto/
        @touch $@

Reload Nagios nrpe server on changes:

.PHONY: all
all:    nrpe_local.cfg.done nrpe.cfg.done

.PHONY: clean
        rm *.done

nrpe_local.cfg.done:    nrpe_local.cfg
        /etc/init.d/nagios-nrpe-server reload
        touch $@

nrpe.cfg.done:          nrpe.cfg
        /etc/init.d/nagios-nrpe-server reload
        touch $@
linux/make.txt · Last modified: 2008-12 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready