#!/bin/bash

CPCRLF=../tools/cpcrlf
APPNAME=abclapp
DEST=${APPNAME}.cob

MAC=`uname | tr '[A-Z]' '[a-z]'| grep -o darwin`       # on MAC OS it is "darwin"
if [ "${MAC}" = "" ]; then		# Linux
	BPKG=../tools/bpkg-static-linux-x86
else					# MAC
	BPKG=../tools/bpkg-mac-x86
	# we are running MacOS, try to find if it is supporting only 64 bit binaries (High Sierra (10.13.x) or later)
	# we do that using MacOS built-in command sw_vers
	MAC_OS_MAJOR_VER=`sw_vers -productVersion | cut -d"." -f1`
	MAC_OS_MINOR_VER=`sw_vers -productVersion | cut -d"." -f2`
	if [ "$MAC_OS_MAJOR_VER" -gt 10 ]; then
		BPKG=../tools/bpkg-mac-x86_64
	else
		if [ "$MAC_OS_MINOR_VER" -gt 12 ]; then
			BPKG=../tools/bpkg-mac-x86_64
		fi
	fi
fi

${CPCRLF} -r ${APPNAME} bla

${BPKG} /o ${APPNAME}.cob /d bla
rm -rf bla
echo
