# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../icc/icc.conf
# Copyright (C) 2007 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
prefix=opt/icc
set_confopt

makeopt=
makeinstopt=

hook_add prepatch 5 'icc_extract_rpm'
icc_extract_rpm() {
	iccarch=`echo $arch | sed -e s/x86-64/em64t/ -e s/x86/i386/`
	for x in intel-icc[e0-9]*.$iccarch.rpm ; do
		echo "Extracting $x ..."
		rpm2cpio $x | cpio -id 2> /dev/null
	done
	}

hook_add preconf 5 'icc_license'
icc_license() {
	mkdir -p $root/$prefix/licenses
	echo "Copying local licence file (will not be packaged) ..."
	# FIXME: this is wrong, the serial has to be converted into a
	# real license file to be able to use ICC
	echo $SDECFG_PKG_ICC_SERIAL_NUMBER > $root/$prefix/licenses/t2.lic

	cat <<-EOT > $root/$prefix/licenses/README
	Copy your license (*.lic) files to this directory.
	Sorry - we are not allowed to bundle a license file
	in the Intel CC binary package for T2.
	EOT
}

hook_add postmake 5 'icc_install'
icc_install() {
	for x in $( grep -l "<INSTALLDIR>" opt/intel/cc*/*/bin/* ) ; do
		sed -i "s,<INSTALLDIR>,/$prefix,g" $x
	done
	( cd opt/intel/cc*/*/
	  tar -cf - * | tar -xv -C $root/$prefix -f -
	)

	[ $SDECFG_DEFAULT_CC  != icc ] || ln -sf icc $root/$bindir/cc
	[ $SDECFG_DEFAULT_CXX != icc ] || ln -sf icc $root/$bindir/c++
}

var_append flist''del '|' "$prefix/licenses/t2.lic"