File: make_and_install

package info (click to toggle)
kamailio 4.2.0-2+deb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (153 lines) | stat: -rwxr-xr-x 6,449 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash

if [ "$1" == "" ]; then
  echo "Usage:"
  echo "$0 [clean|compile|install|nccompile|ncinstall] \"standard|standard-dep|mysql|radius|presence|stable|experimental\" [ignore|stop] [installpath]"
  echo " "
  echo "  The first parameter specifies what to do: 'clean' up source tree, 'compile', or compile and 'install'.."
  echo "  The 'nccompile' and 'ncinstall' do the same as compile and install respectively, but withou"
  echo "  cleaning the source tree first (this will make make_and_install_output.txt easier to scan for"
  echo "  errors and takes less time after you have compiled once)."
  echo " "
  echo "  The second parameter controls which modules to include. It may list several group names"
  echo "  separated by space (see INSTALL). If you don't know what to include, use \"standard\" (default) "
  echo "  or \"standard mysql\" (if you want mysql storage support)."
  echo " "
  echo "  ignore|stop(default) specifies whether to stop after found errors or ignore and just install."
  echo "  If you have errors in a module with dependencies, it will allow you to install the remaining"
  echo "  modules. This switch is only relevant for install and ncinstall."
  echo " "
  echo "  If installpath is not supplied, ser will be installed created in /usr/local and sub-directories."
  echo " "
  echo "  Groups and installpath will be stored and reused the next time you use make_and_install unless"
  echo "  you specify explicitly groups and installpath on the command line."
  echo " "
  echo "  Examples:"
  echo "   $0 compile"
  echo "     will compile the standard modules without external dependencies."
  echo "    If the make_and_install_config_* files exist, groups and installpath specified there will be used."
  echo " "
  echo "   $0 install \"standard mysql\" stop /tmp/ser"
  echo "    will compile and install all mysql and standard modules without external dependencies to /tmp/ser"
  echo "    and stop and not install if there are errors."
  echo "    make_and_install_config_* files will be created to save the groups and installpath."
  echo " "
  echo "   $0 ncinstall \"standard standard-dep\" ignore"
  echo "    will compile without cleaning first (i.e. skip already made files and modules). All"
  echo "    modules without (standard) and with (standard-dep) dependencies will be included, but"
  echo "    if a module won't compile due to lack of installed dependencies, SER will still be installed"
  echo "    to default directory (/usr/local)."
  echo "    make_and_install_config_* files will be created to save the groups and installpath."
  echo " "
  echo "   $0 clean"
  echo "    will default clean ALL modules (not only standard). Specify groups to clean only those."
  echo "    If the make_and_install_config_groups file exists, groups specified there will be used."
  exit
fi

action="$1"
groups="$2"
whenerrors="$3"
installpath="$4"

# source the saved config
if [ "$groups" == "" ]; then
  echo "Attempting to load groups and install path from files..."
  echo "  To reset, either specify groups to include and installation path on command line or"
  echo "  do: rm make_and_install_config_*"
  echo " "
  if [ -f ./make_and_install_config_groups ]; then
    groups="`cat ./make_and_install_config_groups`"
    echo "    Loaded groups..."
  fi
  if [ -f ./make_and_install_config_installpath ]; then
    installpath="`cat ./make_and_install_config_installpath`"
    echo "    Loaded installpath..."
  fi
fi

if [ "$whenerrors" == "" ]; then
  whenerrors="stop"
fi
if [ "$installpath" == "" ]; then
  installpath="/usr/local"
fi
if [ "$groups" == "" ]; then
  if [ "$action" == "clean" ]; then
    groups="standard standard-dep stable experimental"
  else
    groups="standard"
  fi
fi
clean="yes"
if [ "$action" == "clean" ]; then
  echo "The source tree will be cleaned."
elif [ "$action" == "compile" ]; then
  echo "SER core and groups $groups will be compiled."
elif [ "$action" == "nccompile" ]; then
  echo "SER core and groups $groups will be compiled without cleaning source tree."
  clean="no"
  action="compile"
elif [ "$action" == "install" ]; then
  echo "SER core and groups $groups will be compiled and installed to $installpath."
elif [ "$action" == "ncinstall" ]; then
  echo "SER core and groups $groups will be compiled and installed to $installpath without cleaning source tree."
  clean="no"
  action="install"
else
  echo "No such action, please specify clean, compile, or install."
  exit
fi
echo " "
if [ "$action" == "clean" ]; then
    echo "----------------------"
    echo "Cleaning up the SER source tree for $groups... "
    echo "----------------------"
    make group_include="$groups" prefix=$installpath proper > /dev/null 2>&1
    rm -f make_and_install_output.txt
    rm -f make_and_install_config_*
    exit
fi

# save config
rm -f ./make_and_install_config*
echo "$groups" > ./make_and_install_config_groups
echo "$installpath" > ./make_and_install_config_installpath

echo " YOU WILL FIND THE OUTPUT IN make_and_install_output.txt IN THE CURRENT DIRECTORY"
echo "----------------------"
if [ "$clean" == "yes" ]; then
    echo "Cleaning up the source tree... "
    echo "----------------------"
    
    make group_include="$groups" prefix=$installpath proper > /dev/null 2>&1
    echo "----------------------"
fi
echo "Making ser and all modules in the groups \"$groups\". This may take some time..."
echo "----------------------"
echo "COMPILING......"
rm -f ./make_and_install_output.txt
make group_include="$groups" prefix=$installpath all > ./make_and_install_output.txt  2>&1
echo "----------------------"
count=`egrep "error |Error |error:" ./make_and_install_output.txt | wc -l | awk '{print $1}'`
if [ $count -ne 0 ]; then
    echo "FOUND ERRORS!"
    echo "  You may want to run the same $0 command again but use 'nccompile'."
    echo "  The output file will then be simpler to read."
    echo "  See make_and_install_output.txt for full output, search for 'error'."
    if [ "$whenerrors" == "ignore" ]; then
	echo " "
	echo "Error ignore switch was specified, moving on despite errors..."
    else
	exit
    fi
fi
if [ "$action" == "compile" ]; then
    echo "'compile' was used; skipping installation."
    exit
fi

echo "----------------------"
echo "Installing SER and all modules to $installpath"
echo "----------------------"
make group_include="$groups" prefix=$installpath install >> ./make_and_install_output.txt 2>&1