RIP freedb.org -- Add notes/todos re migrating to MusicBrainz
[zcdrip] / build.sh
index 046d2d5..058d01e 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -1,9 +1,9 @@
 #!/bin/zsh
 
-## Copyright (C) 2006, 2007 Steve Youngs
+## Copyright (C) 2006 - 2011 Steve Youngs
 
-## Author:        Steve Youngs <steve@sxemacs.org>
-## Maintainer:    Steve Youngs <steve@sxemacs.org>
+## Author:        Steve Youngs <steve@steveyoungs.com>
+## Maintainer:    Steve Youngs <steve@steveyoungs.com>
 ## Created:       <2006-08-16>
 
 ## This file is part of zcdrip
 ## 
 ##    Because I suck at writing makefiles
 
+PREFIX=${PREFIX:-/usr/local}
+BINDIR=${BINDIR:-${PREFIX}/bin}
+ESHELL=${ESHELL:-0}
+
 ### Code:
 clean ()
 {
@@ -49,10 +53,12 @@ all ()
 {
     clean
     sub=@VERSION@
-    rep=$(tla logs --full|tail -n1)
+    tver=v0.7
+    rep=$(git describe 2>/dev/null||echo ${tver})
     zmodload -i zsh/mapfile
     gcc -Wall -o zdiscid zdiscid.c
     mapfile[zcdrip]=${mapfile[zcdrip.in]/$sub/$rep}
+    [[ ${ESHELL} -eq 1 ]] && eshell
     chmod -v 755 zcdrip
 }
 
@@ -62,16 +68,15 @@ eshell ()
     ln -svf zcdrip ecdrip
 }
 
-target=${target:-/usr/local/bin}
 INSTALL=${INSTALL:-install}
 
 _install ()
 {
-    [[ -f zcdrip && -f zdiscid ]] || all
+    [[ ! -f zcdrip || zcdrip.in -nt zcdrip ]] && all
 
-    $INSTALL -vd $target
-    $INSTALL -v zcdrip zdiscid $target
-    [[ -f ecdrip ]] && $INSTALL -v ecdrip $target
+    $INSTALL -vdm755 ${BINDIR}
+    $INSTALL -vm755 album_art zcdrip zdiscid ${BINDIR}
+    [[ ${ESHELL} -eq 1 || -h ecdrip ]] && ln -svf zcdrip ${BINDIR}/ecdrip
 }
 
 ourname=${0##/}
@@ -87,12 +92,27 @@ OPTION can be...
     clean   -- removes objects
     install -- installs zcdrip
 
-Hint:
+Hints:
 
     If you want to install zcdrip to a directory somewhere in '${HOME}'
     do something like...
 
-      target=${HOME}/bin ./build.sh install
+      PREFIX=${HOME} ./build.sh install
+
+    Which would put everything in ${HOME}/bin
+    or...
+
+      BINDIR=${HOME}/some/other/dir ./build.sh install
+
+    Which would put everything in ${HOME}/some/other/dir
+
+    Basically, setting PREFIX sets the install directory to PREFIX/bin
+    and setting BINDIR sets the install directory to exactly BINDIR
+
+    You can also automatically build the eshell version by setting
+    ESHELL to 1 (one)...
+
+      ESHELL=1 ./build.sh install
 
 EOF
 }