1 # $Id: mk-1st.awk,v 1.35 1998/02/11 12:13:53 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" 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 printf "rm -f %s; ", dst
54 printf "$(LN_S) %s %s; ", src, dst
57 function sharedlinks(directory, add) {
58 if ( end_name != lib_name ) {
59 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
61 printf "\tcd %s && (", directory
62 symlink(end_name, abi_name);
63 symlink(abi_name, lib_name);
66 printf "\t-@rm -f %s/%s\n", directory, abi_name
67 printf "\t-@rm -f %s/%s\n", directory, lib_name
71 function removelinks() {
72 if ( end_name != lib_name ) {
73 printf "\trm -f ../lib/%s ../lib/%s\n", abi_name, end_name
76 function installed_name() {
77 if ( DO_LINKS == "yes" ) {
78 return sprintf("%s.$(REL_VERSION)", lib_name);
89 if (subset == "none") {
91 } else if (index(subset,$2) > 0) {
95 print "# generated by mk-1st.awk"
100 if ( subset == "termlib") {
117 printf "%s_OBJS =", OBJS
123 printf " \\\n\t../%s/%s.o", model, $1
130 printf "\n$(%s_OBJS) : %s\n", OBJS, depend
135 lib_name = sprintf("%s%s%s", prefix, name, suffix)
136 if ( MODEL == "SHARED" )
138 if ( DoLinks == "yes" ) {
139 end_name = sprintf("%s.$(REL_VERSION)", lib_name);
143 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
145 printf "\t$(MK_SHARED_LIB) $(%s_OBJS)\n", OBJS
146 sharedlinks("../lib", 1)
148 if ( end_name != lib_name ) {
149 printf "../lib/%s : ../lib/%s\n", end_name, lib_name
153 print "install.libs \\"
154 printf "install.%s :: $(INSTALL_PREFIX)$(libdir) ../lib/%s\n", name, end_name
155 printf "\t@echo installing ../lib/%s as $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, end_name
156 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", end_name
157 printf "\t$(INSTALL_LIB) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, end_name
158 sharedlinks("$(INSTALL_PREFIX)$(libdir)", 1)
159 if ( overwrite == "yes" && name == "ncurses" )
161 ovr_name = sprintf("libcurses%s", suffix)
162 printf "\t@echo linking %s to %s\n", ovr_name, lib_name
163 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", ovr_name
164 printf "\t(cd $(INSTALL_PREFIX)$(libdir) && $(LN_S) %s %s)\n", lib_name, ovr_name
166 if ( ldconfig != "" ) {
167 printf "\t- test -z \"$(INSTALL_PREFIX)\" && %s\n", ldconfig
171 print "uninstall.libs \\"
172 printf "uninstall.%s ::\n", name
173 printf "\t@echo uninstalling $(INSTALL_PREFIX)$(libdir)/%s \n", end_name
174 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s\n", end_name
175 sharedlinks("$(INSTALL_PREFIX)$(libdir)", 0)
176 if ( overwrite == "yes" && name == "ncurses" )
178 ovr_name = sprintf("libcurses%s", suffix)
179 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", ovr_name
181 if ( rmSoLocs == "yes" ) {
183 print "mostlyclean \\"
185 printf "\t-@rm -f so_locations\n"
191 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
192 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
193 printf "\t$(RANLIB) $@\n"
194 if ( target == "vxworks" )
196 printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=.o)\n"
200 print "install.libs \\"
201 printf "install.%s :: $(INSTALL_PREFIX)$(libdir) ../lib/%s\n", name, lib_name
202 printf "\t@echo installing ../lib/%s as $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
203 printf "\t$(INSTALL_DATA) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
204 if ( overwrite == "yes" && lib_name == "libncurses.a" )
206 printf "\t@echo linking libcurses.a to libncurses.a \n"
207 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/libcurses.a \n"
208 printf "\t(cd $(INSTALL_PREFIX)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
210 printf "\t$(RANLIB) $(INSTALL_PREFIX)$(libdir)/%s\n", lib_name
211 if ( target == "vxworks" )
213 printf "\t@echo installing ../lib/lib%s.o as $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name, name
214 printf "\t$(INSTALL_DATA) ../lib/lib%s.o $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name, name
218 print "uninstall.libs \\"
219 printf "uninstall.%s ::\n", name
220 printf "\t@echo uninstalling $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name
221 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/%s\n", lib_name
222 if ( overwrite == "yes" && lib_name == "libncurses.a" )
224 printf "\t@echo linking libcurses.a to libncurses.a \n"
225 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/libcurses.a \n"
227 if ( target == "vxworks" )
229 printf "\t@echo uninstalling $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name
230 printf "\t-@rm -f $(INSTALL_PREFIX)$(libdir)/lib%s.o\n", name
235 printf "\trm -f ../lib/%s\n", lib_name
237 print "mostlyclean::"
238 printf "\trm -f $(%s_OBJS)\n", OBJS
241 printf "\trm -f $(%s_OBJS)\n", OBJS
244 else if ( found == 2 )
247 print "mostlyclean::"
248 printf "\trm -f $(%s_OBJS)\n", OBJS
251 printf "\trm -f $(%s_OBJS)\n", OBJS