added irreco_theme_save function
[irreco.git] / script / backend.sh
blob34e70e284659ac4f7c16380367826fb48ed9056f
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)
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 "Commands:"
70 echo " --config | config | conf [ options ]"
71 echo " Congigure backend. Options are passed to ./configure script."
72 echo " --make | make"
73 echo " Compile backend."
74 echo " --install | install | inst"
75 echo " Install backend to \"$INSTALL_DIR\"."
76 echo " --clean | clean"
77 echo " Clean backend."
78 echo " --src | src"
79 echo " Show a list of backend source code files."
80 echo ""
83 backend_conf()
85 create_install_dir
87 if [ -e './autogen.sh' ]; then
88 backend_print_title "AUTOGEN"
89 ./autogen.sh
90 check_exit_code "$?"
93 backend_print_title "CONFIGURE"
94 ./configure --prefix="$INSTALL_DIR" --enable-debug=yes "$@"
95 check_exit_code "$?"
98 backend_make()
100 if [ ! -e "Makefile" ]; then
101 backend_conf
103 generic_make backend_print_title "$@"
106 backend_install()
108 backend_make
109 backend_print_title "INSTALL"
110 make install
111 check_exit_code "$?"
114 backend_clean()
116 generic_clean backend_print_title
120 # Prints a list of backend sources and headers.
122 backend_src()
124 backend_print_title "SOURCES"
125 echo -n "$BACKEND""_SOURCES = "
126 cd "$BACKEND_DIR/$BACKEND"
127 find | egrep '\.[ch]$' | sort | scripts_src_pad
128 cd "$OLDPWD"
131 backend_print_title()
133 print_title `echo "$BACKEND" | tr a-z A-Z `" $1"
136 backend_main "$@"