1 # $NetBSD: gen_template.sh,v 1.3 2008/02/26 21:46:38 rafal Exp $
3 # Copyright (c) 2001 The NetBSD Foundation, Inc.
6 # This code is derived from software contributed to The NetBSD Foundation
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
32 # Generate application/static library dsp/vcp template.
37 if [ $TYPE != "application" ] ; then
38 PROJECTTYPE
="Static Library"
40 PROJECTTYPE
="Application"
49 echo "Generate template for Visual C++ 5 Windows CE Embeded ToolKit"
52 echo "Generate template for Visual C++ 6 Windows CE ToolKit"
55 echo "Generate template for Embeded Visual C++ 3/4"
58 echo "Unsupported Visual C++ version."
62 tmpl_base
="tmpl.$vc_ver"
63 header_tmpl
="$tmpl_base/header"
64 project_tmpl
="$tmpl_base/project"
72 while [ $i -lt $n ]; do
77 echo "Supported architecture [$archs ]"
82 cat $header_tmpl >> $TEMPLATE
85 # Configuration declare.
87 echo '!MESSAGE' >> $TEMPLATE
90 ARCH_CFG
="Win32 (WCE $arch)"
91 CFG
="%%% NAME %%% - $ARCH_CFG"
92 echo "!MESSAGE \"$CFG $DEBUG_VER\" (\"$ARCH_CFG $PROJECTTYPE\")" >> $TEMPLATE
93 echo "!MESSAGE \"$CFG $RELEASE_VER\" (\"$ARCH_CFG $PROJECTTYPE\")" >> $TEMPLATE
95 echo '!MESSAGE' >> $TEMPLATE
100 cat $project_tmpl >> $TEMPLATE
103 # Architecture dependent configuration define.
107 ARCH_CFG
="Win32 (WCE $arch)"
108 CFG
="%%% NAME %%% - $ARCH_CFG"
109 echo "!IF \"\$(CFG)\" == \"$CFG $DEBUG_VER\"" >> $TEMPLATE
110 echo "# PROP BASE Output_Dir \"..\\compile\\$arch$DEBUG_VER\"" >> $TEMPLATE
111 echo "# PROP BASE Intermediate_Dir \"..\\compile\\$arch$DEBUG_VER\"" >> $TEMPLATE
112 echo "# PROP Output_Dir \"..\\compile\\$arch$DEBUG_VER\"" >> $TEMPLATE
113 echo "# PROP Intermediate_Dir \"..\\compile\\$arch$DEBUG_VER\"" >> $TEMPLATE
114 cat $tmpl_base/$TYPE.
$arch$DEBUG_VER >> $TEMPLATE
115 cat $tmpl_base/config.defadd
>> $TEMPLATE
116 if [ $TYPE = "application" ] ; then
117 echo "# ADD LINK32 /libpath:\"..\\compile\\$arch$DEBUG_VER\"" >> $TEMPLATE
119 echo "!ENDIF" >> $TEMPLATE
120 echo "!IF \"\$(CFG)\" == \"$CFG $RELEASE_VER\"" >> $TEMPLATE
121 cat $tmpl_base/config.defprop
>> $TEMPLATE
122 echo "# PROP BASE Output_Dir \"..\\compile\\$arch$RELEASE_VER\"" >> $TEMPLATE
123 echo "# PROP BASE Intermediate_Dir \"..\\compile\\$arch$RELEASE_VER\"" >> $TEMPLATE
124 echo "# PROP Output_Dir \"..\\compile\\$arch$RELEASE_VER\"" >> $TEMPLATE
125 echo "# PROP Intermediate_Dir \"..\\compile\\$arch$RELEASE_VER\"" >> $TEMPLATE
126 cat $tmpl_base/$TYPE.
$arch$RELEASE_VER >> $TEMPLATE
127 cat $tmpl_base/config.defadd
>> $TEMPLATE
128 if [ $TYPE = "application" ] ; then
129 echo "# ADD LINK32 /libpath:\"..\\compile\\$arch$RELEASE_VER\"" >> $TEMPLATE
131 echo "!ENDIF" >> $TEMPLATE
138 echo "# Begin Target" >> $TEMPLATE
141 ARCH_CFG
="Win32 (WCE $arch)"
142 CFG
="%%% NAME %%% - $ARCH_CFG"
143 echo "# Name \"$CFG $DEBUG_VER\"" >> $TEMPLATE
144 echo "# Name \"$CFG $RELEASE_VER\"" >> $TEMPLATE
151 cat >> $TEMPLATE <<SRCS
153 # Begin Group "Source Files"
160 echo "%%% SRCFILES_$arch %%%" >> $TEMPLATE
165 cat >> $TEMPLATE <<FOOTER
174 # Generate MD source files property.
178 ARCH_FILE
="property.$arch"
180 for sub_arch
in $archs
182 ARCH_CFG
="Win32 (WCE $sub_arch)"
183 CFG
="%%% NAME %%% - $ARCH_CFG"
184 CONDITION_DEBUG
="!IF \"\$(CFG)\" == \"$CFG $DEBUG_VER\""
185 CONDITION_RELEASE
="!IF \"\$(CFG)\" == \"$CFG $RELEASE_VER\""
186 if [ $sub_arch != $arch ] ; then
187 echo $CONDITION_DEBUG >> $ARCH_FILE >> $ARCH_FILE
188 echo "# PROP Exclude_From_Build 1" >> $ARCH_FILE
189 echo "!ENDIF" >> $ARCH_FILE
190 echo $CONDITION_RELEASE >> $ARCH_FILE >> $ARCH_FILE
191 echo "# PROP Exclude_From_Build 1" >> $ARCH_FILE
192 echo "!ENDIF" >> $ARCH_FILE
195 # mv $ARCH_FILE $ARCH_FILE.0
196 # awk ' { printf "%s\r\n", $0 }' $ARCH_FILE.0 > $ARCH_FILE
201 # Generate MD assembler files property and custom build method.
205 ARCH_FILE
="asm_build.$arch.0"
207 for sub_arch
in $archs
209 ARCH_CFG
="Win32 (WCE $sub_arch)"
210 CFG
="%%% NAME %%% - $ARCH_CFG"
211 CONDITION_DEBUG
="!IF \"\$(CFG)\" == \"$CFG $DEBUG_VER\""
212 CONDITION_RELEASE
="!IF \"\$(CFG)\" == \"$CFG $RELEASE_VER\""
213 if [ $sub_arch != $arch ] ; then
214 echo $CONDITION_DEBUG >> $ARCH_FILE >> $ARCH_FILE
215 echo "# PROP Exclude_From_Build 1" >> $ARCH_FILE
216 echo "!ENDIF" >> $ARCH_FILE
217 echo $CONDITION_RELEASE >> $ARCH_FILE >> $ARCH_FILE
218 echo "# PROP Exclude_From_Build 1" >> $ARCH_FILE
219 echo "!ENDIF" >> $ARCH_FILE
221 echo $CONDITION_DEBUG >> $ARCH_FILE >> $ARCH_FILE
222 echo "# PROP Ignore_Default_Tool 1" >> $ARCH_FILE
223 echo "# Begin Custom Build" >> $ARCH_FILE
224 echo "InputPath=%%% ASM_BASENAME %%%.asm" >> $ARCH_FILE
225 echo "\"\$(OUTDIR)\\%%% ASM_BASENAME %%%.obj\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"" >> $ARCH_FILE
226 echo " %%% ASM %%% \$(InputPath) \$(OUTDIR)\\%%% ASM_BASENAME %%%.obj" >> $ARCH_FILE
227 echo "# End Custom Build" >> $ARCH_FILE
228 echo "!ENDIF" >> $ARCH_FILE
229 echo $CONDITION_RELEASE >> $ARCH_FILE >> $ARCH_FILE
230 echo "# PROP Ignore_Default_Tool 1" >> $ARCH_FILE
231 echo "# Begin Custom Build" >> $ARCH_FILE
232 echo "InputPath=%%% ASM_BASENAME %%%.asm" >> $ARCH_FILE
233 echo "\"\$(OUTDIR)\\%%% ASM_BASENAME %%%.obj\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"" >> $ARCH_FILE
234 echo " %%% ASM %%% \$(InputPath) \$(OUTDIR)\\%%% ASM_BASENAME %%%.obj" >> $ARCH_FILE
235 echo "# End Custom Build" >> $ARCH_FILE
236 echo "!ENDIF" >> $ARCH_FILE
244 if [ -f asm_build.ARM
.0 ]; then
245 sed 's/%%% ASM %%%/armasm.exe/' asm_build.ARM
.0 > asm_build.ARM
246 rm -f asm_build.ARM
.0
248 if [ -f asm_build.ARMV4.0
]; then
249 sed 's/%%% ASM %%%/armasm.exe/' asm_build.ARMV4.0
> asm_build.ARMV4
250 rm -f asm_build.ARMV4.0
252 if [ -f asm_build.SH
.0 ]; then
253 sed 's/%%% ASM %%%/asmsh.exe/' asm_build.SH
.0 > asm_build.SH
256 if [ -f asm_build.SH3.0
]; then
257 sed 's/%%% ASM %%%/asmsh.exe/' asm_build.SH3.0
> asm_build.SH3
258 rm -f asm_build.SH3.0
260 if [ -f asm_build.SH4.0
]; then
261 sed 's/%%% ASM %%%/asmsh.exe/' asm_build.SH4.0
> asm_build.SH4
262 rm -f asm_build.SH4.0
264 if [ -f asm_build.MIPS
.0 ]; then
265 sed 's/%%% ASM %%%/mipsasm.exe/' asm_build.MIPS
.0 > asm_build.MIPS
266 rm -f asm_build.MIPS
.0