#!/bin/bash
# Now Check if Tcl is installed, run it if so. The backslash extends the comment and hides the line below against Tcl interpreter \
exec tclsh "$0" "$@" || echo "Please install 'tcl' package first - it's required to run any other scripts here." && exit 1

# 
# SRT - Secure, Reliable, Transport
# Copyright (c) 2017 Haivision Systems Inc.
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; If not, see <http://www.gnu.org/licenses/>
# 

set ok 1

set nothave [catch {set cmake [exec cmake --version]}]

if { $nothave } {
	puts "CMake version >= 2.6 required - please install cmake"
	set ok 0
} else {
	set cmakel1 [lindex [split $cmake \n] 0]
	set cv [lindex $cmakel1 end]
	if { [package vcompare $cv 2.6] == -1 } {
		puts "CMake version >= 2.6 required - please upgrade cmake"
		set ok 0
	} else {
		puts "Cmake version $cv -- ok."
	}
}

set nothave [catch {exec pkg-config --exists libcrypto}]

if { $nothave } {
	puts "Required libcrypto to compile SRT (usually libopenssl-devel package)"
	set ok 0
}


# May others also apply

if { $ok } {
	puts "All dependencies satisfied, you should be good to go."
	exit 0
}

puts "Please fix the above findings before compiling"
exit 1


