clean code and changed version nro.
[irreco.git] / script / backend.sh
blob0476916ed678e3b74427296995a0beb3bd0d114f
1 #!/bin/bash
2 cd `dirname "$0"`
3 source variables.sh
4 scratchbox_need
7 # Script for automating backend testing.
10 backend_main()
12 BACKEND="$1"
13 COMMAND="$2"
14 ARGS=("$@")
16 if [[ "$COMMAND" == "" ]]; then
17 echo "Error: You did not give me a command to run!"
18 backend_usage
19 exit 1
22 if [[ "$BACKEND" == "" ]]; then
23 echo "Error: You did not give me backend name!"
24 backend_usage
25 exit 1
28 if [[ "$BACKEND" == "all" ]]; then
29 cd "$BACKEND_DIR"
30 { while read BACKEND; do
31 if [ -d "$BACKEND" ]; then
32 "$SCRIPT_DIR/$SCRIPT_NAME" \
33 "$BACKEND" "$COMMAND" "${ARGS[@]:2}"
34 check_exit_code "$?"
36 done } < <( ls -1 | egrep -v "$ALL_BACKENDS_FILTER" )
37 exit 0
40 if [ ! -d "$BACKEND_DIR/$BACKEND" ]; then
41 echo "Error: Backend \"$BACKEND\" does not exist!"
42 exit 1
45 cd "$BACKEND_DIR/$BACKEND"
46 check_exit_code "$?"
48 declare -x PKG_CONFIG_PATH="$SCRIPT_TMP_DIR:$PKG_CONFIG_PATH"
49 #echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
51 case "$COMMAND" in
52 --config|config|conf) backend_conf "${ARGS[@]:2}";;
53 --make|make) backend_make "${ARGS[@]:2}";;
54 --install|install|inst) backend_install "${ARGS[@]:2}";;
55 --clean|clean) backend_clean "${ARGS[@]:2}";;
56 --src|src) backend_src "${ARGS[@]:1}";;
57 *) echo "Error: Unknown command \"$COMMAND\"";
58 backend_usage;
59 exit 1;;
60 esac
63 backend_usage()
65 echo ""
66 echo "Usage: $SCRIPT_NAME BACKEND COMMAND [ options ]"
67 echo " $SCRIPT_NAME all COMMAND [ options ]"
68 echo ""
69 echo "If BACKEND is all, then COMMAND is executed for all backends"
70 echo "excepth those which match this regex: \"$ALL_BACKENDS_FILTER\"."
71 echo ""
72 echo "Commands:"
73 echo " --config | config | conf [ options ]"
74 echo " Congigure backend. Options are passed to ./configure script."
75 echo " --make | make"
76 echo " Compile backend."
77 echo " --install | install | inst"
78 echo " Install backend to \"$INSTALL_DIR\"."
79 echo " --clean | clean"
80 echo " Clean backend."
81 echo " --src | src"
82 echo " Show a list of backend source code files."
83 echo ""
86 backend_conf()
88 create_install_dir
90 if [ -e './autogen.sh' ]; then
91 backend_print_title "AUTOGEN"
92 ./autogen.sh
93 check_exit_code "$?"
96 backend_print_title "CONFIGURE"
97 ./configure --prefix="$INSTALL_DIR" --enable-debug=yes "$@"
98 check_exit_code "$?"
101 backend_make()
103 if [ ! -e "Makefile" ]; then
104 backend_conf
106 generic_make backend_print_title "$@"
109 backend_install()
111 backend_make
112 backend_print_title "INSTALL"
113 make install
114 check_exit_code "$?"
117 backend_clean()
119 generic_clean backend_print_title
123 # Prints a list of backend sources and headers.
125 backend_src()
127 backend_print_title "SOURCES"
128 echo -n "$BACKEND""_SOURCES = "
129 cd "$BACKEND_DIR/$BACKEND"
130 find | egrep '\.[ch]$' | sort | scripts_src_pad
131 cd "$OLDPWD"
134 backend_print_title()
136 print_title `echo "$BACKEND" | tr a-z A-Z `" $1"
139 backend_main "$@"