summaryrefslogtreecommitdiffstats
path: root/do
blob: d5384484e9277667a9a78997ae93fc1212a7b5f3 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/sh

#
# Description:
#	ZABBIX compilateion script
# Author:
#	Eugene Grigorjev
#

win2nix="no"
premake="no"
copy="no"
tgz="no"
configure="no"
domake="no"
config_param="--prefix=`pwd`"
dotest="no"
cleanwarnings="no"
docat="yes"
help="no"
noparam=0;
def="--enable-agent --enable-server --with-mysql --with-ldap --with-net-snmp"

for cmd
do
  case "$cmd" in
    win2nix )	win2nix="yes";		noparam=1;;
    copy )	copy="yes";		noparam=1;;
    cpy )	copy="yes";		noparam=1;;
    pre )	premake="yes";		noparam=1;;
    premake )	premake="yes";		noparam=1;;
    conf )	configure="yes";	noparam=1;;
    config )	configure="yes";	noparam=1;;
    configure )	configure="yes";	noparam=1;;
    make )	domake="yes";		noparam=1;;
    test )	dotest="yes";		noparam=1;;
    tar )	tgz="yes";		noparam=1;;
    nocat )	docat="no";		noparam=1;;
    cat )	docat="yes";		noparam=1;;
    def )		config_param="$config_param $def";;
    --enable-* )	config_param="$config_param $cmd";; 
    --with-* )		config_param="$config_param $cmd";;
    --prefix=* )	config_param="$config_param $cmd";;
    help )	help="yes";;
    h )		help="yes";;
    * ) 
        echo "$0: ERROR: uncnown parameter \"$cmd\""; 
	help="yes";
  esac
done
if [ "$help" = "yes" ] || [ $noparam = 0 ]
then
        echo
        echo "Usage:"
        echo "  $0 [commands] [options]"
	echo
	echo " Commands:"
	echo "   [win2nix]                - convers win EOL [\\r\\n] to nix EOL [\\r]"
	echo "   [copy|cpy]               - copy automake files"
	echo "   [premake|pre]            - make configuration file"
	echo "   [configure|config|conf]  - configure make files"
	echo "   [make]                   - make applications"
	echo "   [test]                   - test applications"
	echo "   [tar]                    - create ../zabbix.tar.gz of this folder"
	echo
	echo " Options:"
	echo "   [def]            - default configuration \"$def\""
	echo "   [cat]            - cat WARRNING file at the end (defaut - ON)"
	echo "   [nocat]          - do not cat WARRNING file"
	echo "   [--enable-*]     - option for configuration"
	echo "   [--with-*]       - option for configuration"
        echo
        echo "Examples:"
        echo "  $0 conf def make test        - compyle, test, and sow report"
        echo "  $0 cpy tar nocat             - make archive .tar.gz and don't show report"
        echo "  $0 cat                       - cat last REPORT"
        echo "  $0                           - show this help"
        exit 1;
fi

if [ "$copy" = "yes" ] || [ $premake = "yes" ] || 
  [ $configure = "yes" ] || [ $domake = "yes" ] || 
  [ $dotest = "yes" ] || [ $tgz = "yes" ] ||
  [ "$win2nix" = "yes" ]
then
  cleanwarnings="yes"
fi

if [ "$cleanwarnings" = "yes" ] 
then
  rm -f WARNINGS
fi

if [ "$win2nix" = "yes" ]
then
  echo "Replacing..."
  echo "Replacing..." >> WARNINGS
  find ./ -name "configure.in" -exec vi "+%s/\\r$//" "+wq" "-es" {} ';' -print 2>> WARNINGS
  find ./ -name "*.[hc]" -exec vi "+%s/\\r$//" "+wq" "-es" {} ';' -print 2>> WARNINGS
fi

if [ "$premake" = "yes" ] 
then
  echo "Pre-making..."
  echo "Pre-making..." >> WARNINGS
  aclocal 2>> WARNINGS
  autoconf 2>> WARNINGS
  autoheader 2>> WARNINGS
  automake -a 2>> WARNINGS
  automake 2>> WARNINGS
fi

if [ "$copy" = "yes" ] 
then
  echo "Copyng..."
  echo "Copyng..." >> WARNINGS
  rm -f config.guess config.sub depcomp install-sh missing 2>> WARNINGS

  cp /usr/share/automake-1.9/config.guess config.guess 2>> WARNINGS
  cp /usr/share/automake-1.9/config.sub   config.sub 2>> WARNINGS
  cp /usr/share/automake-1.9/depcomp      depcomp 2>> WARNINGS
  cp /usr/share/automake-1.9/install-sh   install-sh 2>> WARNINGS
  cp /usr/share/automake-1.9/missing      missing 2>> WARNINGS
fi

if [ "$configure" = "yes" ] 
then
  echo "Configuring..."
  echo "Configuring..." >> WARNINGS
  #export CFLAGS="-Wall"
  #export CFLAGS="-Wall -pedantic"
  ./configure $config_param 2>>WARNINGS 
fi

if [ "$domake" = "yes" ] 
then
  echo "Cleaning..."
  echo "Cleaning..." >> WARNINGS
  make clean 2>>WARNINGS 
  echo "Making..."
  echo "Making..." >> WARNINGS
  make 2>>WARNINGS 
fi

if [ "$dotest" = "yes" ] 
then
  echo "Testing..."
  echo "Testing..." >> WARNINGS
  ./src/zabbix_agent/zabbix_agent -h >> WARNINGS
  ./src/zabbix_agent/zabbix_agentd -h >> WARNINGS
  ./src/zabbix_get/zabbix_get -h >> WARNINGS
  ./src/zabbix_sender/zabbix_sender -h >> WARNINGS
  ./src/zabbix_server/zabbix_server -h >> WARNINGS
  echo "------------------------" >> WARNINGS 
  echo "   Agent TEST RESULTS   " >> WARNINGS 
  echo "------------------------" >> WARNINGS 
  ./src/zabbix_agent/zabbix_agentd -p >> WARNINGS
fi

if [ "$tgz" = "yes" ] 
then
  echo "Zipping..."
  rm -f ../zabbix.tar.gz
  tar cvzf ../zabbix.tar.gz .
fi

if [ "$docat" = "yes" ] 
then
  echo
  echo WARNINGS
  echo "-----------------------------------"
  cat WARNINGS
  echo "-----------------------------------"
fi