1#! make -f
2#----------------------------------------------------------------------------
3# Project:  TwlSDK - modulerules - common rules for build system
4# File:     modulerules.x86
5#
6# Copyright 2003-2008 Nintendo.  All rights reserved.
7#
8# These coded instructions, statements, and computer programs contain
9# proprietary information of Nintendo of America Inc. and/or Nintendo
10# Company Ltd., and are protected by Federal copyright law.  They may
11# not be disclosed to third parties or copied or duplicated in any form,
12# in whole or in part, without the prior written consent of Nintendo.
13#
14# $Date:: 2008-10-07#$
15# $Rev: 8882 $
16# $Author: adachi_hiroaki $
17#----------------------------------------------------------------------------
18
19
20TWLSDK_MSG_COMPILE			= "  compile:"
21
22
23#----------------------------------------------------------------------------
24#	Implicit RULES
25#----------------------------------------------------------------------------
26WARNING		= -Wall
27
28LEX		= flex
29YACC		= bison -y
30STRIP		= strip -s
31
32# workaround for flex gen code to avoid warnings
33%.yy.o:WARNING	+= -Wno-unused-label -Wno-unused-function
34
35ifdef	DEBUG
36MACROS		+= -DDEBUG -g
37endif
38
39ifdef	NITRO_DEBUG
40MACROS		+= -g
41endif
42
43define COMPILE_C
44	$(CC_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(NITRO_INCDIR) $< -o $@
45endef
46
47define COMPILE_CXX
48	$(CXX_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(NITRO_INCDIR) $< -o $@
49endef
50
51%.o:		%.c
52ifdef SILENT
53	echo $(TWLSDK_MSG_COMPILE) $(notdir $<)
54endif
55	$(COMPILE_C)
56
57%.o:		%.cpp
58ifdef SILENT
59	echo $(TWLSDK_MSG_COMPILE) $(notdir $<)
60endif
61	$(COMPILE_CXX)
62
63%.yy.c:		%.l
64	$(LEX) -P$(basename $<)_yy -o$@ $<
65
66%.tab.c:	%.y
67	$(YACC) -d -p $(basename $<)_yy -b $(basename $<) $<
68
69%.tab.h:	%.tab.c;
70
71ifndef	NITRO_DEBUG
72ifneq	($(NO_STRIP),TRUE)
73define DO_STRIP
74$(if $(filter %.exe,$(1)),$(STRIP) $(filter %.exe,$(1)),$(TRUE))
75endef
76endif
77endif
78
79ifndef DO_STRIP
80define DO_STRIP
81$(TRUE)
82endef
83endif
84
85#----------------------------------------------------------------------------
86#  MAKE TARGETS
87#----------------------------------------------------------------------------
88
89.PHONY:	all default build build_platform do-build install install_platform do-install \
90	clean clobber super-clobber
91
92
93#----------------------------------------------------------------------------
94
95.PHONY:	make-subdir-p-% make-submake-p-% make-sub make-sub-p-pre make-sub-p
96
97SUBDIRS_PREFIX   = make-subdir-p-
98SUBDIRS_PARALLEL = $(addprefix $(SUBDIRS_PREFIX),$(SUBDIRS_P))
99
100SUBMAKES_PREFIX   = make-submake-p-
101SUBMAKES_PARALLEL = $(addprefix $(SUBMAKES_PREFIX),$(SUBMAKES_P))
102
103$(SUBDIRS_PARALLEL):$(SUBDIRS_PREFIX)%: make-sub-p-pre
104	@+$(MAKE) -C $(*F) $(MAKECMDGOALS)
105
106$(SUBMAKES_PARALLEL):$(SUBMAKES_PREFIX)%: make-sub-p-pre
107	@+$(MAKE) -C $(*D) -f $(*F) $(MAKECMDGOALS)
108
109make-sub-p-pre:
110	@+$(foreach DIR,$(SUBDIRS),$(MAKE) -C $(DIR) $(MAKECMDGOALS) $(AND)) $(TRUE)
111	@+$(foreach FILE,$(SUBMAKES),$(MAKE) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) $(AND)) $(TRUE)
112
113make-sub-p: make-sub-p-pre $(SUBDIRS_PARALLEL)	$(SUBMAKES_PARALLEL)
114
115make-sub: make-sub-p
116
117#----------------------------------------------------------------------------
118#  make build
119#----------------------------------------------------------------------------
120
121build: build_platform
122
123build_platform: make-sub
124		@$(ECHO_CURDIR)
125ifdef	TARGETS
126		@$(DO_MAKEDIR)
127		@+$(REMAKE) do-build
128ifndef	NITRO_DEBUG
129ifneq	($(NO_STRIP),TRUE)
130ifneq	($(STRIP_TARGETS),)
131		strip $(STRIP_TARGETS)
132endif
133endif
134endif
135ifdef	INSTALL_TARGETS
136		@+$(REMAKE) do-install
137endif
138endif
139
140full:
141	@+$(REMAKE) build_platform
142
143#----------------------------------------------------------------------------
144#  make install
145#----------------------------------------------------------------------------
146
147install: install_platform
148
149install_platform: make-sub
150		@$(ECHO_CURDIR)
151ifdef	INSTALL_TARGETS
152		@+$(REMAKE) do-install
153endif
154
155
156define DO_INSTALL
157	$(INSTALL) -d $(INSTALL_DIR) $(AND)					\
158	$(foreach FILE, $(INSTALL_TARGETS),			   		\
159		if [ ! -e $(INSTALL_DIR)/$(notdir $(FILE)) -o			\
160			$(FILE) -nt $(INSTALL_DIR)/$(notdir $(FILE)) ];		\
161		then 								\
162			$(ECHO) "  install: $(FILE) -> $(INSTALL_DIR)" $(AND)	\
163			$(INSTALL) $(FILE) $(INSTALL_DIR)/$(notdir $(FILE)) $(AND)\
164			$(call DO_STRIP,$(INSTALL_DIR)/$(notdir $(FILE)));	\
165		fi $(AND) ) $(TRUE)
166endef
167
168
169do-install:
170	@$(DO_INSTALL)
171
172full-install:
173	@+$(REMAKE) install_platform
174
175#----------------------------------------------------------------------------
176#  make do-autotest
177#----------------------------------------------------------------------------
178
179do-autotest: make-sub
180		@$(ECHO_CURDIR)
181
182
183#----------------------------------------------------------------------------
184#  make clobber & clean
185#----------------------------------------------------------------------------
186
187super-clobber clobber: make-sub
188		@$(ECHO_CURDIR)
189		-$(RM) $(GDIRT_CLEAN)   $(LDIRT_CLEAN)
190		-$(RM) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER)
191		-$(RM) $(GDIRT_INSTALLED)
192
193
194#----------------------------------------------------------------------------
195
196clean: make-sub
197		@$(ECHO_CURDIR)
198		-$(RM) $(GDIRT_CLEAN)   $(LDIRT_CLEAN)
199
200
201#----- End of modulerules -----
202