aboutsummaryrefslogtreecommitdiff
path: root/build-gnunet.sh
blob: 40349a52785962186d9a0e1d5d3479b3fe84ed5a (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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/sh

die() {
  printf "%s\n" "$1"
  exit 1
}

BUILDROOT="$(pwd)"
SYSROOT="$BUILDROOT/gnunet/sysroot"
mkdir -p "$SYSROOT"

# Build libgpg-error
LIBGPG_ERROR_TBZ2=libgpg-error-1.12.tar.bz2
LIBGPG_ERROR_SRCDIR=libgpg-error-1.12
LIBGPG_ERROR_URL=ftp://ftp.gnupg.org/gcrypt/libgpg-error/$LIBGPG_ERROR_TBZ2
if ! [ -f "downloads/$LIBGPG_ERROR_TBZ2" ]; then
  wget -P downloads "$LIBGPG_ERROR_URL" ||
    die "Unable to download $LIBGPG_ERROR_TBZ2"
fi

cd gnunet
tar -jxf "../downloads/$LIBGPG_ERROR_TBZ2" ||
  die "Unable to extract $LIBGPG_ERROR_TBZ2"
cd "$LIBGPG_ERROR_SRCDIR"
# Build libgpg-error first using build system tools to produce generated
# header files.
./configure --disable-nls ||
  die "Unable to configure libgpg-error"
make ||
  die "Unable to make libgpg-error"
# Build again with emscripten, keeping generated files fresh so make won't
# rebuild them.
emconfigure ./configure --prefix="$SYSROOT" \
  --disable-nls ||
  die "Unable to emconfigure libgpg-error"
touch src/mkerrcodes.h
touch src/mkerrcodes
touch src/code-from-errno.h
touch src/gpg-error.def
emmake make ||
  die "Unable to emmake libgpg-error"
EMMAKEN_JUST_CONFIGURE=true EMCONFIGURE_JS=true emmake make check ||
  die "libgpg-error tests failed"
emmake make install ||
  die "Unable to install libgpg-error"
cd "$BUILDROOT"

# Build libgcrypt
LIBGCRYPT_TBZ2=libgcrypt-1.6.0.tar.bz2
LIBGCRYPT_SRCDIR=libgcrypt-1.6.0
LIBGCRYPT_URL=ftp://ftp.gnupg.org/gcrypt/libgcrypt/$LIBGCRYPT_TBZ2
if ! [ -f "downloads/$LIBGCRYPT_TBZ2" ]; then
  wget -P downloads "$LIBGCRYPT_URL" ||
    die "Unable to download $LIBGCRYPT_TBZ2"
fi

cd gnunet
tar -jxf "../downloads/$LIBGCRYPT_TBZ2" ||
  die "Unable to extract $LIBGCRYPT_TBZ2"
cd "$LIBGCRYPT_SRCDIR"
patch -p1 < ../../patches/libgcrypt.patch
automake --add-missing
./autogen.sh ||
  die "Uanble to autogen libgcrypt"
emconfigure ./configure --enable-maintainer-mode \
  --prefix="$SYSROOT" \
  --disable-threads \
  --disable-asm \
  --disable-avx-support \
  --disable-avx2-support \
  --disable-amd64-as-feature-detection \
  --with-gpg-error-prefix="$SYSROOT" \
  ac_cv_sizeof_unsigned_short=2 \
  ac_cv_sizeof_unsigned_int=4 \
  ac_cv_sizeof_unsigned_long=4 \
  ac_cv_sizeof_unsigned_long_long=8 \
  ac_cv_func_syslog=no \
  ac_cv_func_mlock=no \
  gnupg_cv_mlock_is_in_sys_mman=no ||
  die "Unable to emconfigure libgcrypt"
emmake make SUBDIRS="compat mpi cipher random src" \
  LDFLAGS=-Wc,--ignore-dynamic-linking ||
  die "Unable to emmake libgcrypt"
#emmake make SUBDIRS="tests" ||
#  die "Unable to emmake tests"
#touch tests/*.o
#EMMAKEN_JUST_CONFIGURE=true EMCONFIGURE_JS=true emmake make check \
#  SUBDIRS="tests" \
#  LDFLAGS=-Wc,-s,TOTAL_MEMORY=33554432 ||
#  die "Unable to emmake check"
emmake make install SUBDIRS="compat mpi cipher random src" ||
  die "Unable to install libgcrypt"
cd "$BUILDROOT"

# Build libunistring
LIBUNISTRING_TGZ=libunistring-0.9.3.tar.gz
LIBUNISTRING_SRCDIR=libunistring-0.9.3
LIBUNISTRING_URL=http://ftp.gnu.org/gnu/libunistring/$LIBUNISTRING_TGZ
if ! [ -f "downloads/$LIBUNISTRING_TGZ" ]; then
  wget -P downloads "$LIBUNISTRING_URL" ||
    die "Unable to download $LIBUNISTRING_TGZ"
fi

cd gnunet
tar -zxf "../downloads/$LIBUNISTRING_TGZ" ||
  die "Unable to extract $LIBUNISTRING_TGZ"
cd "$LIBUNISTRING_SRCDIR"
patch -p1 < ../../patches/libunistring-0.9.3.patch
emconfigure ./configure --prefix="$SYSROOT" \
  --disable-threads \
  ac_cv_func_uselocale=no \
  am_cv_func_iconv=no ||
  die "Unable to emconfigure libunistring"
emmake make ||
  die "Unable to emmake libunistring"
emmake make install ||
  die "Unable to install libunistring"
cd "$BUILDROOT"

# Build zlib
ZLIB_TGZ=zlib-1.2.8.tar.gz
ZLIB_SRCDIR=zlib-1.2.8
ZLIB_URL=http://zlib.net/$ZLIB_TGZ
if ! [ -f "downloads/$ZLIB_TGZ" ]; then
  wget -P downloads "$ZLIB_URL" ||
    die "Unable to download $ZLIB_TGZ"
fi

cd gnunet
tar -zxf "../downloads/$ZLIB_TGZ" ||
  die "Unable to extract $ZLIB_TGZ"
cd "$ZLIB_SRCDIR"
emconfigure ./configure --prefix="$SYSROOT" ||
  die "Unable to emconfigure zlib"
emmake make ||
  die "Unable to emmake zlib"
emmake make install ||
  die "Unable to install zlib"
cd "$BUILDROOT"

# Build libidn
LIBIDN_TGZ=libidn-1.28.tar.gz
LIBIDN_SRCDIR=libidn-1.28
LIBIDN_URL=http://ftp.gnu.org/gnu/libidn/$LIBIDN_TGZ
if ! [ -f "downloads/$LIBIDN_TGZ" ]; then
  wget -P downloads "$LIBIDN_URL" ||
    die "Unable to download $LIBIDN_TGZ"
fi

cd gnunet
tar -zxf "../downloads/$LIBIDN_TGZ" ||
  die "Unable to extract $LIBIDN_TGZ"
cd "$LIBIDN_SRCDIR"
patch -p1 < ../../patches/libidn-1.27.patch
emconfigure ./configure --prefix="$SYSROOT" ||
  die "Unable to emconfigure libidn"
emmake make ||
  die "Unable to emmake libidn"
emmake make install ||
  die "Unable to install libidn"
cd "$BUILDROOT"

# Build libltdl
LIBTOOL_TGZ=libtool-1.5.26.tar.gz
LIBTOOL_SRCDIR=libtool-1.5.26
LIBTOOL_URL=http://ftpmirror.gnu.org/libtool/$LIBTOOL_TGZ
if ! [ -f "downloads/$" ]; then
  wget -P downloads "$LIBTOOL_URL" ||
    die "Unable to download $LIBTOOL_TGZ"
fi

cd gnunet
tar -zxf "../downloads/$LIBTOOL_TGZ" ||
  die "Unable to extract $LIBTOOL_TGZ"
cd "$LIBTOOL_SRCDIR"
emconfigure ./configure --prefix="$SYSROOT" \
  ac_cv_func_argz_append=no \
  ac_cv_func_argz_create_sep=no \
  ac_cv_func_argz_insert=no \
  ac_cv_func_argz_next=no \
  ac_cv_func_argz_stringify=no ||
  die "Unable to emconfigure libltdl"
emmake make ||
  die "Unable to emmake libltdl"
emmake make install ||
  die "Unable to install libltdl"
cd "$BUILDROOT"

# Build fake libextractor
cd fake-extractor
emmake make ||
  die "Unable to make fake libextractor"
emmake make install DESTDIR="$SYSROOT" ||
  die "Unable to install fake libextractor"
cd "$BUILDROOT"

# Build GNUnet
GNUNET_URL=https://gnunet.org/svn/gnunet
if ! [ -d "downloads/gnunet" ]; then
  svn co "$GNUNET_URL" downloads/gnunet ||
    die "Unable to checkout GNUnet svn repository"
fi

cd gnunet
cp -r ../downloads/gnunet gnunet ||
  die "Unable to copy GNUnet repository"
cd gnunet
patch -p0 < ../../patches/gnunet.patch
./bootstrap ||
  die "Unable to bootstrap GNUnet"
EMCONFIGURE_JS=1 emconfigure ./configure --prefix="$SYSROOT" \
  --with-libgcrypt-prefix="$SYSROOT" \
  --with-libunistring-prefix="$SYSROOT" \
  --with-zlib="$SYSROOT" \
  --with-extractor="$SYSROOT" \
  --with-ltdl="$SYSROOT" \
  --with-libidn="$SYSROOT" \
  --without-libcurl \
  --disable-testing \
  ac_cv_lib_idn_stringprep_check_version=yes ||
  die "Unable to configure GNUnet"
emmake make \
  LDFLAGS=-Wc,--ignore-dynamic-linking ||
  die "Unable to make GNUnet"
# Link gnunet services and install them into resources/public/js
mkdir -p "$BUILDROOT/resources/public/js"
./libtool --tag=CC --mode=link \
  emcc -fno-strict-aliasing -Wall "-I$SYSROOT/include" "-L$SYSROOT/lib" \
  -o src/transport/gnunet-service-transport.js \
  src/transport/gnunet_service_transport-gnunet-service-transport*.o \
  src/ats/libgnunetats.la \
  src/hello/libgnunethello.la \
  src/peerinfo/libgnunetpeerinfo.la \
  src/statistics/libgnunetstatistics.la \
  src/util/libgnunetutil.la \
  "$SYSROOT/lib/libgcrypt.la" \
  "$SYSROOT/lib/libgpg-error.la" \
  -lm -lsocket \
  --js-library "$BUILDROOT/src/js/client.js" \
  --js-library "$BUILDROOT/src/js/configuration.js" \
  --js-library "$BUILDROOT/src/js/scheduler.js" \
  --js-library "$BUILDROOT/src/js/server.js" \
  --js-library "$BUILDROOT/src/js/service.js" \
  --pre-js "$BUILDROOT/src/js/pre.js"
cp src/transport/.libs/gnunet-service-transport.js \
  "$BUILDROOT/resources/public/js/"
./libtool --tag=CC --mode=link \
  emcc -fno-strict-aliasing -Wall "-I$SYSROOT/include" "-L$SYSROOT/lib" \
  -o src/ats/gnunet-service-ats.js \
  src/ats/gnunet-service-ats*.o \
  src/ats/libgnunetats.la \
  src/statistics/libgnunetstatistics.la \
  src/util/libgnunetutil.la \
  "$SYSROOT/lib/libgcrypt.la" \
  "$SYSROOT/lib/libgpg-error.la" \
  -lm -lsocket \
  --js-library "$BUILDROOT/src/js/client.js" \
  --js-library "$BUILDROOT/src/js/configuration.js" \
  --js-library "$BUILDROOT/src/js/scheduler.js" \
  --js-library "$BUILDROOT/src/js/server.js" \
  --js-library "$BUILDROOT/src/js/service.js" \
  --pre-js "$BUILDROOT/src/js/pre.js"
cp src/ats/.libs/gnunet-service-ats.js \
  "$BUILDROOT/resources/public/js/"
# Copy HELLOs for dev webserver
cat contrib/hellos/* > "$BUILDROOT/resources/public/hostlist"
cd "$BUILDROOT"

# vim: set expandtab ts=2 sw=2: