do_subst.sh revision 1.2 1 # $NetBSD: do_subst.sh,v 1.2 2000/02/03 19:16:47 cgd Exp $
2 #
3 # Copyright (c) 1999, 2000 Christopher G. Demetriou. All rights reserved.
4 #
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
19 #
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.
30
31 if [ "X$1" = "X--show-libdeps" ]; then
32 if ! expr "X$TYPE" : 'Xconsole_program.*' > /dev/null 2>&1 &&
33 ! expr "X$TYPE" : 'Xapplication.*' > /dev/null 2>&1; then
34 exit
35 fi
36 ( for lib in $LIBDEP_LIST; do
37 echo $lib
38 done ) | sort
39 exit
40 fi
41
42 AWK=awk
43 if [ `uname` = SunOS ]; then
44 AWK=nawk
45 fi
46
47 STD_CPPDEF_LIST=''
48 STD_INCDIR_LIST=''
49 STD_LIBRARY_LIST=''
50
51 export NAME
52 export SRCFILE_LIST
53 export CPPDEF_LIST STD_CPPDEF_LIST
54 export INCDIR_LIST STD_INCDIR_LIST
55 export LIBDEP_LIST
56 export LIBRARY_LIST STD_LIBRARY_LIST
57
58 ${AWK} '
59 BEGIN {
60 NAME=ENVIRON["NAME"]
61
62 SRCFILES=""
63 sz = split(ENVIRON["SRCFILE_LIST"], a, "[ \t\n]+");
64 for (i = 1; i <= sz; i++) {
65 if (a[i] == "") {
66 continue
67 }
68 if (SRCFILES != "") {
69 SRCFILES=SRCFILES "\n"
70 }
71 SRCFILES=SRCFILES "# Begin Source File\n"
72 SRCFILES=SRCFILES "\n"
73 SRCFILES=SRCFILES "SOURCE=.\\" a[i] "\n"
74 SRCFILES=SRCFILES "# End Source File"
75 }
76
77 CPPDEFS=""
78 sz = split(ENVIRON["STD_CPPDEF_LIST"], a, "[ \t\n]+");
79 for (i = 1; i <= sz; i++) {
80 if (a[i] == "") {
81 continue
82 }
83 if (CPPDEFS != "") {
84 CPPDEFS=CPPDEFS " "
85 }
86 CPPDEFS=CPPDEFS "/D \"" a[i] "\""
87 }
88 sz = split(ENVIRON["CPPDEF_LIST"], a, "[ \t\n]+");
89 for (i = 1; i <= sz; i++) {
90 if (a[i] == "") {
91 continue
92 }
93 if (CPPDEFS != "") {
94 CPPDEFS=CPPDEFS " "
95 }
96 CPPDEFS=CPPDEFS "/D \"" a[i] "\""
97 }
98
99 INCDIRS=""
100 sz = split(ENVIRON["STD_INCDIR_LIST"], a, "[ \t\n]+");
101 for (i = 1; i <= sz; i++) {
102 if (a[i] == "") {
103 continue
104 }
105 if (INCDIRS != "") {
106 INCDIRS=INCDIRS " "
107 }
108 INCDIRS=INCDIRS "/I \"" a[i] "\""
109 }
110 sz = split(ENVIRON["INCDIR_LIST"], a, "[ \t\n]+");
111 for (i = 1; i <= sz; i++) {
112 if (a[i] == "") {
113 continue
114 }
115 if (INCDIRS != "") {
116 INCDIRS=INCDIRS " "
117 }
118 INCDIRS=INCDIRS "/I \"" a[i] "\""
119 }
120 sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
121 for (i = 1; i <= sz; i++) {
122 if (a[i] == "") {
123 continue
124 }
125 if (INCDIRS != "") {
126 INCDIRS=INCDIRS " "
127 }
128 INCDIRS=INCDIRS "/I \"..\\" a[i] "\""
129 }
130
131 LIBRARIES=""
132 sz = split(ENVIRON["STD_LIBRARY_LIST"], a, "[ \t\n]+");
133 for (i = 1; i <= sz; i++) {
134 if (a[i] == "") {
135 continue
136 }
137 if (LIBRARIES != "") {
138 LIBRARIES=LIBRARIES " "
139 }
140 LIBRARIES=LIBRARIES a[i] ".lib"
141 }
142 sz = split(ENVIRON["LIBRARY_LIST"], a, "[ \t\n]+");
143 for (i = 1; i <= sz; i++) {
144 if (a[i] == "") {
145 continue
146 }
147 if (LIBRARIES != "") {
148 LIBRARIES=LIBRARIES " "
149 }
150 LIBRARIES=LIBRARIES a[i] ".lib"
151 }
152 sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
153 for (i = 1; i <= sz; i++) {
154 if (a[i] == "") {
155 continue
156 }
157 if (LIBRARIES != "") {
158 LIBRARIES=LIBRARIES " "
159 }
160 LIBRARIES=LIBRARIES a[i] ".lib"
161 }
162
163 sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
164 DEBUG_LIBPATH=""
165 RELEASE_LIBPATH=""
166 for (i = 1; i <= sz; i++) {
167 if (a[i] == "") {
168 continue
169 }
170 if (i > 1) {
171 DEBUG_LIBPATH=DEBUG_LIBPATH " "
172 RELEASE_LIBPATH=RELEASE_LIBPATH " "
173 }
174 DEBUG_LIBPATH=DEBUG_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSDbg\""
175 RELEASE_LIBPATH=RELEASE_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSRel\""
176 }
177 }
178 {
179 gsub("%%% NAME %%%", NAME)
180 gsub("%%% SRCFILES %%%", SRCFILES)
181 gsub("%%% CPPDEFS %%%", CPPDEFS)
182 gsub("%%% INCDIRS %%%", INCDIRS)
183 gsub("%%% LIBRARIES %%%", LIBRARIES)
184 gsub("%%% DEBUG_LIBPATH %%%", DEBUG_LIBPATH)
185 gsub("%%% RELEASE_LIBPATH %%%", RELEASE_LIBPATH)
186 print $0
187 }
188 ' ../dspgen/${TYPE}.tmpl | awk ' { printf "%s\r\n", $0 }' > ${NAME}.dsp
189