# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../wings3d/wings3d.conf
# Copyright (C) 2011 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# 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 ---

OTPDIR=`pkgprefix libdir erlang-otp`/erlang/lib/wings-$ver

var_append makeopt ' ' 'ESDL_PATH="$( pkgprefix libdir esdl )/erlang/addons/esdl-$( pkgprefix ver esdl )"'
# use OpenGL from wx included in erlang-otp
# (esdl >= 1.2 is not including OpenGL support anymore)
var_append makeopt ' ' 'wx'

build () {
    make $makeopt
    erlc -o/tmp tools/strip.erl
    erl -noshell -pa /tmp -run strip strip
    mkdir -p $OTPDIR
    find -name 'Makefile*' -exec rm -f '{}' \;
    for dir in ebin fonts plugins ; do
	cp -r $dir $OTPDIR
    done
}

startscript () {
    echo "erl -pa $ESDLDIR -pa $OTPDIR/bin -run wings_start start_halt \${1+\"\$@\"}" > $root/usr/bin/wings3d
    chmod 755 $root/usr/bin/wings3d
}

# custmain="build"
hook_add postinstall 5 startscript