1###############################################################################
2# Revolution Shared Object demo
3#
4# Copyright (C) 2001-2006 Nintendo  All rights reserved.
5#
6# These coded instructions, statements, and computer programs contain
7# proprietary information of Nintendo of America Inc. and/or Nintendo
8# Company Ltd., and are protected by Federal copyright law.  They may
9# not be disclosed to third parties or copied or duplicated in any form,
10# in whole or in part, without the prior written consent of Nintendo.
11#
12###############################################################################
13
14##################################
15# QUICK START INSTRUCTIONS
16# Type "make" at $(REVOLUTION_SDK_ROOT)/build/demos/rsodemo/MakeInc to build DEBUG versions.
17# Type "make NDEBUG=TRUE" to build OPTIMIZED versions.
18##################################
19
20# commondefs must be included near the top so that all common variables
21# will be defined before their use.
22include $(REVOLUTION_SDK_ROOT)/build/buildtools/commondefs
23
24# build any code modules and module name string table
25all:    setup build install
26
27# Add Suffix for RSO Files
28ifdef NDEBUG
29SELSUFFIX = .sel
30RSOSUFFIX = .rso
31DDFSUFFIX = .ddf
32else
33SELSUFFIX = D.sel
34RSOSUFFIX = D.rso
35DDFSUFFIX = D.ddf
36endif
37
38# module name should be set to the name of this subdirectory
39# DEMO = TRUE indicates that this module resides under the "demos" subtree.
40# The list of selectable paths can be found in modulerules.
41MODULENAME  = rsodemo/MakeInc
42DEMO        = TRUE
43
44# small data sections are not supported by relocatable modules
45CCFLAGS += -sdata 0 -sdata2 0
46
47ifdef MAC
48
49else
50# EPPC
51
52# CSRCS lists all C files that should be built
53# The makefile determines which objects are linked into which binaries
54# based on the dependencies you fill in at the bottom of this file
55CSRCS_D = d.c
56CSRCS_S = static.c sub.c
57CSRCS = $(CSRCS_D) $(CSRCS_S)
58
59# CPPSRCS lists all C++ files that should be built
60# The makefile determines which objects are linked into which binaries
61# based on the dependencies you fill in at the bottom of this file
62CPPSRCS_D =
63CPPSRCS_S =
64CPPSRCS = $(CPPSRCS_D) $(CPPSRCS_S)
65
66# BINNAMES specifies the static portion of the program.  Note that no suffix
67# is required, as that will depend on whether this is a DEBUG build or not.
68# The final name of the binaries will be $(STATIC)$(BINSUFFIX)
69BINNAMES    = static
70
71RSO_DVDROOT = $(REVOLUTION_SDK_ROOT)\build\demos\rsodemo\MakeInc\dvddata
72
73# RELNAMES lists all relocatable modules that will be linked.
74# Note that no suffix is required, as that will depend on whether
75# this is a DEBUG build or not.
76# The final name of the modules will be $(RELNAMES)$(RELSUFFIX)
77
78#
79#RELNAMES = $(basename $(CPPSRCS_D)) $(basename $(CSRCS_D))
80TARGET_PLFS = $(addprefix $(FULLBIN_ROOT)/,$(addsuffix $(PLFSUFFIX), $(basename $(CSRCS_D))))
81TARGET_PLFS += $(addprefix $(FULLBIN_ROOT)/,$(addsuffix $(PLFSUFFIX), $(basename $(CPPSRCS_D))))
82
83#TARGET_RSOS = $(addprefix $(FULLBIN_ROOT)/,$(addsuffix $(RSOSUFFIX), $(RELNAMES)))
84TARGET_RSOS = $(addprefix $(FULLBIN_ROOT)/,$(addsuffix $(RSOSUFFIX), $(basename $(CSRCS_D))))
85TARGET_RSOS += $(addprefix $(FULLBIN_ROOT)/,$(addsuffix $(RSOSUFFIX), $(basename $(CPPSRCS_D))))
86
87
88# linker command file for building the static module
89LCF_FILE        = $(FULLBIN_ROOT)/static$(LCFSUFFIX)
90
91# linker command file for building relocatable modules (for 1st step)
92PREREL_LCF_FILE = $(INC_ROOT)/dolphin/eppc.lcf
93
94# linker command file for building relocatable modules (for 2nd step)
95REL_LCF_FILE    = $(FULLBIN_ROOT)/partial$(LCFSUFFIX)
96
97# linker command file for building static modules
98STATIC_LCF_FILE    = $(INC_ROOT)/revolution/eppc.$(ARCH_TARGET).lcf
99
100# filename of the force active symbol name list
101#LST_FILE        = $(FULLBIN_ROOT)/active$(LSTSUFFIX)
102
103# filename of the symbol name list
104SYMBOL_LST_FILE = $(FULLBIN_ROOT)/symbol$(LSTSUFFIX)
105
106endif
107
108# modulerules contains the rules that will use the above variables
109# and dependencies below to construct the binaries specified.
110include $(REVOLUTION_SDK_ROOT)/build/buildtools/modulerules
111
112# all build targets that depend on 'setup' target must be listed as
113# prerequisites  for 'dobuild'.
114dobuild: $(FULLBIN_ROOT)/$(BINNAMES)$(SELSUFFIX) $(MODULE_ROOT)/include/d.inc $(FULLBIN_ROOT)/$(BINNAMES)$(DDFSUFFIX)
115
116$(FULLBINOBJ_ROOT)/static.o: $(MODULE_ROOT)/include/d.inc
117
118$(MODULE_ROOT)/include/d.inc: $(MODULE_ROOT)/include/d.h
119	@echo
120	@echo ">> $(notdir $+) --> $(notdir $@)"
121	makeinc.exe -o $(MODULE_ROOT)/include/d.inc -l moduleD $(MODULE_ROOT)/include/d.h
122
123$(FULLBIN_ROOT)/$(BINNAMES)$(DDFSUFFIX): $(TARGET_BINS)
124	mkdir -p dvddata
125	cp $(FULLBIN_ROOT)/d$(RSOSUFFIX) dvddata
126	cp $(FULLBIN_ROOT)/static$(SELSUFFIX) dvddata
127	@echo "[Input]" >> $@
128	@echo "DvdRoot=\"`cygpath -w '$(RSO_DVDROOT)'`\"" >> $@
129
130# generate the module name string table.
131$(FULLBIN_ROOT)/$(BINNAMES)$(SELSUFFIX): $(TARGET_BINS) $(SYMBOL_LST_FILE)
132	@echo
133	@echo ">> $(notdir $+) --> $@"
134	cd $(FULLBIN_ROOT); $(ROOT)/X86/bin/makerso.exe $(notdir $(TARGET_BINS)) -e $(notdir $(SYMBOL_LST_FILE)) -a
135
136# $(PREPLFSUFFIX) are for the 1st .plf file build without .lcf file
137# $(PLFSUFFIX)    are for the 2nd .plf file build with .lcf file
138
139#$(TARGET_PREPLFS) : $(FULLBIN_ROOT)/%$(PREPLFSUFFIX): $(FULLBINOBJ_ROOT)/%.o $(BINOBJ_ROOT)/global_destructor_chain.o
140
141$(TARGET_BINS): $(CPPSRCS_S:.cpp=.o) $(CSRCS_S:.c=.o) $(LCF_FILE) $(INSTALL_ROOT)/lib/rso$(LIBSUFFIX)
142$(TARGET_BINS): $(REVOLUTION_LIBS)
143
144$(TARGET_PLFS) : $(FULLBIN_ROOT)/%$(PLFSUFFIX): $(FULLBINOBJ_ROOT)/%.o $(BINOBJ_ROOT)/global_destructor_chain.o $(REL_LCF_FILE)
145
146# generate force active symbol list.
147#$(LST_FILE): $(TARGET_PREPLFS)
148#	@echo
149#	@echo ">> $(notdir $+) --> $@"
150#	cd $(FULLBIN_ROOT); "$(ROOT)/X86/bin/makerelD.exe" $(+F)
151#	cat $(FULLBIN_ROOT)/import.lst > $(LST_FILE)
152
153# generate linker command file for the static module.
154$(LCF_FILE) $(SYMBOL_LST_FILE) : $(TARGET_RSOS) $(STATIC_LCF_FILE)
155	$(ROOT)/X86/bin/makelcf.exe -o $(LCF_FILE) -s $(SYMBOL_LST_FILE) -t $(STATIC_LCF_FILE) $(TARGET_RSOS)
156
157# generate linker command file for relocatable modules.
158$(REL_LCF_FILE): #$(LST_FILE)
159	@echo
160	@echo ">> $+ --> $@"
161	cat $(PREREL_LCF_FILE) > $@
162	echo "FORCEFILES { " >> $@
163	echo "    d.o" >> $@
164	echo " }" >> $@
165	echo "FORCEACTIVE { " >> $@
166	echo "    __global_destructor_chain" >> $@
167	echo "}" >> $@
168
169%$(RSOSUFFIX): %$(PLFSUFFIX)
170	cd $(FULLBIN_ROOT); $(ROOT)/X86/bin/makerso.exe $(notdir $(+)) -a
171
172clean:
173	rm -f $(FULLBIN_ROOT)/*.lst
174	rm -f $(FULLBIN_ROOT)/*.lcf
175
176$(BINOBJ_ROOT)/global_destructor_chain.o:
177	$(CC) $(CCFLAGS) -pragma "warning off (10423)" $(INCLUDES) \
178        $(COMPILE) $(MWDIR)/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c \
179        -o $@
180