1 # $Id: mk-1st.awk,v 1.65 2005/06/18 19:15:57 tom Exp $
2 ##############################################################################
3 # Copyright (c) 1998-2004,2005 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
32 # Generate list of objects for a given model library
34 # name (library name, e.g., "ncurses", "panel", "forms", "menus")
35 # traces ("all" or "DEBUG", to control whether tracing is compiled in)
36 # MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
37 # model (directory into which we compile, e.g., "obj")
38 # prefix (e.g., "lib", for Unix-style libraries)
39 # suffix (e.g., "_g.a", for debug libraries)
40 # subset ("none", "base", "base+ext_funcs" or "termlib")
41 # ShlibVer ("rel", "abi" or "auto", to augment DoLinks variable)
42 # ShlibVerInfix ("yes" or "no", determines location of version #)
43 # DoLinks ("yes", "reverse" or "no", flag to add symbolic links)
44 # rmSoLocs ("yes" or "no", flag to add extra clean target)
45 # ldconfig (path for this tool, if used)
46 # overwrite ("yes" or "no", flag to add link to libcurses.a
47 # depend (optional dependencies for all objects, e.g, ncurses_cfg.h)
48 # host (cross-compile host, if any)
51 # CLIXs nawk does not like underscores in command-line variable names.
53 # HP/UX requires shared libraries to have executable permissions.
55 function symlink(src,dst) {
57 printf "rm -f %s; ", dst
58 printf "$(LN_S) %s %s; ", src, dst
61 function rmlink(directory, dst) {
62 printf "\t-rm -f %s/%s\n", directory, dst
64 function removelinks(directory) {
65 rmlink(directory, end_name);
66 if ( DoLinks == "reverse" ) {
67 if ( ShlibVer == "rel" ) {
68 rmlink(directory, abi_name);
69 rmlink(directory, rel_name);
70 } else if ( ShlibVer == "abi" ) {
71 rmlink(directory, abi_name);
74 if ( ShlibVer == "rel" ) {
75 rmlink(directory, abi_name);
76 rmlink(directory, lib_name);
77 } else if ( ShlibVer == "abi" ) {
78 rmlink(directory, lib_name);
82 function sharedlinks(directory) {
83 if ( ShlibVer != "auto" && ShlibVer != "cygdll" ) {
84 printf "\tcd %s && (", directory
85 if ( DoLinks == "reverse" ) {
86 if ( ShlibVer == "rel" ) {
87 symlink(lib_name, abi_name);
88 symlink(abi_name, rel_name);
89 } else if ( ShlibVer == "abi" ) {
90 symlink(lib_name, abi_name);
93 if ( ShlibVer == "rel" ) {
94 symlink(rel_name, abi_name);
95 symlink(abi_name, lib_name);
96 } else if ( ShlibVer == "abi" ) {
97 symlink(abi_name, lib_name);
109 if (subset == "none") {
111 } else if (index(subset,$2) > 0) {
115 printf "# generated by mk-1st.awk (subset=%s)\n", subset
116 printf "# name: %s\n", name
117 printf "# traces: %s\n", traces
118 printf "# MODEL: %s\n", MODEL
119 printf "# model: %s\n", model
120 printf "# prefix: %s\n", prefix
121 printf "# suffix: %s\n", suffix
122 printf "# subset: %s\n", subset
123 printf "# ShlibVer: %s\n", ShlibVer
124 printf "# ShlibVerInfix: %s\n", ShlibVerInfix
125 printf "# DoLinks: %s\n", DoLinks
126 printf "# rmSoLocs: %s\n", rmSoLocs
127 printf "# ldconfig: %s\n", ldconfig
128 printf "# overwrite: %s\n", overwrite
129 printf "# depend: %s\n", depend
130 printf "# host: %s\n", host
135 if ( subset == "termlib" || subset == "termlib+ext_tinfo" ) {
146 if (traces != "all" && traces != MODEL && $1 != "lib_trace")
151 && ( $1 != "link_test" ) \
159 printf "%s_OBJS =", OBJS
165 printf " \\\n\t../%s/%s$o", model, $1
172 printf "\n$(%s_OBJS) : %s\n", OBJS, depend
177 lib_name = sprintf("%s%s%s", prefix, name, suffix)
178 if ( MODEL == "SHARED" )
180 if (ShlibVerInfix == "cygdll") {
181 abi_name = sprintf("%s%s$(ABI_VERSION)%s", "cyg", name, suffix);
182 rel_name = sprintf("%s%s$(REL_VERSION)%s", "cyg", name, suffix);
183 imp_name = sprintf("%s%s%s.a", prefix, name, suffix);
184 } else if (ShlibVerInfix == "yes") {
185 abi_name = sprintf("%s%s.$(ABI_VERSION)%s", prefix, name, suffix);
186 rel_name = sprintf("%s%s.$(REL_VERSION)%s", prefix, name, suffix);
188 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
189 rel_name = sprintf("%s.$(REL_VERSION)", lib_name);
191 if ( DoLinks == "reverse") {
194 if ( ShlibVer == "rel" ) {
196 } else if ( ShlibVer == "abi" || ShlibVer == "cygdll" ) {
203 if ( ShlibVer == "cygdll" ) {
204 dst_dirs = "$(DESTDIR)$(bindir) $(DESTDIR)$(libdir)";
205 printf "$(SHARED_LIB) $(IMPORT_LIB) : $(%s_OBJS)\n", OBJS;
206 print "\t-@rm -f $(SHARED_LIB) $(IMPORT_LIB)";
208 dst_dirs = "$(DESTDIR)$(libdir)";
209 printf "../lib/%s : $(%s_OBJS)\n", end_name, OBJS
210 print "\t-@rm -f $@";
212 if ( subset == "termlib" || subset == "termlib+ext_tinfo" ) {
213 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(TINFO_LIST) $(LDFLAGS)\n", OBJS
215 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(SHLIB_LIST) $(LDFLAGS)\n", OBJS
217 sharedlinks("../lib")
221 print "install.libs \\"
222 printf "install.%s :: %s $(LIBRARIES)\n", name, dst_dirs
224 if ( ShlibVer == "cygdll" ) {
226 src_name = sprintf("../lib/%s", end_name);
227 dst_name = sprintf("$(DESTDIR)$(bindir)/%s", end_name);
228 printf "\t@echo installing %s as %s\n", src_name, dst_name
229 printf "\t-@rm -f %s\n", dst_name
230 printf "\t$(INSTALL_LIB) %s %s\n", src_name, dst_name
232 src_name = sprintf("../lib/%s", imp_name);
233 dst_name = sprintf("$(DESTDIR)$(libdir)/%s", imp_name);
234 printf "\t@echo installing %s as %s\n", src_name, dst_name
235 printf "\t-@rm -f %s\n", dst_name
236 printf "\t$(INSTALL_LIB) %s %s\n", src_name, dst_name
240 src_name = sprintf("../lib/%s", end_name);
241 dst_name = sprintf("$(DESTDIR)$(libdir)/%s", end_name);
242 printf "\t@echo installing %s as %s\n", src_name, dst_name
243 printf "\t-@rm -f %s\n", dst_name
244 printf "\t$(INSTALL_LIB) %s %s\n", src_name, dst_name
246 sharedlinks("$(DESTDIR)$(libdir)")
250 if ( overwrite == "yes" && name == "ncurses" )
252 if ( ShlibVer == "cygdll" ) {
253 ovr_name = sprintf("libcurses%s.a", suffix)
254 printf "\t@echo linking %s to %s\n", imp_name, ovr_name
255 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, imp_name, ovr_name
257 ovr_name = sprintf("libcurses%s", suffix)
258 printf "\t@echo linking %s to %s\n", end_name, ovr_name
259 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, end_name, ovr_name
262 if ( ldconfig != "" ) {
263 printf "\t- test -z \"$(DESTDIR)\" && %s\n", ldconfig
267 print "uninstall.libs \\"
268 printf "uninstall.%s ::\n", name
269 if ( ShlibVer == "cygdll" ) {
271 printf "\t@echo uninstalling $(DESTDIR)$(bindir)/%s\n", end_name
272 printf "\t-@rm -f $(DESTDIR)$(bindir)/%s\n", end_name
274 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", imp_name
275 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", imp_name
278 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", end_name
279 removelinks("$(DESTDIR)$(libdir)")
280 if ( overwrite == "yes" && name == "ncurses" )
282 if ( ShlibVer == "cygdll" ) {
283 ovr_name = sprintf("libcurses%s.a", suffix)
285 ovr_name = sprintf("libcurses%s", suffix)
287 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", ovr_name
290 if ( rmSoLocs == "yes" ) {
292 print "mostlyclean \\"
294 printf "\t-@rm -f so_locations\n"
297 else if ( MODEL == "LIBTOOL" )
305 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
306 printf "\tcd ../lib && $(LIBTOOL_LINK) $(%s) -o %s $(%s_OBJS:$o=.lo) -rpath $(DESTDIR)$(libdir) -version-info $(NCURSES_MAJOR):$(NCURSES_MINOR) $(SHLIB_LIST)\n", compile, lib_name, OBJS
309 print "install.libs \\"
310 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
311 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
312 printf "\tcd ../lib; $(LIBTOOL_INSTALL) $(INSTALL) %s $(DESTDIR)$(libdir)\n", lib_name
315 print "uninstall.libs \\"
316 printf "uninstall.%s ::\n", name
317 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
318 printf "\t-@$(LIBTOOL_UNINSTALL) rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
323 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
324 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
325 printf "\t$(RANLIB) $@\n"
326 if ( host == "vxworks" )
328 printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=$o)\n"
332 print "install.libs \\"
333 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
334 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
335 printf "\t$(INSTALL_DATA) ../lib/%s $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
336 if ( overwrite == "yes" && lib_name == "libncurses.a" )
338 printf "\t@echo linking libcurses.a to libncurses.a\n"
339 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
340 printf "\t(cd $(DESTDIR)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
342 printf "\t$(RANLIB) $(DESTDIR)$(libdir)/%s\n", lib_name
343 if ( host == "vxworks" )
345 printf "\t@echo installing ../lib/lib%s$o as $(DESTDIR)$(libdir)/lib%s$o\n", name, name
346 printf "\t$(INSTALL_DATA) ../lib/lib%s$o $(DESTDIR)$(libdir)/lib%s$o\n", name, name
350 print "uninstall.libs \\"
351 printf "uninstall.%s ::\n", name
352 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
353 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
354 if ( overwrite == "yes" && lib_name == "libncurses.a" )
356 printf "\t@echo linking libcurses.a to libncurses.a\n"
357 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
359 if ( host == "vxworks" )
361 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/lib%s$o\n", name
362 printf "\t-@rm -f $(DESTDIR)$(libdir)/lib%s$o\n", name
367 removelinks("../lib");
369 print "mostlyclean::"
370 printf "\t-rm -f $(%s_OBJS)\n", OBJS
371 if ( MODEL == "LIBTOOL" ) {
372 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
375 else if ( found == 2 )
378 print "mostlyclean::"
379 printf "\t-rm -f $(%s_OBJS)\n", OBJS
380 if ( MODEL == "LIBTOOL" ) {
381 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
385 printf "\t-rm -f $(%s_OBJS)\n", OBJS
386 if ( MODEL == "LIBTOOL" ) {
387 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS