cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

build-all.sh (3848B)


      1#!/bin/sh -e
      2#
      3# Licensed to the Apache Software Foundation (ASF) under one
      4# or more contributor license agreements.  See the NOTICE file
      5# distributed with this work for additional information
      6# regarding copyright ownership.  The ASF licenses this file
      7# to you under the Apache License, Version 2.0 (the
      8# "License"); you may not use this file except in compliance
      9# with the License.  You may obtain a copy of the License at
     10#
     11#   http://www.apache.org/licenses/LICENSE-2.0
     12#
     13# Unless required by applicable law or agreed to in writing,
     14# software distributed under the License is distributed on an
     15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     16# KIND, either express or implied.  See the License for the
     17# specific language governing permissions and limitations
     18# under the License.
     19#
     20
     21##
     22## @fn build-all.sh
     23##
     24## Builds the source of guacamole-server and its various core protocol library
     25## dependencies.
     26##
     27
     28# Pre-populate build control variables such that the custom build prefix is
     29# used for C headers, locating libraries, etc.
     30export CFLAGS="-I${PREFIX_DIR}/include"
     31export LDFLAGS="-L${PREFIX_DIR}/lib"
     32export PKG_CONFIG_PATH="${PREFIX_DIR}/lib/pkgconfig" 
     33
     34# Ensure thread stack size will be 8 MB (glibc's default on Linux) rather than
     35# 128 KB (musl's default)
     36export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=8388608"
     37
     38##
     39## Builds and installs the source at the given git repository, automatically
     40## switching to the version of the source at the tag/commit that matches the
     41## given pattern.
     42##
     43## @param URL
     44##     The URL of the git repository that the source should be downloaded from.
     45##
     46## @param PATTERN
     47##     The Perl-compatible regular expression that the tag must match. If no
     48##     tag matches the regular expression, the pattern is assumed to be an
     49##     exact reference to a commit, branch, etc. acceptable by git checkout.
     50##
     51## @param ...
     52##     Any additional command-line options that should be provided to CMake or
     53##     the configure script.
     54##
     55install_from_git() {
     56
     57    URL="$1"
     58    PATTERN="$2"
     59    shift 2
     60
     61    # Calculate top-level directory name of resulting repository from the
     62    # provided URL
     63    REPO_DIR="$(basename "$URL" .git)"
     64
     65    # Allow dependencies to be manually omitted with the tag/commit pattern "NO"
     66    if [ "$PATTERN" = "NO" ]; then
     67        echo "NOT building $REPO_DIR (explicitly skipped)"
     68        return
     69    fi
     70
     71    # Clone repository and change to top-level directory of source
     72    cd /tmp
     73    git clone "$URL"
     74    cd $REPO_DIR/
     75
     76    # Locate tag/commit based on provided pattern
     77    VERSION="$(git tag -l --sort=-v:refname | grep -Px -m1 "$PATTERN" \
     78        || echo "$PATTERN")"
     79
     80    # Switch to desired version of source
     81    echo "Building $REPO_DIR @ $VERSION ..."
     82    git -c advice.detachedHead=false checkout "$VERSION"
     83
     84    # Configure build using CMake or GNU Autotools, whichever happens to be
     85    # used by the library being built
     86    if [ -e CMakeLists.txt ]; then
     87        cmake -DCMAKE_INSTALL_PREFIX:PATH="$PREFIX_DIR" "$@" .
     88    else
     89        [ -e configure ] || autoreconf -fi
     90        ./configure --prefix="$PREFIX_DIR" "$@"
     91    fi
     92
     93    # Build and install
     94    make && make install
     95
     96}
     97
     98#
     99# Build and install core protocol library dependencies
    100#
    101
    102install_from_git "https://github.com/FreeRDP/FreeRDP" "$WITH_FREERDP" $FREERDP_OPTS
    103install_from_git "https://github.com/libssh2/libssh2" "$WITH_LIBSSH2" $LIBSSH2_OPTS
    104install_from_git "https://github.com/seanmiddleditch/libtelnet" "$WITH_LIBTELNET" $LIBTELNET_OPTS
    105install_from_git "https://github.com/LibVNC/libvncserver" "$WITH_LIBVNCCLIENT" $LIBVNCCLIENT_OPTS
    106install_from_git "https://github.com/warmcat/libwebsockets" "$WITH_LIBWEBSOCKETS" $LIBWEBSOCKETS_OPTS
    107
    108#
    109# Build guacamole-server
    110#
    111
    112cd "$BUILD_DIR"
    113autoreconf -fi && ./configure --prefix="$PREFIX_DIR" $GUACAMOLE_SERVER_OPTS
    114make && make install
    115