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