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/LinkList 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/LinkListFixed0
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 = a.c b.c
56CSRCS_S = static.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\LinkListFixed0\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) $(FULLBIN_ROOT)/$(BINNAMES)$(DDFSUFFIX)
115
116$(FULLBIN_ROOT)/$(BINNAMES)$(DDFSUFFIX): $(TARGET_BINS)
117	mkdir -p dvddata
118	cp $(FULLBIN_ROOT)/a$(RSOSUFFIX) dvddata
119	cp $(FULLBIN_ROOT)/b$(RSOSUFFIX) dvddata
120	cp $(FULLBIN_ROOT)/static$(SELSUFFIX) dvddata
121	@echo "[Input]" >> $@
122	@echo "DvdRoot=\"`cygpath -w '$(RSO_DVDROOT)'`\"" >> $@
123
124# generate the module name string table.
125$(FULLBIN_ROOT)/$(BINNAMES)$(SELSUFFIX): $(TARGET_BINS) $(SYMBOL_LST_FILE)
126	@echo
127	@echo ">> $(notdir $+) --> $@"
128	cd $(FULLBIN_ROOT); $(ROOT)/X86/bin/makerso.exe $(notdir $(TARGET_BINS)) -e $(notdir $(SYMBOL_LST_FILE)) -a
129
130# $(PREPLFSUFFIX) are for the 1st .plf file build without .lcf file
131# $(PLFSUFFIX)    are for the 2nd .plf file build with .lcf file
132
133#$(TARGET_PREPLFS) : $(FULLBIN_ROOT)/%$(PREPLFSUFFIX): $(FULLBINOBJ_ROOT)/%.o $(BINOBJ_ROOT)/global_destructor_chain.o
134
135$(TARGET_BINS): $(CPPSRCS_S:.cpp=.o) $(CSRCS_S:.c=.o) $(LCF_FILE) $(INSTALL_ROOT)/lib/rso$(LIBSUFFIX)
136$(TARGET_BINS): $(REVOLUTION_LIBS)
137
138$(TARGET_PLFS) : $(FULLBIN_ROOT)/%$(PLFSUFFIX): $(FULLBINOBJ_ROOT)/%.o $(BINOBJ_ROOT)/global_destructor_chain.o $(REL_LCF_FILE)
139
140# generate force active symbol list.
141#$(LST_FILE): $(TARGET_PREPLFS)
142#	@echo
143#	@echo ">> $(notdir $+) --> $@"
144#	cd $(FULLBIN_ROOT); "$(ROOT)/X86/bin/makerelD.exe" $(+F)
145#	cat $(FULLBIN_ROOT)/import.lst > $(LST_FILE)
146
147# generate linker command file for the static module.
148$(LCF_FILE) $(SYMBOL_LST_FILE) : $(TARGET_RSOS) $(STATIC_LCF_FILE)
149	$(ROOT)/X86/bin/makelcf.exe -o $(LCF_FILE) -s $(SYMBOL_LST_FILE) -t $(STATIC_LCF_FILE) $(TARGET_RSOS)
150
151# generate linker command file for relocatable modules.
152$(REL_LCF_FILE): #$(LST_FILE)
153	@echo
154	@echo ">> $+ --> $@"
155	cat $(PREREL_LCF_FILE) > $@
156	echo "FORCEFILES { " >> $@
157	echo "    a.o" >> $@
158	echo "    b.o" >> $@
159	echo " }" >> $@
160	echo "FORCEACTIVE { " >> $@
161	echo "    __global_destructor_chain" >> $@
162	echo "}" >> $@
163
164%$(RSOSUFFIX): %$(PLFSUFFIX)
165	cd $(FULLBIN_ROOT); $(ROOT)/X86/bin/makerso.exe $(notdir $(+)) -a
166
167clean:
168	rm -f $(FULLBIN_ROOT)/*.lst
169	rm -f $(FULLBIN_ROOT)/*.lcf
170
171$(BINOBJ_ROOT)/global_destructor_chain.o:
172	$(CC) $(CCFLAGS) -pragma "warning off (10423)" $(INCLUDES) \
173        $(COMPILE) $(MWDIR)/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c \
174        -o $@
175