#! make -f
#----------------------------------------------------------------------------
# Project:  NitroSDK - root
# File:     Makefile
#
# Copyright 2003,2004 Nintendo.  All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
# Company Ltd., and are protected by Federal copyright law.  They may
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Log: Makefile,v $
# Revision 1.12  2004/10/25 11:25:26  yasu
# Use libdiff
#
# Revision 1.11  2004/10/05 02:30:37  yasu
# Set LMACRO_FLAGS=1 instead of MACRO_FLAGS
#
# Revision 1.10  2004/10/05 00:19:31  yasu
# Fix SDK_NO_MESSAGE
#
# Revision 1.9  2004/10/04 11:47:41  yasu
# Corrected find condition
#
# Revision 1.8  2004/10/03 10:01:18  yasu
# Fix sdkindent rules
#
# Revision 1.7  2004/10/03 09:32:10  yasu
# renew indent rules
#
# Revision 1.6  2004/06/29 00:59:49  yasu
# Add setup libcxx for workaround against lcf error
#
# Revision 1.5  2004/05/06 10:18:18  yasu
# fix typo
#
# Revision 1.4  2004/03/17 07:31:04  yasu
# add indent correction rule
#
# Revision 1.3  2004/02/05 07:12:05  yasu
# change SDK prefix iris -> nitro
#
# Revision 1.2  2003/10/30 05:51:52  yasu
# build: target deleted
#
# Revision 1.1  2003/10/29 13:27:26  yasu
# make propatation framework completed
# Can use all/install/clean/clobber
#
# $NoKeywords: $
#----------------------------------------------------------------------------

include	$(NITROSDK_ROOT)/build/buildtools/commondefs


#----------------------------------------------------------------------------

SUBDIRS 	= build


#----------------------------------------------------------------------------

include	$(NITROSDK_ROOT)/build/buildtools/modulerules


#----------------------------------------------------------------------------
.PHONY:		setup

setup:
	$(MAKE) -C build/buildsetup/libcxx

#----------------------------------------------------------------------------
.PHONY:	indent-all do-indent do-rename do-diff

SDKINDENT	= $(NITRO_TOOLSDIR)/bin/sdkindent
SDKDIFF		= $(NITRO_TOOLSDIR)/bin/sdkindent.libdiff
SDKDIR_BUILD	?= build
SDKDIR_INCLUDE	= include

indent-all:
	( export LMACRO_FLAGS=-DSDK_NO_MESSAGE=1;		\
	  export NITRO_NO_OPT_G=1;				\
	  $(MAKE) -kB -C $(SDKDIR_BUILD) $(SDKINDENT_BUILD);	\
	  $(REMAKE) do-rename;					\
	  $(REMAKE) do-indent;					\
	  $(MAKE) -skB -C $(SDKDIR_BUILD) $(SDKINDENT_BUILD);	\
	  $(REMAKE) do-diff )

indent-sub:
	( export LMACRO_FLAGS=-DSDK_NO_MESSAGE=1;		\
	  export NITRO_NO_OPT_G=1;				\
	  $(REMAKE) do-indent;					\
	  $(MAKE) -skB -C $(SDKDIR_BUILD) $(SDKINDENT_BUILD);	\
	  $(REMAKE) do-diff )

indent-diff:
	  $(REMAKE) do-diff

do-indent:
	@echo ===== INDENT STAGE =====
	/bin/find $(SDKDIR_BUILD)   -type f \
		-name '*.[ch]' ! -name '*.yy.c' ! -name '*.yy.patched.c' \
		-size -128k -print -exec $(SDKINDENT) {} \;
	/bin/find $(SDKDIR_INCLUDE) -type f \
		-name '*.[ch]' ! -name '*.yy.c' ! -name '*.yy.patched.c' \
		-size -128k -print -exec $(SDKINDENT) {} \;

do-rename:
	@echo ===== RENAME STAGE =====
	/bin/find $(SDKDIR_BUILD) -type f -name '*.o' -exec $(MV) {} {}.backup \;

do-diff:
	@echo ===== COMPARE STAGE =====
	/bin/find $(SDKDIR_BUILD) -type f -name '*.o' -exec $(SDKDIFF) {} {}.backup \;

#===== End of Makefile =====
