#    This file is part of MKF.
#
#    MKF 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; either version 2 of the License, or
#    (at your option) any later version.
#
#    MKF 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with MKF; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#    Copyright (c) 2004 Alexandre Becoulet <alexandre.becoulet@epita.fr>

# make invocation

_if_var_eq		cmd_make
 _if_in_path		gmake
  var_define		cmd_make	gmake
 _else
  var_define		cmd_make	make
 _end_if
_end_if

_if_in_path		{PVAR,cmd_make}
 _if_stdout_match	GNU		{PVAR,cmd_make} -v -f /dev/null

  msg_info		GNU make ({PVAR,cmd_make}) found

  _if_var_eq		mkf_pretty_print	yes
   command_add	enter	dir	@echo " * MAKE              {PWD}/{OUT}"
   command_add	enter	dir	@{PVAR,cmd_make} -s all -C {OUT}
   command_add	enter	dir	@echo "   MAKE (leave)      {OUT}"
  _else
   command_add	enter	dir	{PVAR,cmd_make} all -C {OUT}
  _end_if

  _if_var_eq		mkf_pretty_print	yes
   command_add	clean	dir	@echo " * MAKE (clean)      {PWD}/{DIR}"
   command_add	clean	dir	@{PVAR,cmd_make} -s clean -C {DIR}
   command_add	clean	dir	@echo "   MAKE (leaving)    {DIR}"
  _else
   command_add	clean	dir	{PVAR,cmd_make} clean -C {DIR}
  _end_if

  _if_var_eq		mkf_pretty_print	yes
   command_add	install	dir	@echo " * MAKE (install)    {PWD}/{DIR}"
   command_add	install	dir	@{PVAR,cmd_make} -s install -C {DIR}
   command_add	install	dir	@echo "   MAKE (leave)      {DIR}"
  _else
   command_add	install	dir	{PVAR,cmd_make} install -C {DIR}
  _end_if

 _else

  msg_info		native make ({PVAR,cmd_make}) found
  command_add	enter	dir	(cd {OUT} ; {PVAR,cmd_make} all)
  command_add	clean	dir	(cd {DIR} ; {PVAR,cmd_make} clean)
  command_add	install	dir	(cd {DIR} ; {PVAR,cmd_make} install)

 _end_if
_else

  msg_error		invalid or no make tool specified

_end_if

command_add	clean	file	rm -f {FILE}

