Migrate tla related stuff to git
[zcdrip] / build.sh
1 #!/bin/zsh
2
3 ## Copyright (C) 2006 - 2011 Steve Youngs
4
5 ## Author:        Steve Youngs <steve@steveyoungs.com>
6 ## Maintainer:    Steve Youngs <steve@steveyoungs.com>
7 ## Created:       <2006-08-16>
8
9 ## This file is part of zcdrip
10
11 ## Redistribution and use in source and binary forms, with or without
12 ## modification, are permitted provided that the following conditions
13 ## are met:
14 ##
15 ## 1. Redistributions of source code must retain the above copyright
16 ##    notice, this list of conditions and the following disclaimer.
17 ##
18 ## 2. Redistributions in binary form must reproduce the above copyright
19 ##    notice, this list of conditions and the following disclaimer in the
20 ##    documentation and/or other materials provided with the distribution.
21 ##
22 ## 3. Neither the name of the author nor the names of any contributors
23 ##    may be used to endorse or promote products derived from this
24 ##    software without specific prior written permission.
25 ##
26 ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
27 ## IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 ## WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 ## DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 ## SUBSTITUTE GOODS OR SERVICES# LOSS OF USE, DATA, OR PROFITS# OR
33 ## BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
35 ## OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
36 ## IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
38 ### Commentary:
39 ## 
40 ##    Because I suck at writing makefiles
41
42 ### Code:
43 clean ()
44 {
45     rm -vf zcdrip ecdrip zdiscid
46 }
47
48 all ()
49 {
50     clean
51     sub=@VERSION@
52     tver=v0.7
53     rep=$(git describe 2>/dev/null||echo ${tver})
54     zmodload -i zsh/mapfile
55     gcc -Wall -o zdiscid zdiscid.c
56     mapfile[zcdrip]=${mapfile[zcdrip.in]/$sub/$rep}
57     chmod -v 755 zcdrip
58 }
59
60 eshell ()
61 {
62     [[ -f zcdrip && -f zdiscid ]] || all
63     ln -svf zcdrip ecdrip
64 }
65
66 target=${target:-/usr/local/bin}
67 INSTALL=${INSTALL:-install}
68
69 _install ()
70 {
71     [[ -f zcdrip && -f zdiscid ]] || all
72
73     $INSTALL -vd $target
74     $INSTALL -v zcdrip zdiscid $target
75     [[ -f ecdrip ]] && $INSTALL -v ecdrip $target
76 }
77
78 ourname=${0##/}
79 help ()
80 {
81     cat<<EOF
82 Usage:  $ourname [OPTION]
83
84 OPTION can be...
85
86     all     -- builds zdiscid and zcdrip, also runs 'clean'
87     eshell  -- create eshell symlink workaround
88     clean   -- removes objects
89     install -- installs zcdrip
90
91 Hint:
92
93     If you want to install zcdrip to a directory somewhere in '${HOME}'
94     do something like...
95
96       target=${HOME}/bin ./build.sh install
97
98 EOF
99 }
100
101 case $argv[1] in
102     (all) all ;;
103     (eshell) eshell ;;
104     (clean) clean ;;
105     (install) _install ;;
106     (*) help ;;
107 esac
108     
109 ### build.sh ends here
110