| 1 | #!/bin/sh |
| 2 | |
| 3 | # default: |
| 4 | PREFIX=/usr/local |
| 5 | PROGS="java javac jar make sed" |
| 6 | |
| 7 | valid=true |
| 8 | while [ "$*" != "" ]; do |
| 9 | key=`echo "$1" | cut -f1 -d=` |
| 10 | val=`echo "$1" | cut -f2 -d=` |
| 11 | case "$key" in |
| 12 | --) |
| 13 | ;; |
| 14 | --help) # This help message |
| 15 | echo The following arguments can be used: |
| 16 | cat "$0" | grep '^\s*--' | grep '#' | while read ln; do |
| 17 | cmd=`echo "$ln" | cut -f1 -d')'` |
| 18 | msg=`echo "$ln" | cut -f2 -d'#'` |
| 19 | echo " $cmd$msg" |
| 20 | done |
| 21 | ;; |
| 22 | --prefix) #=PATH Change the prefix to the given path |
| 23 | PREFIX="$val" |
| 24 | ;; |
| 25 | *) |
| 26 | echo "Unsupported parameter: '$1'" >&2 |
| 27 | echo >&2 |
| 28 | sh "$0" --help >&2 |
| 29 | valid=false |
| 30 | ;; |
| 31 | esac |
| 32 | shift |
| 33 | done |
| 34 | |
| 35 | [ $valid = false ] && exit 1 |
| 36 | |
| 37 | MESS="A required program cannot be found:" |
| 38 | for prog in $PROGS; do |
| 39 | out="`whereis -b "$prog" 2>/dev/null`" |
| 40 | if [ "$out" = "$prog:" ]; then |
| 41 | echo "$MESS $prog" >&2 |
| 42 | valid=false |
| 43 | fi |
| 44 | done |
| 45 | |
| 46 | [ $valid = false ] && exit 2 |
| 47 | |
| 48 | if [ "`whereis tput`" = "tput:" ]; then |
| 49 | ok='"[ ok ]"'; |
| 50 | ko='"[ !! ]"'; |
| 51 | cols=80; |
| 52 | else |
| 53 | ok='"`tput bold`[`tput setf 2` OK `tput init``tput bold`]`tput init`"'; |
| 54 | ko='"`tput bold`[`tput setf 4` !! `tput init``tput bold`]`tput init`"'; |
| 55 | cols='"`tput cols`"'; |
| 56 | fi; |
| 57 | |
| 58 | echo "MAIN = be/nikiroo/gofetch/Main" > Makefile |
| 59 | echo "MORE = " >> Makefile |
| 60 | echo "TEST = " >> Makefile |
| 61 | echo "TEST_PARAMS = $cols $ok $ko" >> Makefile |
| 62 | echo "NAME = gofetch" >> Makefile |
| 63 | echo "PREFIX = $PREFIX" >> Makefile |
| 64 | echo "JAR_FLAGS += -C bin/ org -C bin/ be -C bin/ VERSION" >> Makefile |
| 65 | #echo "SJAR_FLAGS += -C src/ org -C src/ jexer -C src/ be -C ./ LICENSE -C ./ README.md -C ./ VERSION" >> Makefile |
| 66 | |
| 67 | cat Makefile.base >> Makefile |
| 68 | |