-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sh
executable file
·149 lines (126 loc) · 6.54 KB
/
build.sh
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
#!/bin/bash
# check if we can build 32bits binaries
cat > /tmp/conftest.c << _LT_EOF
int main() { return 0;}
_LT_EOF
gcc -m32 /tmp/conftest.c -o /tmp/conftest > /dev/null 2>&1
can32bits=$?
rm /tmp/conftest.c /tmp/conftest 2> /dev/null
arch=""
additionallibs=""
MACHINE_TYPE=`uname -m`
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
destarchs="64"
if [[ ${can32bits} -eq 0 ]]; then
destarchs="64 32"
fi
elif [ ${MACHINE_TYPE} == 'sun4u' ]; then
destarchs="32"
arch="_sparc"
additionallibs="-lsocket -lnsl"
else
destarchs="32"
fi
#rm libs/lib*
#rm -rf 3rdparty/tmp
for destarch in $destarchs; do
gccopts="-Wl,-Bstatic -m${destarch} -O2 -pipe -Iinclude -Llibs -Bstatic \
-Wall -Wno-trigraphs -fno-strict-aliasing -fno-common -ggdb -Wl,-Bdynamic"
## quarrantined options:
## "-fPIC" (only works for shared libraries, not used)
## useful options:
## "-O2" to enable optimizations
## "-ggdb" to enable debug symbols
## "-DDEBUG_LOG -DDEBUG_MEM" to enable debuging of memory allocation
## unknown what they do, even if the are used "-DGETHOSTBYNAME -DGETSERVBYNAME"
if [[ ! -f libs/libdebug${destarch}${arch}.a ]]; then
gcc $gccopts -c -o obj/log${destarch}.o src/libdebug/log.c
gcc $gccopts -c -o obj/memory${destarch}.o src/libdebug/memory.c
gcc $gccopts -c -o obj/hex${destarch}.o src/libdebug/hex.c
ar crv libs/libdebug${destarch}${arch}.a obj/log${destarch}.o obj/memory${destarch}.o obj/hex${destarch}.o > /dev/null
fi
if [[ ! -f libs/libconfig${destarch}${arch}.a ]]; then
gcc $gccopts -c -o obj/scan${destarch}.o src/libconfig/scan.c
gcc $gccopts -c -o obj/parse${destarch}.o src/libconfig/parse.c
gcc $gccopts -c -o obj/config${destarch}.o src/libconfig/config.c
ar crv libs/libconfig${destarch}${arch}.a obj/scan${destarch}.o obj/parse${destarch}.o obj/config${destarch}.o > /dev/null
fi
if [[ ! -f libs/libz${destarch}${arch}.a ]]; then
pushd . > /dev/null
rm -r 3rdparty/tmp/zlib-1.2.8 2> /dev/null
mkdir 3rdparty/tmp/ 2> /dev/null
cd 3rdparty/tmp > /dev/null
gzip -dc ../zlib-1.2.8.tar.gz | tar xf -
cd ../.. > /dev/null
DESTDIR=`pwd`/3rdparty/tmp/
cd $DESTDIR/zlib-1.2.8 > /dev/null
CFLAGS="-m${destarch}" ./configure --static > /tmp/build${destarch}${arch}.log 2>&1
make install DESTDIR=$DESTDIR >> /tmp/build${destarch}${arch}.log 2>&1
popd > /dev/null
cp $DESTDIR/usr/local/lib/libz.a libs/libz${destarch}${arch}.a
fi
if [[ ! -f libs/libcurl${destarch}${arch}.a ]]; then
pushd . > /dev/null
rm -r 3rdparty/tmp/curl-7.30.0 2> /dev/null
mkdir 3rdparty/tmp/ 2> /dev/null
cd 3rdparty/tmp > /dev/null
bzip2 -dc ../curl-7.30.0.tar.bz2 | tar xf -
cd ../.. > /dev/null
DESTDIR=`pwd`/3rdparty/tmp/
cd $DESTDIR/curl-7.30.0 > /dev/null
export CFLAGS="-m${destarch}"
./configure --enable-static --without-libidn --without-librtmp \
--disable-shared --disable-ssl \
--disable-ipv6 --disable-rtsp --disable-dict --disable-gopher --disable-https \
--disable-telnet --disable-smtp --disable-smtps --disable-imap --disable-imaps \
--disable-pop3 --disable-pop3s --disable-ftps --without-ssl --without-polarssl \
--disable-ldap --disable-ldaps --disable-debug --disable-ntlm-wb \
--disable-tls-srp --prefix=/usr/local/${destarch}${arch} >> /tmp/build${destarch}${arch}.log 2>&1
make install DESTDIR=$DESTDIR >> /tmp/build${destarch}${arch}.log 2>&1
popd > /dev/null
cp $DESTDIR/usr/local/${destarch}${arch}/lib/libcurl.a libs/libcurl${destarch}${arch}.a
fi
rnopts="-lm -ldl -lpthread -static-libgcc ${additionallibs} \
-lconfig${destarch}${arch} -ldebug${destarch}${arch} \
-lcurl${destarch}${arch} -lz${destarch}${arch} -lrt \
-I3rdparty/tmp/usr/local/${destarch}${arch}/include"
rncfiles="src/asterix.c src/sacsic.c src/helpers.c \
src/startup.c src/crc32.c src/red_black_tree.c \
src/red_black_tree_misc.c src/red_black_tree_stack.c \
src/md5.c"
gcc $gccopts -DCLIENT_RRD -o bin/reader_rrd3${destarch}${arch} $rncfiles src/reader_rrd3.c $rnopts -I/usr/include/mysql -DBIG_JOINS=1 `mysql_config --libs` -lmysqlclient
#echo gcc $gccopts -o bin/reader_network${destarch}${arch} $rncfiles src/reader_network.c $rnopts
gcc $gccopts -o bin/reader_network${destarch}${arch} $rncfiles src/reader_network.c $rnopts
#strip bin/reader_network${destarch} 2> /dev/null
#-L/usr/lib/x86_64-linux-gnu
#`mysql_config --libs | cut -d ' ' -f1`
gcc $gccopts -o bin/client_time${destarch}${arch} src/client_time.c src/sacsic.c src/helpers.c src/startup.c $rnopts
gcc $gccopts -o bin/client${destarch}${arch} src/client.c src/sacsic.c src/helpers.c src/startup.c $rnopts
gcc $gccopts -o bin/cleanast${destarch}${arch} src/utils/cleanast.c $rnopts
gcc $gccopts -o bin/cleanast_s${destarch}${arch} src/utils/cleanast_s.c $rnopts
gcc $gccopts -o bin/listersacsic_s${destarch}${arch} src/utils/listersacsic_s.c $rnopts
gcc $gccopts -o bin/filtercat${destarch}${arch} src/utils/filtercat.c $rnopts
gcc $gccopts -o bin/filtercat_s${destarch}${arch} src/utils/filtercat_s.c $rnopts
gcc $gccopts -o bin/filtertime_s${destarch}${arch} src/utils/filtertime_s.c $rnopts
gcc $gccopts -o bin/filtercatout${destarch}${arch} src/utils/filtercatout.c $rnopts
gcc $gccopts -o bin/filtersacsic${destarch}${arch} src/utils/filtersacsic.c $rnopts
gcc $gccopts -o bin/filtersacsicout${destarch}${arch} src/utils/filtersacsicout.c $rnopts
gcc $gccopts -o bin/filtersacsic_s${destarch}${arch} src/utils/filtersacsic_s.c $rnopts
gcc $gccopts -o bin/joingps${destarch}${arch} src/utils/joingps.c $rnopts
gcc $gccopts -o bin/joingps_s${destarch}${arch} src/utils/joingps_s.c $rnopts
gcc $gccopts -o bin/memresps${destarch}${arch} src/memresp/memresps.c $rnopts
gcc $gccopts -o bin/gps2era${destarch}${arch} src/utils/gps2era.c $rnopts
gcc $gccopts -o bin/hensoldt2ast${destarch}${arch} src/utils/hensoldt2ast.c $rnopts
done
#gcc -Wall -Iinclude/ src/memresp/memresp.c -o bin/memresp -DLINUX
#gcc -Wall -Iinclude/ src/memresp/memresps.c -o bin/memresps -DLINUX
ls -la bin/
#scp bin/reader_network64 10.40.210.32:/home/eval/reader_network64
exit
#old binaries
#gcc -Wall -Iinclude/ src/cmpclock.c -o bin/cmpclock
#gcc -g -o bin/client_rrd src/client_rrd.c src/sacsic.c src/helpers.c $params
#gcc -g -o bin/client_rrd2 src/client_rrd2.c src/sacsic.c src/helpers.c $params
#gcc -g -o bin/client src/client.c src/sacsic.c src/helpers.c src/startup.c $params
#gcc -g -o bin/client_filter src/client_filter.c src/sacsic.c src/helpers.c src/startup.c $params
#gcc -Wall -g -o bin/repeater_network src/repeater_network.c src/asterix.c src/sacsic.c src/helpers.c src/startup.c $params