README: markdownify the README.txt file
[blocksruntime.git] / installlib
blobad7b094ca397399a94639cb3f6e916339a475134
1 #!/bin/sh
3 : ${prefix:=/usr/local}
4 : ${includedir:=$prefix/include}
5 : ${libdir:=$prefix/lib}
6 : ${DESTDIR:=}
8 HEADER=BlocksRuntime/Block.h
9 LIB=libBlocksRuntime.a
11 docmd()
13 echo "$*"
14 if [ -z "$dryrun" ]; then eval "$*"; fi
17 if ! myid="$(id -u)"; then
18 echo "Cannot run id, aborting!"
19 exit 1
21 if [ ! -r $HEADER ]; then
22 echo "Cannot find $HEADER, aborting!"
23 exit 1
25 if [ ! -r $LIB ]; then
26 echo "Cannot find $LIB, did you run buildlib or buildlib-osx?"
27 exit 1
29 dryrun=
30 if [ "$1" = '-n' ] || [ "$1" = '--dry-run' ]; then
31 dryrun=1
32 shift
34 if [ "$#" != 0 ]; then
35 echo "Usage: [prefix=prefixdir] $0 [-n | --dry-run]"
36 exit 1
39 if [ -n "$DESTDIR" ]; then
40 echo "Destination Root(\$DESTDIR): $DESTDIR (default is \"\")"
42 echo "Install Prefix(\$prefix): $prefix (default is /usr/local)"
43 echo "Include Directory(\$includedir): $includedir (default is \$prefix/include)"
44 echo "Library Directory(\$libdir): $libdir (default is \$prefix/lib)"
45 echo "(use prefix=prefixdir $0 [or similar] to change)"
46 echo ''
48 if [ -z "$DESTDIR" -a -z "$dryrun" -a "$myid" != 0 ]; then
49 echo "Must be root to install, use sudo $0"
50 echo "(Or try using the --dry-run option)"
51 exit 1
53 docmd "install -d "$DESTDIR"$includedir "$DESTDIR"$libdir"
54 docmd "install -m 644 $HEADER "$DESTDIR"$includedir/"
55 docmd "install -m 644 $LIB "$DESTDIR"$libdir/"