No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hpc / stand / dspgen / do_subst.awk
blob55c05c57c0733eba6c0541febf68733562fe31fb
1 # $NetBSD: do_subst.awk,v 1.4 2001/04/15 12:27:32 takemura Exp $
3 # Copyright (c) 1999, 2000 Christopher G. Demetriou. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # 3. All advertising materials mentioning features or use of this software
14 # must display the following acknowledgement:
15 # This product includes software developed by Christopher G. Demetriou
16 # for the NetBSD Project.
17 # 4. The name of the author may not be used to endorse or promote products
18 # derived from this software without specific prior written permission
20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 function setup_md_files (arch, env, srclist) {
32 srclist=""
33 asm_tmpl="dspgen/asm_build." arch
34 prop_tmpl="dspgen/property." arch
36 sz = split(ENVIRON[env], a, "[ \t\n]+");
37 for (i = 1; i <= sz; i++) {
38 if (a[i] == "") {
39 continue
41 if (srclist != "") {
42 srclist=srclist "\n"
44 srclist=srclist "# Begin Source File\n"
45 srclist=srclist "\n"
46 srclist=srclist "SOURCE=.\\" a[i] "\n"
47 base = index (a[i], ".asm")
48 if (base != 0) {
49 basename = substr (a[i], 0, base - 1)
50 while (getline < asm_tmpl > 0) {
51 gsub ("%%% ASM_BASENAME %%%", basename)
52 srclist=srclist $0 "\n"
54 close (asm_tmpl)
55 } else {
56 while (getline < prop_tmpl > 0)
57 srclist=srclist $0 "\n"
58 close (prop_tmpl)
60 srclist=srclist "# End Source File"
62 return srclist
65 BEGIN {
66 NAME=ENVIRON["NAME"]
68 SRCFILES=""
69 sz = split(ENVIRON["SRCFILE_LIST"], a, "[ \t\n]+");
70 for (i = 1; i <= sz; i++) {
71 if (a[i] == "") {
72 continue
74 if (SRCFILES != "") {
75 SRCFILES=SRCFILES "\n"
77 SRCFILES=SRCFILES "# Begin Source File\n"
78 SRCFILES=SRCFILES "\n"
79 SRCFILES=SRCFILES "SOURCE=.\\" a[i] "\n"
80 SRCFILES=SRCFILES "# End Source File"
83 SRCFILES_ARM = setup_md_files("ARM", "SRCFILE_LIST_ARM", SRCFILES_ARM)
84 SRCFILES_ARMV4 = setup_md_files("ARMV4", "SRCFILE_LIST_ARM", SRCFILES_ARM)
85 SRCFILES_SH3 = setup_md_files("SH3", "SRCFILE_LIST_SH3", SRCFILES_SH3)
86 SRCFILES_SH4 = setup_md_files("SH4", "SRCFILE_LIST_SH3", SRCFILES_SH3)
87 SRCFILES_SH = setup_md_files("SH", "SRCFILE_LIST_SH3", SRCFILES_SH3)
88 SRCFILES_MIPS = setup_md_files("MIPS", "SRCFILE_LIST_MIPS",
89 SRCFILES_MIPS)
91 CPPDEFS=""
92 sz = split(ENVIRON["STD_CPPDEF_LIST"], a, "[ \t\n]+");
93 for (i = 1; i <= sz; i++) {
94 if (a[i] == "") {
95 continue
97 if (CPPDEFS != "") {
98 CPPDEFS=CPPDEFS " "
100 a[i] = gensub("([^\\\\]|^)#", "\\1 ", "g", a[i])
101 a[i] = gensub("\\\\#", "#", "g", a[i])
102 CPPDEFS=CPPDEFS "/D " a[i]
104 sz = split(ENVIRON["CPPDEF_LIST"], a, "[ \t\n]+");
105 for (i = 1; i <= sz; i++) {
106 if (a[i] == "") {
107 continue
109 if (CPPDEFS != "") {
110 CPPDEFS=CPPDEFS " "
112 a[i] = gensub("([^\\\\]|^)#", "\\1 ", "g", a[i])
113 a[i] = gensub("\\\\#", "#", "g", a[i])
114 CPPDEFS=CPPDEFS "/D " a[i]
117 INCDIRS=""
118 sz = split(ENVIRON["STD_INCDIR_LIST"], a, "[ \t\n]+");
119 for (i = 1; i <= sz; i++) {
120 if (a[i] == "") {
121 continue
123 if (INCDIRS != "") {
124 INCDIRS=INCDIRS " "
126 INCDIRS=INCDIRS "/I \"" a[i] "\""
128 sz = split(ENVIRON["INCDIR_LIST"], a, "[ \t\n]+");
129 for (i = 1; i <= sz; i++) {
130 if (a[i] == "") {
131 continue
133 if (INCDIRS != "") {
134 INCDIRS=INCDIRS " "
136 INCDIRS=INCDIRS "/I \"" a[i] "\""
138 sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
139 for (i = 1; i <= sz; i++) {
140 if (a[i] == "") {
141 continue
143 if (INCDIRS != "") {
144 INCDIRS=INCDIRS " "
146 INCDIRS=INCDIRS "/I \"..\\" a[i] "\""
149 LIBRARIES=""
150 sz = split(ENVIRON["STD_LIBRARY_LIST"], a, "[ \t\n]+");
151 for (i = 1; i <= sz; i++) {
152 if (a[i] == "") {
153 continue
155 if (LIBRARIES != "") {
156 LIBRARIES=LIBRARIES " "
158 LIBRARIES=LIBRARIES a[i] ".lib"
160 sz = split(ENVIRON["LIBRARY_LIST"], a, "[ \t\n]+");
161 for (i = 1; i <= sz; i++) {
162 if (a[i] == "") {
163 continue
165 if (LIBRARIES != "") {
166 LIBRARIES=LIBRARIES " "
168 LIBRARIES=LIBRARIES a[i] ".lib"
170 sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
171 for (i = 1; i <= sz; i++) {
172 if (a[i] == "") {
173 continue
175 if (LIBRARIES != "") {
176 LIBRARIES=LIBRARIES " "
178 LIBRARIES=LIBRARIES a[i] ".lib"
181 sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
182 DEBUG_LIBPATH=""
183 RELEASE_LIBPATH=""
184 for (i = 1; i <= sz; i++) {
185 if (a[i] == "") {
186 continue
188 if (i > 1) {
189 DEBUG_LIBPATH=DEBUG_LIBPATH " "
190 RELEASE_LIBPATH=RELEASE_LIBPATH " "
192 DEBUG_LIBPATH=DEBUG_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSDbg\""
193 RELEASE_LIBPATH=RELEASE_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSRel\""
197 gsub("%%% SRCFILES %%%", SRCFILES)
198 gsub("%%% SRCFILES_ARM %%%", SRCFILES_ARM)
199 gsub("%%% SRCFILES_ARMV4 %%%", SRCFILES_ARMV4)
200 gsub("%%% SRCFILES_SH3 %%%", SRCFILES_SH3)
201 gsub("%%% SRCFILES_SH4 %%%", SRCFILES_SH4)
202 gsub("%%% SRCFILES_SH %%%", SRCFILES_SH)
203 gsub("%%% SRCFILES_MIPS %%%", SRCFILES_MIPS)
204 gsub("%%% CPPDEFS %%%", CPPDEFS)
205 gsub("%%% INCDIRS %%%", INCDIRS)
206 gsub("%%% LIBRARIES %%%", LIBRARIES)
207 gsub("%%% DEBUG_LIBPATH %%%", DEBUG_LIBPATH)
208 gsub("%%% RELEASE_LIBPATH %%%", RELEASE_LIBPATH)
209 gsub("%%% NAME %%%", NAME)
210 print $0