#!/bin/bash

if [ -f /usr/local/bin/python ]
then
  export PATH="/usr/local/bin:$PATH"
fi

target=`uname`
if [ -z "${CC}" ]; then
  CC="cc"
fi
if [ -z "${CXX}" ]; then
  CXX="c++"
fi
while [ $# -gt 0 ]
do
  eval $1
  shift
done
wxdefs=""
qt4defs=""
qt5defs=""
if [ "`uname -m`" = "x86_64" ]; then
  qt_lib_suffix="64"
  qt_arch="x86_64"
else
  qt_lib_suffix=""
  qt_arch="i386"   # using 'uname -p' does not work in that case; for ubuntu it returns i686, but i386 is set as path prefix
fi
qt4_qmake_names=("qmake-qt4" "qmake")
qt4_qmake_dirs=("/usr/lib/${qt_arch}-linux-gnu/qt4/bin" "/usr/bin" "/usr/lib${qt_lib_suffix}/qt4/bin")
qt5_qmake_names=("qmake-qt5" "qmake")
qt5_qmake_dirs=("/usr/lib/${qt_arch}-linux-gnu/qt5/bin" "/usr/bin" "/usr/lib${qt_lib_suffix}/qt5/bin")
gtkdefs=""
x11defs=""
xftdefs=""
gsdefs=""
glfwdefs=""
zmqdefs=""
avdefs=""
mupdfdefs=""
cairodefs=""
ssldefs=""
extradefs=""
if [ `uname` = "Darwin" ]; then
  if [ -z "${EXTRA_CFLAGS}" ]; then
    EXTRA_CFLAGS="-I/usr/local/include"
  fi
  if [ -z "${EXTRA_CXXFLAGS}" ]; then
    EXTRA_CXXFLAGS="-I/usr/local/include"
  fi
  if [ -z "${EXTRA_LDFLAGS}" ]; then
    EXTRA_LDFLAGS="-L/usr/local/lib"
  fi
fi
if [ ! -z "${EXTRA_CFLAGS}" ]; then
  extradefs="EXTRA_CFLAGS=$EXTRA_CFLAGS"
fi
if [ ! -z "${EXTRA_CXXFLAGS}" ]; then
 extradefs="$extradefs EXTRA_CXXFLAGS=$EXTRA_CXXFLAGS"
fi
if [ ! -z "${EXTRA_LDFLAGS}" ]; then
  extradefs="$extradefs EXTRA_LDFLAGS=$EXTRA_LDFLAGS"
fi
ret=0

red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
normal=$(tput sgr0)

printf "\nBuilding GR Framework\n---------------------\n" >&2

if [ "`which ${CC} 2>/dev/null`" = "" ]
then
  info="${red} no${normal} [not found]"
else
  info="${green}yes${normal} [`${CC} --version | sed 's/) (/ /' | head -1`]"
fi
printf "%12s: %s\n" "C" "$info" >&2

if [ "`which ${CXX} 2>/dev/null`" = "" ]
then
  info="${red} no${normal} [not found]"
else
  info="${green}yes${normal} [`${CXX} --version | sed 's/) (/ /' | head -1`]"
fi
printf "%12s: %s\n" "C++" "$info" >&2

if [ "`which python 2>/dev/null`" = "" ]
then
  info="${red} no${normal} [not found]"
else
  info="${green}yes${normal} [version `python -c 'import sys;print sys.version' | head -1`]"
fi
printf "%12s: %s\n" "Python" "$info" >&2

if [ "`which latex 2>/dev/null`" = "" ]
then
  info="${red} no${normal} [not found]"
else
  info="${green}yes${normal} [version `latex --version|grep ^pdfTeX|awk '{print $2}'`]"
fi
printf "%12s: %s\n" "LaTeX" "$info" >&2

if [ "`which dvipng 2>/dev/null`" = "" ]
then
  info="${red} no${normal} [not found]"
else
  info="${green}yes${normal} [version `dvipng --version|grep ^dvipng|awk '{print $NF}'`]"
fi
printf "%12s: %s\n" "dvipng" "$info" >&2

if [ "$qt" != "no" ]
then
  for qt_major_version in 4 5
  do
    eval current_qt="$qt${qt_major_version}"
    if [ "${current_qt}" != "no" ]
    then
      found_qmake=false
      eval qmake_path="\${QT${qt_major_version}_QMAKE}"
      if [ "${qmake_path}" != "" ]
      then
        if [ -x "${qmake_path}" ] || [ "`which ${qmake_path} 2>/dev/null`" != "" ]
        then
          qmake_qt_version="`${qmake_path} -query QT_VERSION 2>/dev/null`"
          if [ "${qmake_qt_version%%.*}" = "${qt_major_version}" ]
          then
            found_qmake=true
          fi
        fi
      else
        eval current_qmake_names=( "\${qt${qt_major_version}_qmake_names[@]}" )
        eval current_qmake_dirs=( "\${qt${qt_major_version}_qmake_dirs[@]}" )
        for qmake_name in "${current_qmake_names[@]}"
        do
          if [ "`which ${qmake_name} 2>/dev/null`" != "" ]
          then
            qmake_qt_version="`${qmake_name} -query QT_VERSION 2>/dev/null`"
            if [ "${qmake_qt_version%%.*}" = "${qt_major_version}" ]
            then
              found_qmake=true
              qmake_path="${qmake_name}"
              break
            fi
          fi
        done
        if [ "${found_qmake}" = "false" ]
        then
          for qmake_dir in "${current_qmake_dirs[@]}"
          do
            for qmake_name in "${current_qmake_names[@]}"
            do
              qmake_path="${qmake_dir}/${qmake_name}"
              if [ -x "${qmake_path}" ]
              then
                qmake_qt_version="`${qmake_path} -query QT_VERSION 2>/dev/null`"
                if [ "${qmake_qt_version%%.*}" = "${qt_major_version}" ]
                then
                  found_qmake=true
                  break
                fi
              fi
            done
            if [ "${found_qmake}" = "true" ]
            then
              break
            fi
          done
        fi
      fi
      if [ "${found_qmake}" = "false" ]
      then
        info="${red} no${normal} [Qt${qt_major_version} API not found]"
        eval qt${qt_major_version}defs="QT${qt_major_version}_QMAKE=false\ QT${qt_major_version}DEFS=-DNO_QT${qt_major_version}"
        ret=1
      else
        info="${green}yes${normal} [version ${qmake_qt_version}]"
        eval qt${qt_major_version}defs="QT${qt_major_version}_QMAKE=${qmake_path}"
      fi
    else
      eval qt${qt_major_version}defs="QT${qt_major_version}_QMAKE=false\ QT${qt_major_version}DEFS=-DNO_QT${qt_major_version}"
      info="${yellow} no${normal} [disabled]"
      ret=1
    fi
    printf "%12s: %s\n" "Qt${qt_major_version}" "$info" >&2
  done
fi

if [ "$wx" != "no" ]
then
  wxconfig=wx-config
  if [ "$WX_CONFIG" != "" ]
  then
    wxconfig=$WX_CONFIG
  fi
  if [ "`which $wxconfig 2>/dev/null`" = "" ]
  then
    wxdefs="WX_CONFIG=false WXDEFS=-DNO_WX WXINC= WXLIBS="
    info="${red} no${normal} [wx-config not found]"
    ret=1
  else
    wxdefs="WX_CONFIG=$wxconfig"
    info="${green}yes${normal} [version `wx-config --version`]"
  fi
else
  wxdefs="WX_CONFIG=false WXDEFS=-DNO_WX WXINC= WXLIBS="
  info="${yellow} no${normal} [disabled]"
  ret=1
fi
printf "%12s: %s\n" "wxWidgets" "$info" >&2

if [ "$gtk" != "no" ]
then
  if [ "`pkg-config gtk+-2.0 --cflags 2>/dev/null`" = "" ]
  then
    gtkdefs="GTK_CONFIG=false GTKDEFS=-DNO_GTK GTKINC= GTKLIBS="
    info="${red} no${normal} [gtk+-2.0 not found]"
    ret=1
  else
    gtkdefs="GTK_CONFIG=pkg-config"
    info="${green}yes${normal} [version `pkg-config gtk+-2.0 --modversion`]"
  fi
else
  gtkdefs="GTK_CONFIG=false GTKDEFS=-DNO_GTK GTKINC= GTKLIBS="
  info="${yellow} no${normal} [disabled]"
  ret=1
fi
printf "%12s: %s\n" "GTK+" "$info" >&2

if [ "$x11" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  cat >$tmpsrc << eof
#include <X11/Intrinsic.h>

int main(int argc, char **argv)
{
    Widget toplevel;
    toplevel = XtInitialize(argv[0], "simple", NULL, 0, &argc, argv);
    XtMainLoop();
    return 0;
}
eof
  if [ `uname` = "Darwin" ]; then
    x11path="/opt/X11"
  elif [ -d /usr/X11R6 ]; then
    x11path="/usr/X11R6"
  else
    x11path="/usr/X11"
  fi
  cmd="${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -I$x11path/include -L$x11path/lib -lXt -lX11"
  $cmd >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    x11defs="X11DEFS=-DNO_X11 X11INC= X11LIBS="
    info="${red} no${normal} [X11 API not found]"
    ret=1
  else
    x11defs="X11PATH=-L$x11path/lib"
    info="${green}yes${normal} [$x11path]"
  fi
else
  x11defs="X11DEFS=-DNO_X11 X11INC= X11LIBS="
  info="${yellow} no${normal} [disabled]"
  xft="no"
  gs="no"
  ret=1
fi
printf "%12s: %s\n" "X11" "$info" >&2
rm -f $tmpout $tmpsrc
if [ `uname` = "Darwin" ]; then
  dir=`dirname $0`
  if [ $ret -eq 0 ]; then
    cp -p $dir/gks/quartz/project.pbxproj.X11 lib/gks/quartz/GKSTerm.xcodeproj/project.pbxproj
  else
    cp -p $dir/gks/quartz/project.pbxproj lib/gks/quartz/GKSTerm.xcodeproj/project.pbxproj
  fi
fi

if [ "$xft" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmpver=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <stdio.h>
#include <X11/Xft/Xft.h>
int main(void)
{
    printf("%d.%d.%d\n", XFT_MAJOR, XFT_MINOR, XFT_REVISION);
    return 0;
}
eof
  cmd="${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -I$x11path/include `freetype-config --cflags 2>/dev/null`"
  $cmd >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    xftdefs="XFTDEFS=-DNO_XFT XFTLIBS="
    info="${red} no${normal} [Xft API not found]"
    ret=1
  else
    $tmpout >$tmpver 2>&1
    info="${green}yes${normal} [version `cat $tmpver`]"
  fi
else
  xftdefs="XFTDEFS=-DNO_XFT XFTLIBS="
  info="${yellow} no${normal} [disabled]"
  ret=1
fi
printf "%12s: %s\n" "Xft" "$info" >&2
rm -f $tmpout $tmpsrc $tmpver

if [ "$gs" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmprev=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <stdio.h>
#include <stdlib.h>
#include <ghostscript/iapi.h>

int main()
{
    gsapi_revision_t r;
    if (gsapi_revision(&r, sizeof(gsapi_revision_t)) == 0)
        fprintf(stderr, "%ld\n", r.revision);
    exit(0);
}
eof
  cmd="${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -lgs"
  if [ `uname` = "Darwin" ]; then
    cmd="$cmd -L/usr/X11/lib -lXt -lX11 -liconv"
  fi
  $cmd >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    gsdefs="GSDEFS=-DNO_GS GSINC= GSLIBS="
    info="${red} no${normal} [GS API not found]"
    ret=1
  else
    $tmpout >$tmprev 2>&1
    info="${green}yes${normal} [revision `cat $tmprev`]"
  fi
else
  gsdefs="GSDEFS=-DNO_GS GSINC= GSLIBS="
  info="${yellow} no${normal} [disabled]"
  ret=1
fi
printf "%12s: %s\n" "Ghostscript" "$info" >&2
rm -f $tmpout $tmpsrc $tmprev

if [ "$glfw" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmpver=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <stdio.h>
#include <GLFW/glfw3.h>

int main(void)
{
    if (!glfwInit())
        return -1;
    fprintf(stderr, "%d.%d.%d\n", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR,
        GLFW_VERSION_REVISION);
    return 0;
}
eof
  cmd="${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc"
  if [ `uname` = "Darwin" ]; then
    libs="-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo"
    ret=1
  else
    libs="-lGL -lXrandr -lXxf86vm -lXinerama -lXcursor -lXi -lX11 -lrt -lpthread -lm"
  fi
  glfwlib="glfw3"
  $cmd -l$glfwlib $libs >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    glfwlib="glfw"
    $cmd -l$glfwlib $libs >/dev/null 2>&1
  fi
  if [ $? -ne 0 ]; then
    glfwdefs="GLFWDEFS=-DNO_GLFW GLFWLIBS="
    info="${red} no${normal} [GLFW 3.x API not found]"
    ret=1
  else
    glfwdefs="GLFWLIB=$glfwlib"
    $tmpout >$tmpver 2>&1
    info="${green}yes${normal} [version `cat $tmpver`]"
  fi
else
  glfwdefs="GLFWDEFS=-DNO_GLFW GLFWLIBS="
  info="${yellow} no${normal} [disabled]"
  ret=1
fi
printf "%12s: %s\n" "GLFW" "$info" >&2
rm -f $tmpout $tmpsrc $tmpver

if [ "$zmq" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmpver=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <stdio.h>
#include <zmq.h>

int main(void)
{
    void *context = zmq_ctx_new();
    void *publisher = zmq_socket(context, ZMQ_PUSH);
    if (0) {
        zmq_bind(publisher, "tcp://*:5556");
        zmq_send(publisher, "Hello", 5, 0);
    }
    zmq_close(publisher);
    zmq_ctx_destroy(context);
    fprintf(stderr, "%d.%d.%d\n", ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR,
        ZMQ_VERSION_PATCH);
    return 0;
}
eof
  cmd="${CXX} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -lzmq -lpthread"
  if [ `uname` != "Darwin" ]; then
    cmd="${cmd} -lrt"
  fi
  $cmd >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    zmqdefs="ZMQDEFS=-DNO_ZMQ ZMQLIBS="
    info="${red} no${normal} [0MQ 3.x API not found]"
    ret=1
  else
    $tmpout >$tmpver 2>&1
    info="${green}yes${normal} [version `cat $tmpver`]"
  fi
else
  info="${yellow} no${normal} [disabled]"
  zmqdefs="ZMQDEFS=-DNO_ZMQ ZMQLIBS="
  ret=1
fi
printf "%12s: %s\n" "0MQ" "$info" >&2
rm -f $tmpout $tmpsrc $tmpver

if [ "$av" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmpver=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/mathematics.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>

int main(void)
{
   avcodec_register_all();
   exit(0);
}
eof
  cmd="${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -lavdevice -lavformat -lavfilter -lavcodec -lswscale -lavutil -ltheora -logg -lvpx -lz"
  if [ `uname` = "Linux" ]
  then
    cmd="$cmd -lpthread -lm"
  elif [ `uname` = "Darwin" ]
  then
    cmd="$cmd -liconv"
  fi
  $cmd >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    avdefs="AVDEFS=-DNO_AV AVLIBS="
    info="${red} no${normal} [required APIs not found]"
    ret=1
  else
    if [ "`which ffmpeg 2>/dev/null`" != "" ]
    then
      ffmpeg -version >$tmpver 2>&1
    else
      cat /dev/null >$tmpver
    fi
    info="${green}yes${normal} [`cat $tmpver | head -1`]"
  fi
else
  avdefs="AVDEFS=-DNO_AV AVLIBS="
  info="${yellow} no${normal} [disabled]"
  ret=1
fi
printf "%12s: %s\n" "ffmpeg" "$info" >&2
rm -f $tmpsrc $tmpout $tmpver

if [ "$mupdf" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmpver=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <stdio.h>
#include <mupdf/fitz.h>

int main(int argc, char **argv)
{
#ifdef FZ_VERSION
  printf("%s\n", FZ_VERSION);
#else
  printf("unknown\n");
#endif
}
eof
  ${CC} -o $tmpout $tmpsrc >/dev/null 2>&1
  $tmpout >$tmpver 2>&1
  case `cat $tmpver` in
  1.7*)
    MUPDF_CFLAGS=-DMUPDF_API_VERSION_17
    mupdfdefs="MUPDFDEFS=${MUPDF_CFLAGS}"
    ;;
  *)
    MUPDF_CFLAGS=""
    mupdfdefs=""
  esac
  cat >$tmpsrc << eof
#include <stdio.h>
#include <mupdf/fitz.h>

int main(int argc, char **argv)
{
  fz_context  *ctx;
  fz_document *doc;
  fz_rect      rect;
  fz_irect     bbox;
  fz_pixmap   *pix;
  fz_device   *dev;
  fz_page     *page;

  ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
  fz_register_document_handlers(ctx);
  doc = fz_open_document(ctx, argv[1]);
#ifdef MUPDF_API_VERSION_17
  page = fz_load_page(ctx, doc, 0);
  fz_bound_page(ctx, page, &rect);
#else
  page = fz_load_page(doc, 0);
  fz_bound_page(doc, page, &rect);
#endif
  fz_round_rect(&bbox, &rect);
  pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &bbox);
  dev = fz_new_draw_device(ctx, pix);
#ifdef MUPDF_API_VERSION_17
  fz_run_page(ctx, page, dev, &fz_identity, NULL);
  fz_drop_device(ctx, dev);
#else
  fz_run_page(doc, page, dev, &fz_identity, NULL);
  fz_free_device(dev);
#endif
  fz_drop_pixmap(ctx, pix);
#ifdef MUPDF_API_VERSION_17
  fz_drop_page(ctx, page);
  fz_drop_document(ctx, doc);
  fz_drop_context(ctx);
#else
  fz_free_page(doc, page);
  fz_close_document(doc);
  fz_free_context(ctx);
#endif

#ifdef FZ_VERSION
  fprintf(stderr, "version %s\n", FZ_VERSION);
#endif
}
eof
  libs="-lz -lm"
  cmd="${CC} ${MUPDF_CFLAGS} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -lmupdf -lfreetype -ljbig2dec -ljpeg -lopenjp2"
  $cmd $libs >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    $cmd -lssl -lcrypto $libs >/dev/null 2>&1
  else
    ssldefs="SSLLIBS="
  fi
  if [ $? -ne 0 ]; then
    mupdfdefs="MUPDFDEFS=-DNO_MUPDF MUPDFLIBS="
    ssldefs="SSLLIBS="
    info="${red} no${normal} [MuPDF API >=1.4 not found]"
    ret=1
  else
    $tmpout >$tmpver 2>&1
    info="${green}yes${normal} [`cat $tmpver | head -1`]"
    if [ `uname` = "Linux" ]; then
      # check whether the MuPDF library is built with -fPIC
      ${CXX} -shared -o /dev/null ${EXTRA_LDFLAGS} -Wl,--whole-archive -lmupdf -Wl,--no-whole-archive >/dev/null 2>&1
      if [ $? -ne 0 ]; then
        mupdfdefs="MUPDFDEFS=-DNO_MUPDF MUPDFLIBS="
        ssldefs="SSLLIBS="
        info="${yellow} no${normal} [`cat $tmpver | head -1`, not relocatable]"
        ret=1
     fi
    fi
  fi
else
  info="${yellow} no${normal} [disabled]"
  mupdfdefs="MUPDFDEFS=-DNO_MUPDF MUPDFLIBS="
  ssldefs="SSLLIBS="
  ret=1
fi
printf "%12s: %s\n" "MuPDF" "$info" >&2
rm -f $tmpsrc $tmpout $tmpver

if [ "$cairo" != "no" ]
then
  tmpout=`mktemp /tmp/a.out.XXXXX`
  tmpsrc=`mktemp /tmp/a$$XXXXX.c`
  tmpver=`mktemp /tmp/a$$XXXXX.txt`
  cat >$tmpsrc << eof
#include <stdio.h>
#include <cairo/cairo.h>

int main(int argc, char **argv) {
    cairo_t *cr;
    cairo_surface_t *surface;

    surface = (cairo_surface_t *) cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 500, 500);
    cr = cairo_create(surface);

    cairo_move_to(cr, 0, 0);
    cairo_line_to(cr, 500, 500);
    cairo_stroke(cr);

    cairo_destroy(cr);
    cairo_surface_destroy(surface);

    puts(CAIRO_VERSION_STRING);

    return 0;
}
eof
  libs="-lm"
  cmd="${CC} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o $tmpout $tmpsrc -lcairo -lpixman-1 -lpthread"
  $cmd $libs >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    cairodefs="CAIRODEFS=-DNO_CAIRO CAIROLIBS="
    info="${red} no${normal} [Cairo not found]"
    ret=1
  else
    $tmpout >$tmpver 2>&1
    info="${green}yes${normal} [version `cat $tmpver | head -1`]"
  fi
else
  info="${yellow} no${normal} [disabled]"
  cairodefs="CAIRODEFS=-DNO_CAIRO CAIROLIBS="
  ret=1
fi
printf "%12s: %s\n" "Cairo" "$info" >&2
rm -f $tmpsrc $tmpout $tmpver

echo "" >&2
echo $target $wxdefs $qt4defs $qt5defs $gtkdefs $x11defs $xftdefs $gsdefs $glfwdefs $zmqdefs $avdefs $mupdfdefs $ssldefs $cairodefs $extradefs
