#!/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.11.tar.bz2 LIBGPG_ERROR_SRCDIR=libgpg-error-1.11 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_URL=git://git.gnupg.org/libgcrypt.git if ! [ -d "downloads/libgcrypt" ]; then git clone "$LIBGCRYPT_URL" downloads/libgcrypt || die "Unable to clone libgcrypt git repository" fi cd gnunet git clone ../downloads/libgcrypt libgcrypt || die "Unable to clone libgcrypt git repository" cd libgcrypt patch -p1 < ../../patches/libgcrypt.patch automake --add-missing ./autogen.sh || die "Uanble to autogen libgcrypt" emconfigure ./configure --enable-maintainer-mode \ --prefix="$SYSROOT" \ --disable-asm \ --disable-avx-support \ --disable-avx2-support \ --with-gpg-error-prefix="$SYSROOT" \ 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.27.tar.gz LIBIDN_SRCDIR=libidn-1.27 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 ./libtool --tag=CC --mode=link \ emcc -fno-strict-aliasing -Wall "-I$SYSROOT/include" "-L$SYSROOT/lib" \ -o src/peerinfo/gnunet-service-peerinfo.js \ src/peerinfo/gnunet-service-peerinfo.o \ src/hello/libgnunethello.la \ src/statistics/libgnunetstatistics.la \ src/util/libgnunetutil.la \ "$SYSROOT/lib/libgcrypt.la" \ "$SYSROOT/lib/libgpg-error.la" \ -lm -lsocket \ --js-library "$BUILDROOT/configuration.js" \ --js-library "$BUILDROOT/scheduler.js" \ --js-library "$BUILDROOT/server.js" \ --js-library "$BUILDROOT/service.js" \ --pre-js "$BUILDROOT/pre.js" cp src/peerinfo/.libs/gnunet-service-peerinfo.js \ "$BUILDROOT/resources/public/js/" cd "$BUILDROOT" # vim: set expandtab ts=2 sw=2: