1#! make -f
2#----------------------------------------------------------------------------
3# Project:  TwlSDK
4# File:     modulerules.x86
5#
6# Copyright 2007-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	TWL_DEBUG
40MACROS		+= -g
41endif
42
43define COMPILE_C
44	$(CC_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(TWL_INCDIR) $< -o $@
45endef
46
47define COMPILE_CXX
48	$(CXX_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(TWL_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	TWL_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
128ifdef	INSTALL_TARGETS
129		@+$(REMAKE) do-install
130endif
131endif
132
133full:
134	@+$(REMAKE) build_platform
135
136#----------------------------------------------------------------------------
137#  make install
138#----------------------------------------------------------------------------
139
140install: install_platform
141
142install_platform: make-sub
143		@$(ECHO_CURDIR)
144ifdef	INSTALL_TARGETS
145		@+$(REMAKE) do-install
146endif
147
148
149define DO_INSTALL
150	$(INSTALL) -d $(INSTALL_DIR) $(AND)					\
151	$(foreach FILE, $(INSTALL_TARGETS),			   		\
152		if [ ! -e $(INSTALL_DIR)/$(notdir $(FILE)) -o			\
153			$(FILE) -nt $(INSTALL_DIR)/$(notdir $(FILE)) ];		\
154		then 								\
155			$(ECHO) "  install: $(FILE) -> $(INSTALL_DIR)" $(AND)	\
156			$(INSTALL) $(FILE) $(INSTALL_DIR)/$(notdir $(FILE)) $(AND)\
157			$(call DO_STRIP,$(INSTALL_DIR)/$(notdir $(FILE)));	\
158		fi $(AND) ) $(TRUE)
159endef
160
161
162do-install:
163	@$(DO_INSTALL)
164
165full-install:
166	@+$(REMAKE) install_platform
167
168#----------------------------------------------------------------------------
169#  make do-autotest
170#----------------------------------------------------------------------------
171
172do-autotest: make-sub
173		@$(ECHO_CURDIR)
174
175
176#----------------------------------------------------------------------------
177#  make clobber & clean
178#----------------------------------------------------------------------------
179
180super-clobber clobber: make-sub
181		@$(ECHO_CURDIR)
182		-$(RM) $(GDIRT_CLEAN)   $(LDIRT_CLEAN)
183		-$(RM) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER)
184		-$(RM) $(GDIRT_INSTALLED)
185
186
187#----------------------------------------------------------------------------
188
189clean: make-sub
190		@$(ECHO_CURDIR)
191		-$(RM) $(GDIRT_CLEAN)   $(LDIRT_CLEAN)
192
193
194#----- End of modulerules -----
195