#!/bin/bash

############################################################################
#                                                                          #
#  Copyright (c) 2001, 2016 NoMachine, http://www.nomachine.com/.          #
#                                                                          #
#  Simple configure script used to build as part of the NX system.         #
#                                                                          #
#  Redistribution and use of the present software is allowed according     #
#  to terms specified in the file LICENSE which comes in the source        #
#  distribution.                                                           #
#                                                                          #
#  Check http://www.nomachine.com/licensing.html for other options.        #
#                                                                          #
#  NX and NoMachine are trademarks of NoMachine S.a.r.l.                   #
#                                                                          #
#  All rights reserved.                                                    #
#                                                                          #
############################################################################

#
# Include our configure functions.
#

if test -z "$ROOT"; then
  if test -x "../../../Configure"; then
    ROOT="../../.."
  else
    echo -ne "configure: error: can't find the main configure script\n\n"
    exit 1
  fi
fi

. $ROOT/Configure --functs || include_failed

#
# Setup the configuration environment.
#

setup_configure || setup_failed


empty_makefile $ROOT || makefile_failed

if test "$TARGET" = "Linux32" || test "$TARGET" = "Linux64"; then

  CC=gcc

  replace_targets Makefile  

  add_target Makefile "install" "nxtunctl additional-install" ""

  add_target Makefile "all" "nxtunctl" ""

  add_target Makefile "distclean" "additional-clean additional-distclean" ""  

  add_target Makefile "nxtunctl" "" "$CC -g -Wall -o nxtunctl tunctl.c"

  add_command Makefile install "rm -f $BUILD/bin/nxtunctl"

  add_command Makefile install "cp -p nxtunctl $BUILD/bin/nxtunctl"

  add_command Makefile distclean "rm nxtunctl"

  flush_targets Makefile

fi

echo -ne "configure: creating ./config.status\n"

touch ./config.status

