No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hpc / stand / dspgen / gen_template.sh
blob2abcd2e2550e08567429de3da81eef6ce2cb7cac
1 # $NetBSD: gen_template.sh,v 1.3 2008/02/26 21:46:38 rafal Exp $
3 # Copyright (c) 2001 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by UCHIYAMA Yasushi.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
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.
34 TEMPLATE=$TYPE.tmpl
35 DEBUG_VER="Debug"
36 RELEASE_VER="Release"
37 if [ $TYPE != "application" ] ; then
38 PROJECTTYPE="Static Library"
39 else
40 PROJECTTYPE="Application"
44 # Visual C++ version.
46 vc_ver=$1
47 case $vc_ver in
48 "vc5")
49 echo "Generate template for Visual C++ 5 Windows CE Embeded ToolKit"
51 "vc6")
52 echo "Generate template for Visual C++ 6 Windows CE ToolKit"
54 "evc3"|"evc4")
55 echo "Generate template for Embeded Visual C++ 3/4"
58 echo "Unsupported Visual C++ version."
59 exit 1
60 esac
62 tmpl_base="tmpl.$vc_ver"
63 header_tmpl="$tmpl_base/header"
64 project_tmpl="$tmpl_base/project"
67 # Architecture types.
69 archs=""
70 i=1
71 n=`expr $#`
72 while [ $i -lt $n ]; do
73 shift 1
74 archs="$archs $1"
75 i=`expr $i + 1`
76 done
77 echo "Supported architecture [$archs ]"
80 # DSP/VCP header.
82 cat $header_tmpl >> $TEMPLATE
85 # Configuration declare.
87 echo '!MESSAGE' >> $TEMPLATE
88 for arch in $archs
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
94 done
95 echo '!MESSAGE' >> $TEMPLATE
98 # Project define.
100 cat $project_tmpl >> $TEMPLATE
103 # Architecture dependent configuration define.
105 for arch in $archs
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
132 done
135 # Target declare
137 echo >> $TEMPLATE
138 echo "# Begin Target" >> $TEMPLATE
139 for arch in $archs
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
145 done
148 # Source files
150 # (MI)
151 cat >> $TEMPLATE <<SRCS
153 # Begin Group "Source Files"
154 %%% SRCFILES %%%
156 SRCS
157 # (MD)
158 for arch in $archs
160 echo "%%% SRCFILES_$arch %%%" >> $TEMPLATE
161 done
163 # Footer.
165 cat >> $TEMPLATE <<FOOTER
167 # End Group
168 # End Target
169 # End Project
171 FOOTER
174 # Generate MD source files property.
176 for arch in $archs
178 ARCH_FILE="property.$arch"
179 rm -f $ARCH_FILE
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
194 done
195 # mv $ARCH_FILE $ARCH_FILE.0
196 # awk ' { printf "%s\r\n", $0 }' $ARCH_FILE.0 > $ARCH_FILE
197 # rm -f $ARCH_FILE.0
198 done
201 # Generate MD assembler files property and custom build method.
203 for arch in $archs
205 ARCH_FILE="asm_build.$arch.0"
206 rm -f $ARCH_FILE
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
220 else
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
238 done
239 done
242 # set assembler.
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
254 rm -f asm_build.SH.0
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