Packaging GNU Makefile for desklets - adesklets 0.6.1
Description: adesklets 0.6.1

Next: Submitting a desklet, Previous: Imlib2 documentation, Up: Top

## Appendix E Packaging GNU Makefile for desklets

Here is a convenient Makefile that automates the packaging of new or existing desklets on a GNU system. Just copy the Makefile below into `GNUmakefile` from your base desklet directory to use it. There is nothing at all to edit, provided you named your base directory in a proper 'NAME-MAJOR.MINOR.REVISION' fashion, such as `beast-0.666.0`.

    #--------------------------------------------------------------
    # Written by S.Fourmanoit <syfou@users.sourceforge.net>,
    #       2004, 2005.
    #
    # This is a minimal makefile to facilitate packaging operation
    # of adesklets's desklets, following a syntax similar
    # to automake's
    #
    # Some possible invocations would be:
    #
    # make [dist-bzip2]       - create an updated bzip'ed tarball
    # make dist-bzip2-sign    - also create an open PGP signature
    # make clean              - just clean up current directory
    # make promote            - auto update current package directory
    #                           to next version one on the system:
    #                           adapts $(HOME)/.adesklets accordingly
    #
    # You can also set the VER environment variable to
    # any string if you wish to bypass package naming
    # auto-incrementation scheme. For instance:
    #
    # make VER=0.666.0
    #
    # will force creation of $(PACKAGE)-0.666.0.tar.bz2
    #
    # Portability warning:
    #
    # This was not meant to be portable, but to work on a GNU
    # system (GNU sed, GNU make, bc, portable bourne shell,
    # GNU findutils, GNU coreutils). It also need base directory
    # to be named in a standard 'NAME-MAJOR.MINOR.REVISION'
    # fashion.
    #
    #--------------------------------------------------------------
    GPG-LOCAL-USER=syfou       # User for GnuPG signing the package

    #--------------------------------------------------------------
    # Do not edit anything below this point, unless you know
    # what you are doing.
    #
    #--------------------------------------------------------------
    NAME=$(shell basename `pwd` | sed 's/^\(.*\)-.*/\1/')
    REV=$(shell basename `pwd` | \
            sed 's/.*-\(.*\)$$/\1/;s/.*\.\([0-9]\+\)$$/\1 + 1/' | \
            bc)
    MAJ-MIN=$(shell basename `pwd` | \
            sed 's/.*-\(.*\)$$/\1/;s/^\(.*\.\)[0-9]\+/\1/')
    VERSION=$(if $(VER),$(VER),$(MAJ-MIN)$(REV))
    P=$(NAME)-$(VERSION)
    PWD_ESC=$(shell pwd | sed 's/\//\\\//g')
    PPWD_ESC=$(shell cd .. && pwd | sed 's/\//\\\//g')
    PWD=$(shell pwd)

    #--------------------------------------------------------------
    %.asc: %
            gpg --local-user $(GPG-LOCAL-USER) \
                    --armor --detach-sign $<

    $(P).tar.bz2: $(wildcard *.py) README clean
            -mkdir /tmp/$(P)
            cp -r . /tmp/$(P)
            tar --exclude='config.txt' -C /tmp -cvjf $@ $(P)
            -rm -rf /tmp/$(P)

    #--------------------------------------------------------------
    .INTERMEDIATE: clean
    .PHONY: clean promote dist-bzip2 dist-bzip2-sign
    promote: clean
            -killall -9 adesklets python && sleep .2
            cd $(PWD)/.. && \
                    rm -rf $(P) && \
                    cp -rav `basename $(PWD)` $(P) && \
            sed -i 's/^\[$(PWD_ESC)\(.*\)/\[$(PPWD_ESC)\/$(P)\1/'\
                    $(HOME)/.adesklets
            -adesklets
    clean:
            -rm `find . -name '*~' -or -name '*.pyc' \
                    -or -name '*.bz2' -or -name '*.asc'`
            -rm -rf `find . -mindepth 1 -maxdepth 1 \
                    -type d -name '$(PACKAGE)-*'`
    dist-bzip2: $(P).tar.bz2
    dist-bzip2-sign: $(P).tar.bz2.asc

    #--------------------------------------------------------------