-
Notifications
You must be signed in to change notification settings - Fork 5
/
build
executable file
·141 lines (120 loc) · 4.2 KB
/
build
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
#!/bin/bash
export PG_VERSION=$(cat src/drivers/pg/common.h | grep "VERSION \+" | sed 's/^.*VERSION *//' | sed 's/"//g')
export MYSQL_VERSION=$(cat src/drivers/mysql/common.h | grep "VERSION \+" | sed 's/^.*VERSION *//' | sed 's/"//g')
export SQLITE3_VERSION=$(cat src/drivers/sqlite3/common.h | grep "VERSION \+" | sed 's/^.*VERSION *//' | sed 's/"//g')
cleanup() {
make clean
rm -rf cmake_install.cmake CMakeFiles/ CMakeCache.txt install_manifest.txt Makefile
rm -rf debian/dbic++-dev.debhelper.log
rm -rf debian/dbic++-dev.substvars
rm -rf debian/dbic++-dev/
rm -rf debian/dbic++-mysql.debhelper.log
rm -rf debian/dbic++-mysql.postinst.debhelper
rm -rf debian/dbic++-mysql.postrm.debhelper
rm -rf debian/dbic++-mysql.substvars
rm -rf debian/dbic++-mysql/
rm -rf debian/dbic++-pg.debhelper.log
rm -rf debian/dbic++-pg.postinst.debhelper
rm -rf debian/dbic++-pg.postrm.debhelper
rm -rf debian/dbic++-pg.substvars
rm -rf debian/dbic++-pg/
rm -rf debian/files
rm -rf debian/stamp-autotools-files
rm -rf debian/stamp-makefile-build
rm -rf debian/tmp/
rm -rf Data/ Languages.txt Topics.txt Menu.txt
}
realclean() {
cleanup
rm -rf lib/*
rm -rf bench/bin/*
rm -rf bench/src/*.o src/*.o src/drivers/*.o src/drivers/pg/*.o
}
builddocs() {
rm -rf Data/
rm -rf doc/{files2,index,index.html,javascript,search,styles,dbicpp*}
naturaldocs -i src/ -i inc/ -o HTML doc/ -s doc/Web -p .
if [ -e doc/files2/dbic++-h.html ]; then
mv doc/files2/dbic++-h.html doc/files2/dbicpp-h.html
fi
if [ -d doc/files2/dbic++ ]; then
mv doc/files2/dbic++ doc/files2/dbicpp
fi
for file in `grep -lr "dbic++/" doc/`; do sed -i 's/dbic++\//dbicpp\//g' $file; done
for file in `grep -lr "dbic++-h" doc/`; do sed -i 's/dbic++-h/dbicpp-h/g' $file; done
for file in `grep -lr "../files2" doc/`; do sed -i 's/..\/files2/../g' $file; done
mv doc/files2/* doc/
for file in `grep -lr "../../" doc/dbicpp`; do sed -i 's/\.\.\/\.\./../g' $file; done
for file in `grep -lr "../" doc/*.html`; do sed -i 's/\.\.\///g' $file; done
rm -f doc/index.html
cd doc && ln -s about-txt.html index.html && cd ..
for file in `find doc/ -type f -name "*.html"`; do
echo '<a href="http://github.com/deepfryed/dbicpp"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub" /></a>' >> $file
done
}
usage() {
echo "
$0 [options]
-h print this help message.
-d builds debian binary packages for local architecture.
-s builds debian source packages for this version.
-l builds and install libraries locally into lib (default).
-c cleanup all temporary files.
-i builds and installs dbic++ under /usr (root)
-u uninstall dbic++ stuff from /usr (root)
-r real clean - cleanups up build artifacts and local install files
-g generate HTML documentation using naturaldocs
"
}
_uninstall() {
rm -rf /usr/lib/libdbic++.a
rm -rf /usr/lib/dbic++
rm -rf /usr/include/dbic++*
}
_install() {
_uninstall
cmake -DCMAKE_PG_VERSION=$PG_VERSION \
-DCMAKE_MYSQL_VERSION=$MYSQL_VERSION \
-DCMAKE_SQLITE3_VERSION=$SQLITE3_VERSION \
-DCMAKE_INSTALL_PREFIX:PATH=/usr
make
make install
}
debian_binary_build() {
dpkg-buildpackage -rfakeroot -b
make clean
}
debian_source_build() {
PREFIX=dbic++-$(cat debian/changelog | head -n1 | grep -o "[0-9.]\+" | head -n1)
git archive --remote=$PWD --format=tar --prefix=$PREFIX/ HEAD | tar -C $PWD/.. -xvf -
cd $PWD/../$PREFIX
debuild -S -sa
}
local_build() {
cmake -DCMAKE_PG_VERSION=$PG_VERSION \
-DCMAKE_MYSQL_VERSION=$MYSQL_VERSION \
-DCMAKE_SQLITE3_VERSION=$SQLITE3_VERSION \
-DCMAKE_INSTALL_PREFIX:PATH=tmp/
make -j4
make install
rm -rf lib/*
mv tmp/lib/* lib/
rm -rf tmp/*
rm -f install_manifest.txt
}
while getopts "cdhilursg" OPTION
do
case $OPTION in
c) cleanup; exit 0;;
d) debian_binary_build; exit 0;;
l) local_build; exit 0;;
i) _install; exit 0;;
u) _uninstall; exit 0;;
r) realclean; exit 0;;
s) debian_source_build; exit 0;;
h) usage; exit 0;;
g) builddocs; exit 0;;
?) usage; exit 0;;
esac
done
local_build