Browse code

added improved and modified onsip.org make_and_install wrapper script to simplify compile and installation. Run ./make_and_install to see docs. NOTE! Currently only tested for bash, patches to improve compatibility are welcome!

Greger V. Teigre authored on 07/03/2008 08:54:18
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,153 @@
0
+#!/bin/bash
1
+
2
+if [ "$1" == "" ]; then
3
+  echo "Usage:"
4
+  echo "$0 [clean|compile|install|nccompile|ncinstall] \"standard|standard-dep|mysql|radius|presence|stable|experimental\" [ignore|stop] [installpath]"
5
+  echo " "
6
+  echo "  The first parameter specifies what to do: 'clean' up source tree, 'compile', or compile and 'install'.."
7
+  echo "  The 'nccompile' and 'ncinstall' do the same as compile and install respectively, but withou"
8
+  echo "  cleaning the source tree first (this will make make_and_install_output.txt easier to scan for"
9
+  echo "  errors and takes less time after you have compiled once)."
10
+  echo " "
11
+  echo "  The second parameter controls which modules to include. It may list several group names"
12
+  echo "  separated by space (see INSTALL). If you don't know what to include, use \"standard\" (default) "
13
+  echo "  or \"standard mysql\" (if you want mysql storage support)."
14
+  echo " "
15
+  echo "  ignore|stop(default) specifies whether to stop after found errors or ignore and just install."
16
+  echo "  If you have errors in a module with dependencies, it will allow you to install the remaining"
17
+  echo "  modules. This switch is only relevant for install and ncinstall."
18
+  echo " "
19
+  echo "  If installpath is not supplied, ser will be installed created in /usr/local and sub-directories."
20
+  echo " "
21
+  echo "  Groups and installpath will be stored and reused the next time you use make_and_install unless"
22
+  echo "  you specify explicitly groups and installpath on the command line."
23
+  echo " "
24
+  echo "  Examples:"
25
+  echo "   $0 compile"
26
+  echo "     will compile the standard modules without external dependencies."
27
+  echo "    If the make_and_install_config_* files exist, groups and installpath specified there will be used."
28
+  echo " "
29
+  echo "   $0 install \"standard mysql\" stop /tmp/ser"
30
+  echo "    will compile and install all mysql and standard modules without external dependencies to /tmp/ser"
31
+  echo "    and stop and not install if there are errors."
32
+  echo "    make_and_install_config_* files will be created to save the groups and installpath."
33
+  echo " "
34
+  echo "   $0 ncinstall \"standard standard-dep\" ignore"
35
+  echo "    will compile without cleaning first (i.e. skip already made files and modules). All"
36
+  echo "    modules without (standard) and with (standard-dep) dependencies will be included, but"
37
+  echo "    if a module won't compile due to lack of installed dependencies, SER will still be installed"
38
+  echo "    to default directory (/usr/local)."
39
+  echo "    make_and_install_config_* files will be created to save the groups and installpath."
40
+  echo " "
41
+  echo "   $0 clean"
42
+  echo "    will default clean ALL modules (not only standard). Specify groups to clean only those."
43
+  echo "    If the make_and_install_config_groups file exists, groups specified there will be used."
44
+  exit
45
+fi
46
+
47
+action="$1"
48
+groups="$2"
49
+whenerrors="$3"
50
+installpath="$4"
51
+
52
+# source the saved config
53
+if [ "$groups" == "" ]; then
54
+  echo "Attempting to load groups and install path from files..."
55
+  echo "  To reset, either specify groups to include and installation path on command line or"
56
+  echo "  do: rm make_and_install_config_*"
57
+  echo " "
58
+  if [ -f ./make_and_install_config_groups ]; then
59
+    groups="`cat ./make_and_install_config_groups`"
60
+    echo "    Loaded groups..."
61
+  fi
62
+  if [ -f ./make_and_install_config_installpath ]; then
63
+    installpath="`cat ./make_and_install_config_installpath`"
64
+    echo "    Loaded installpath..."
65
+  fi
66
+fi
67
+
68
+if [ "$whenerrors" == "" ]; then
69
+  whenerrors="stop"
70
+fi
71
+if [ "$installpath" == "" ]; then
72
+  installpath="/usr/local"
73
+fi
74
+if [ "$groups" == "" ]; then
75
+  if [ "$action" == "clean" ]; then
76
+    groups="standard standard-dep stable experimental"
77
+  else
78
+    groups="standard"
79
+  fi
80
+fi
81
+clean="yes"
82
+if [ "$action" == "clean" ]; then
83
+  echo "The source tree will be cleaned."
84
+elif [ "$action" == "compile" ]; then
85
+  echo "SER core and groups $groups will be compiled."
86
+elif [ "$action" == "nccompile" ]; then
87
+  echo "SER core and groups $groups will be compiled without cleaning source tree."
88
+  clean="no"
89
+  action="compile"
90
+elif [ "$action" == "install" ]; then
91
+  echo "SER core and groups $groups will be compiled and installed to $installpath."
92
+elif [ "$action" == "ncinstall" ]; then
93
+  echo "SER core and groups $groups will be compiled and installed to $installpath without cleaning source tree."
94
+  clean="no"
95
+  action="install"
96
+else
97
+  echo "No such action, please specify clean, compile, or install."
98
+  exit
99
+fi
100
+echo " "
101
+if [ "$action" == "clean" ]; then
102
+    echo "----------------------"
103
+    echo "Cleaning up the SER source tree for $groups... "
104
+    echo "----------------------"
105
+    make group_include="$groups" prefix=$installpath proper > /dev/null 2>&1
106
+    rm -f make_and_install_output.txt
107
+    rm -f make_and_install_config_*
108
+    exit
109
+fi
110
+
111
+# save config
112
+rm -f ./make_and_install_config*
113
+echo "$groups" > ./make_and_install_config_groups
114
+echo "$installpath" > ./make_and_install_config_installpath
115
+
116
+echo " YOU WILL FIND THE OUTPUT IN make_and_install_output.txt IN THE CURRENT DIRECTORY"
117
+echo "----------------------"
118
+if [ "$clean" == "yes" ]; then
119
+    echo "Cleaning up the source tree... "
120
+    echo "----------------------"
121
+    
122
+    make group_include="$groups" prefix=$installpath proper > /dev/null 2>&1
123
+    echo "----------------------"
124
+fi
125
+echo "Making ser and all modules in the groups \"$groups\". This may take some time..."
126
+echo "----------------------"
127
+echo "COMPILING......"
128
+rm -f ./make_and_install_output.txt
129
+make group_include="$groups" prefix=$installpath all > ./make_and_install_output.txt  2>&1
130
+echo "----------------------"
131
+count=`egrep "error |Error |error:" ./make_and_install_output.txt | wc -l | awk '{print $1}'`
132
+if [ $count -ne 0 ]; then
133
+    echo "FOUND ERRORS!"
134
+    echo "  You may want to run the same $0 command again but use 'nccompile'."
135
+    echo "  The output file will then be simpler to read."
136
+    echo "  See make_and_install_output.txt for full output, search for 'error'."
137
+    if [ "$whenerrors" == "ignore" ]; then
138
+	echo " "
139
+	echo "Error ignore switch was specified, moving on despite errors..."
140
+    else
141
+	exit
142
+    fi
143
+fi
144
+if [ "$action" == "compile" ]; then
145
+    echo "'compile' was used; skipping installation."
146
+    exit
147
+fi
148
+
149
+echo "----------------------"
150
+echo "Installing SER and all modules to $installpath"
151
+echo "----------------------"
152
+make group_include="$groups" prefix=$installpath install >> ./make_and_install_output.txt 2>&1