1 # $Id: mk-1st.awk,v 1.39 1998/05/09 21:54:02 tom Exp $
2 ##############################################################################
3 # Copyright (c) 1998 Free Software Foundation, Inc. #
5 # Permission is hereby granted, free of charge, to any person obtaining a #
6 # copy of this software and associated documentation files (the "Software"), #
7 # to deal in the Software without restriction, including without limitation #
8 # the rights to use, copy, modify, merge, publish, distribute, distribute #
9 # with modifications, sublicense, and/or sell copies of the Software, and to #
10 # permit persons to whom the Software is furnished to do so, subject to the #
11 # following conditions: #
13 # The above copyright notice and this permission notice shall be included in #
14 # all copies or substantial portions of the Software. #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
19 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
22 # DEALINGS IN THE SOFTWARE. #
24 # Except as contained in this notice, the name(s) of the above copyright #
25 # holders shall not be used in advertising or otherwise to promote the sale, #
26 # use or other dealings in this Software without prior written #
28 ##############################################################################
30 # Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
32 # Generate list of objects for a given model library
34 # name (library name, e.g., "ncurses", "panel", "forms", "menus")
35 # model (directory into which we compile, e.g., "obj")
36 # prefix (e.g., "lib", for Unix-style libraries)
37 # suffix (e.g., "_g.a", for debug libraries)
38 # MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
39 # depend (optional dependencies for all objects, e.g, ncurses_cfg.h)
40 # subset ("none", "base", "base+ext_funcs" or "termlib")
41 # target (cross-compile target, if any)
42 # DoLinks ("yes", "reverse" or "no", flag to add symbolic links)
43 # rmSoLocs ("yes" or "no", flag to add extra clean target)
44 # overwrite ("yes" or "no", flag to add link to libcurses.a
47 # CLIXs nawk does not like underscores in command-line variable names.
49 # HP/UX requires shared libraries to have executable permissions.
51 function symlink(src,dst) {
53 if ( DoLinks == "reverse" ) {
54 printf "rm -f %s; ", src
55 printf "$(LN_S) %s %s; ", dst, src
57 printf "rm -f %s; ", dst
58 printf "$(LN_S) %s %s; ", src, dst
62 function sharedlinks(directory, add) {
63 if ( end_name != lib_name ) {
64 if ( DoLinks == "yes" ) {
65 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
70 printf "\tcd %s && (", directory
71 if ( abi_name != end_name ) {
72 symlink(end_name, abi_name);
74 symlink(abi_name, lib_name);
77 if ( abi_name != end_name ) {
78 printf "\t-@rm -f %s/%s\n", directory, abi_name
80 printf "\t-@rm -f %s/%s\n", directory, lib_name
84 function removelinks() {
85 if ( end_name != lib_name ) {
86 if ( abi_name != end_name ) {
87 printf "\t-rm -f ../lib/%s\n", abi_name
89 printf "\t-rm -f ../lib/%s\n", end_name
98 if (subset == "none") {
100 } else if (index(subset,$2) > 0) {
104 print "# generated by mk-1st.awk"
109 if ( subset == "termlib") {
126 printf "%s_OBJS =", OBJS
132 printf " \\\n\t../%s/%s.o", model, $1
139 printf "\n$(%s_OBJS) : %s\n", OBJS, depend
144 lib_name = sprintf("%s%s%s", prefix, name, suffix)
145 if ( MODEL == "SHARED" )
147 if ( DoLinks == "yes" ) {
148 end_name = sprintf("%s.$(REL_VERSION)", lib_name);
149 } else if ( DoLinks == "reverse") {
150 tmp_name = sprintf("%s.$(ABI_VERSION)", lib_name);
156 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
158 if ( subset == "termlib") {
159 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(TINFO_LIST)\n", OBJS
161 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(SHLIB_LIST)\n", OBJS
163 sharedlinks("../lib", 1)
165 if ( end_name != lib_name ) {
166 printf "../lib/%s : ../lib/%s\n", end_name, lib_name
170 print "install.libs \\"
171 printf "install.%s :: $(INSTALL_PREFIX)$(libdir) ../lib/%s\n", name, end_name
172 printf "\t@echo installing ../lib/%s as $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, end_name
173 if ( DoLinks == "reverse") {
174 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name
175 printf "\t$(INSTALL_LIB) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
177 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", end_name
178 printf "\t$(INSTALL_LIB) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, end_name
180 sharedlinks("$(INSTALL_PREFIX)$(libdir)", 1)
181 if ( overwrite == "yes" && name == "ncurses" )
183 ovr_name = sprintf("libcurses%s", suffix)
184 printf "\t@echo linking %s to %s\n", lib_name, ovr_name
185 printf "\tcd $(INSTALL_PREFIX)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, lib_name, ovr_name
187 if ( ldconfig != "" ) {
188 printf "\t- test -z \"$(INSTALL_PREFIX)\" && %s\n", ldconfig
192 print "uninstall.libs \\"
193 printf "uninstall.%s ::\n", name
194 printf "\t@echo uninstalling $(INSTALL_PREFIX)$(libdir)/%s \n", end_name
195 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s\n", end_name
196 sharedlinks("$(INSTALL_PREFIX)$(libdir)", 0)
197 if ( overwrite == "yes" && name == "ncurses" )
199 ovr_name = sprintf("libcurses%s", suffix)
200 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", ovr_name
202 if ( rmSoLocs == "yes" ) {
204 print "mostlyclean \\"
206 printf "\t-@rm -f so_locations\n"
212 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
213 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
214 printf "\t$(RANLIB) $@\n"
215 if ( target == "vxworks" )
217 printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=.o)\n"
221 print "install.libs \\"
222 printf "install.%s :: $(INSTALL_PREFIX)$(libdir) ../lib/%s\n", name, lib_name
223 printf "\t@echo installing ../lib/%s as $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
224 printf "\t$(INSTALL_DATA) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
225 if ( overwrite == "yes" && lib_name == "libncurses.a" )
227 printf "\t@echo linking libcurses.a to libncurses.a \n"
228 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/libcurses.a \n"
229 printf "\t(cd $(INSTALL_PREFIX)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
231 printf "\t$(RANLIB) $(INSTALL_PREFIX)$(libdir)/%s\n", lib_name
232 if ( target == "vxworks" )
234 printf "\t@echo installing ../lib/lib%s.o as $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name, name
235 printf "\t$(INSTALL_DATA) ../lib/lib%s.o $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name, name
239 print "uninstall.libs \\"
240 printf "uninstall.%s ::\n", name
241 printf "\t@echo uninstalling $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name
242 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s\n", lib_name
243 if ( overwrite == "yes" && lib_name == "libncurses.a" )
245 printf "\t@echo linking libcurses.a to libncurses.a \n"
246 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/libcurses.a \n"
248 if ( target == "vxworks" )
250 printf "\t@echo uninstalling $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name
251 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name
256 printf "\t-rm -f ../lib/%s\n", lib_name
258 print "mostlyclean::"
259 printf "\t-rm -f $(%s_OBJS)\n", OBJS
264 else if ( found == 2 )
267 print "mostlyclean::"
268 printf "\t-rm -f $(%s_OBJS)\n", OBJS
271 printf "\t-rm -f $(%s_OBJS)\n", OBJS