1 # $Id: mk-1st.awk,v 1.45 2000/08/19 19:13:19 tom Exp $
2 ##############################################################################
3 # Copyright (c) 1998,2000 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,2000
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 # ShlibVer ("rel", "abi" or "auto", to augment DoLinks variable)
43 # DoLinks ("yes", "reverse" or "no", flag to add symbolic links)
44 # rmSoLocs ("yes" or "no", flag to add extra clean target)
45 # overwrite ("yes" or "no", flag to add link to libcurses.a
48 # CLIXs nawk does not like underscores in command-line variable names.
50 # HP/UX requires shared libraries to have executable permissions.
52 function symlink(src,dst) {
54 printf "rm -f %s; ", dst
55 printf "$(LN_S) %s %s; ", src, dst
58 function rmlink(directory, dst) {
59 printf "\t-rm -f %s/%s\n", directory, dst
61 function removelinks(directory) {
62 rmlink(directory, end_name);
63 if ( DoLinks == "reverse" ) {
64 if ( ShlibVer == "rel" ) {
65 rmlink(directory, abi_name);
66 rmlink(directory, rel_name);
67 } else if ( ShlibVer == "abi" ) {
68 rmlink(directory, abi_name);
71 if ( ShlibVer == "rel" ) {
72 rmlink(directory, abi_name);
73 rmlink(directory, lib_name);
74 } else if ( ShlibVer == "abi" ) {
75 rmlink(directory, lib_name);
79 function sharedlinks(directory) {
80 if ( ShlibVer != "auto" ) {
81 printf "\tcd %s && (", directory
82 if ( DoLinks == "reverse" ) {
83 if ( ShlibVer == "rel" ) {
84 symlink(lib_name, abi_name);
85 symlink(abi_name, rel_name);
86 } else if ( ShlibVer == "abi" ) {
87 symlink(lib_name, abi_name);
90 if ( ShlibVer == "rel" ) {
91 symlink(rel_name, abi_name);
92 symlink(abi_name, lib_name);
93 } else if ( ShlibVer == "abi" ) {
94 symlink(abi_name, lib_name);
106 if (subset == "none") {
108 } else if (index(subset,$2) > 0) {
112 print "# generated by mk-1st.awk"
117 if ( subset == "termlib") {
129 if (traces != "all" && traces != MODEL && $1 != "lib_trace")
141 printf "%s_OBJS =", OBJS
147 printf " \\\n\t../%s/%s.o", model, $1
154 printf "\n$(%s_OBJS) : %s\n", OBJS, depend
159 lib_name = sprintf("%s%s%s", prefix, name, suffix)
160 if ( MODEL == "SHARED" )
162 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
163 rel_name = sprintf("%s.$(REL_VERSION)", lib_name);
164 if ( DoLinks == "reverse") {
167 if ( ShlibVer == "rel" ) {
169 } else if ( ShlibVer == "abi" ) {
175 printf "../lib/%s : $(%s_OBJS)\n", end_name, OBJS
177 if ( subset == "termlib") {
178 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(TINFO_LIST)\n", OBJS
180 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(SHLIB_LIST)\n", OBJS
182 sharedlinks("../lib")
185 print "install.libs \\"
186 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, end_name
187 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", end_name, end_name
188 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", end_name
189 printf "\t$(INSTALL_LIB) ../lib/%s $(DESTDIR)$(libdir)/%s\n", end_name, end_name
190 sharedlinks("$(DESTDIR)$(libdir)")
191 if ( overwrite == "yes" && name == "ncurses" )
193 ovr_name = sprintf("libcurses%s", suffix)
194 printf "\t@echo linking %s to %s\n", end_name, ovr_name
195 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, end_name, ovr_name
197 if ( ldconfig != "" ) {
198 printf "\t- test -z \"$(DESTDIR)\" && %s\n", ldconfig
202 print "uninstall.libs \\"
203 printf "uninstall.%s ::\n", name
204 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", end_name
205 removelinks("$(DESTDIR)$(libdir)")
206 if ( overwrite == "yes" && name == "ncurses" )
208 ovr_name = sprintf("libcurses%s", suffix)
209 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", ovr_name
211 if ( rmSoLocs == "yes" ) {
213 print "mostlyclean \\"
215 printf "\t-@rm -f so_locations\n"
221 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
222 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
223 printf "\t$(RANLIB) $@\n"
224 if ( target == "vxworks" )
226 printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=.o)\n"
230 print "install.libs \\"
231 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
232 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
233 printf "\t$(INSTALL_DATA) ../lib/%s $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
234 if ( overwrite == "yes" && lib_name == "libncurses.a" )
236 printf "\t@echo linking libcurses.a to libncurses.a\n"
237 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
238 printf "\t(cd $(DESTDIR)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
240 printf "\t$(RANLIB) $(DESTDIR)$(libdir)/%s\n", lib_name
241 if ( target == "vxworks" )
243 printf "\t@echo installing ../lib/lib%s.o as $(DESTDIR)$(libdir)/lib%s.o\n", name, name
244 printf "\t$(INSTALL_DATA) ../lib/lib%s.o $(DESTDIR)$(libdir)/lib%s.o\n", name, name
248 print "uninstall.libs \\"
249 printf "uninstall.%s ::\n", name
250 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
251 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
252 if ( overwrite == "yes" && lib_name == "libncurses.a" )
254 printf "\t@echo linking libcurses.a to libncurses.a\n"
255 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
257 if ( target == "vxworks" )
259 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/lib%s.o\n", name
260 printf "\t-@rm -f $(DESTDIR)$(libdir)/lib%s.o\n", name
265 removelinks("../lib");
267 print "mostlyclean::"
268 printf "\t-rm -f $(%s_OBJS)\n", OBJS
270 else if ( found == 2 )
273 print "mostlyclean::"
274 printf "\t-rm -f $(%s_OBJS)\n", OBJS
277 printf "\t-rm -f $(%s_OBJS)\n", OBJS