A couple of build tweaks.
authorSteve Youngs <steve@steveyoungs.com>
Sun, 19 Jun 2011 04:05:43 +0000 (14:05 +1000)
committerSteve Youngs <steve@steveyoungs.com>
Sun, 19 Jun 2011 04:05:43 +0000 (14:05 +1000)
* build.sh (ESHELL,PREFIX,BINDIR): New
  Make it easier to build and ensure that the eshell compatibility
  symlink is installed as a symlink.

Signed-off-by: Steve Youngs <steve@steveyoungs.com>
build.sh

index 9cb9d65..d199c6c 100755 (executable)
--- a/build.sh
+++ b/build.sh
 ## 
 ##    Because I suck at writing makefiles
 
+PREFIX=${PREFIX:-/usr/local}
+BINDIR=${BINDIR:-${PREFIX}/bin}
+ESHELL=${ESHELL:-0}
+
 ### Code:
 clean ()
 {
@@ -54,6 +58,7 @@ all ()
     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
 }
 
@@ -63,16 +68,15 @@ eshell ()
     ln -svf zcdrip ecdrip
 }
 
-target=${target:-/usr/local/bin}
 INSTALL=${INSTALL:-install}
 
 _install ()
 {
     [[ -f zcdrip && -f zdiscid ]] || all
 
-    $INSTALL -vd $target
-    $INSTALL -v zcdrip zdiscid $target
-    [[ -f ecdrip ]] && $INSTALL -v ecdrip $target
+    $INSTALL -v -m755 -d ${BINDIR}
+    $INSTALL -v -m755 zcdrip zdiscid ${BINDIR}
+    [[ -h ecdrip ]] && ln -svf zcdrip ${BINDIR}/ecdrip
 }
 
 ourname=${0##/}
@@ -88,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
 }