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
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
) {
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
++) {
44 srclist=srclist
"# Begin Source File\n"
46 srclist=srclist
"SOURCE=.\\" a
[i
] "\n"
47 base =
index (a
[i
], ".asm")
49 basename =
substr (a
[i
], 0, base
- 1)
50 while (getline < asm_tmpl
> 0) {
51 gsub ("%%% ASM_BASENAME %%%", basename)
52 srclist=srclist $0 "\n"
56 while (getline < prop_tmpl > 0)
57 srclist=srclist $0 "\n"
60 srclist=srclist "# End Source File"
69 sz =
split(ENVIRON["SRCFILE_LIST"], a
, "[ \t\n]+");
70 for (i =
1; i
<= sz
; i
++) {
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",
92 sz =
split(ENVIRON["STD_CPPDEF_LIST"], a
, "[ \t\n]+");
93 for (i =
1; i
<= sz
; i
++) {
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
++) {
112 a
[i
] = gensub
("([^\\\\]|^)#", "\\1 ", "g", a
[i
])
113 a
[i
] = gensub
("\\\\#", "#", "g", a
[i
])
114 CPPDEFS=CPPDEFS
"/D " a
[i
]
118 sz =
split(ENVIRON["STD_INCDIR_LIST"], a
, "[ \t\n]+");
119 for (i =
1; i
<= sz
; i
++) {
126 INCDIRS=INCDIRS
"/I \"" a
[i
] "\""
128 sz =
split(ENVIRON["INCDIR_LIST"], a
, "[ \t\n]+");
129 for (i =
1; i
<= sz
; i
++) {
136 INCDIRS=INCDIRS
"/I \"" a
[i
] "\""
138 sz =
split(ENVIRON["LIBDEP_LIST"], a
, "[ \t\n]+");
139 for (i =
1; i
<= sz
; i
++) {
146 INCDIRS=INCDIRS
"/I \"..\\" a
[i
] "\""
150 sz =
split(ENVIRON["STD_LIBRARY_LIST"], a
, "[ \t\n]+");
151 for (i =
1; i
<= sz
; i
++) {
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
++) {
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
++) {
175 if (LIBRARIES
!= "") {
176 LIBRARIES=LIBRARIES
" "
178 LIBRARIES=LIBRARIES a
[i
] ".lib"
181 sz =
split(ENVIRON["LIBDEP_LIST"], a
, "[ \t\n]+");
184 for (i =
1; i
<= sz
; i
++) {
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)