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