-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-env
executable file
·203 lines (175 loc) · 3.66 KB
/
setup-env
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/sh
# On FreeBSD:
# pkg install autotools
#
# On Linux:
# apt-get update
# apt-get install autotools-dev autoconf libtool
# or apt-get install build-essential
#
# yum install epel-release
# yum group install "Development Tools"
# yum install openssl-devel zlib-devel libev-devel
#
# Git setup:
# git init
# git add \
# .gitignore \
# AUTHORS \
# COPYING \
# ChangeLog \
# Makefile.am \
# NEWS \
# README \
# configure.ac \
# man/Makefile.am \
# setup-env \
# src/${pname}.c \
# src/${pname}.h \
# src/${pname}_private.h \
# src/Makefile.am \
# src/diag.txt \
# test/Makefile.am \
# test/diag.txt \
# test/gendata.c \
# test/runscripts \
# test/testbar.c \
# test/testfoo.c \
# test/unittest.h
_run() {
echo "running $@ ..."
eval "$@" >/dev/null 2>&1
}
die() {
echo $*
exit 1
}
do_init() {
_run autoreconf --force
if test $? -ne 0
then
if test -e .ac-aux/missing
then
die fix your errors
fi
fi
_run aclocal
_run autoheader
_run autoreconf
_run automake --add-missing --force-missing
_run libtoolize
_run make distclean
_run autoreconf
./configure --prefix=$HOME --enable-debug
}
do_dev() {
autoreconf --force
./configure --prefix=$HOME --enable-debug
}
do_dev_notest() {
autoreconf --force
./configure --prefix=$HOME --enable-debug --with-tests=no
}
do_dev_static() {
autoreconf --force
./configure --prefix=$HOME --enable-debug --enable-allstatic
}
do_dev_ndebug() {
autoreconf --force
./configure --prefix=$HOME
}
do_dev_ndebug_static() {
autoreconf --force
./configure --prefix=$HOME --enable-allstatic --enable-lto
}
uname_s=`uname -s`
sha256_cmd=/sbin/sha256
if test "$uname_s" = "Linux"
then
linux_exclusions='--enable-conf=no'
sha256_cmd=/usr/bin/sha256sum
elif test "$uname_s" = "Darwin"
then
linux_exclusions='--enable-memdebug=no'
fi
dirs="."
R=`pwd -P`
LDFLAGS=
for i in $dirs
do
LDFLAGS="$LDFLAGS -L${R}/$i/src/.libs"
done
LDFLAGS="$LDFLAGS -L$HOME/lib -L/usr/local/lib"
export LDFLAGS
CFLAGS=
for i in $dirs
do
CFLAGS="$CFLAGS -I${R}/$i/src"
done
CFLAGS="$CFLAGS -I$HOME/include -I/usr/local/include"
export CFLAGS
if test "$1" = "init"
then
for i in $dirs
do
( cd $i && do_init )
done
elif test "$1" = "dev"
then
for i in $dirs
do
( cd $i && do_dev )
done
elif test "$1" = "dev-notest"
then
for i in $dirs
do
( cd $i && do_dev_notest )
done
elif test "$1" = "dev-static"
then
for i in $dirs
do
( cd $i && do_dev_static )
done
elif test "$1" = "dev-ndebug"
then
for i in $dirs
do
( cd $i && do_dev_ndebug )
done
elif test "$1" = "dev-ndebug-static"
then
for i in $dirs
do
( cd $i && do_dev_ndebug_static )
done
elif test "$1" = "dist"
then
unset LDFLAGS
unset CFLAGS
autoreconf --force
./configure --enable-profile=no $linux_exclusions $MN_CONFIGURE_ARGS
make dist
if test -f port/distinfo
then
truncate -s0 port/distinfo
fi
if test -d /data0/mkushnir/distfiles
then
for i in *.tar.gz
do
cp -v $i /data0/mkushnir/distfiles/
if test -f port/distinfo
then
$sha256_cmd $i >port/distinfo
echo "SIZE ($i) = `stat -f%z $i`" >>port/distinfo
fi
done
fi
elif test "$1" = "du"
then
find . -type f -name '*.[ch]' -ls | awk '{print $7;}' | (n=0; while read a; do n=$((n + a)); done; echo $n)
else
echo "`basename $0` {init|dev|dist|dev-ndebug|dev-memdebug|du}"
fi