1 # $Id: mk-1st.awk,v 1.68 2006/10/08 00:14:08 tom Exp $
2 ##############################################################################
3 # Copyright (c) 1998-2005,2006 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.
52 # Mixed-case variable names are ok.
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 make_shlib(objs, shlib_list) {
83 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(%s) $(LDFLAGS)\n", objs, shlib_list
85 function sharedlinks(directory) {
86 if ( ShlibVer != "auto" && ShlibVer != "cygdll" ) {
87 printf "\tcd %s && (", directory
88 if ( DoLinks == "reverse" ) {
89 if ( ShlibVer == "rel" ) {
90 symlink(lib_name, abi_name);
91 symlink(abi_name, rel_name);
92 } else if ( ShlibVer == "abi" ) {
93 symlink(lib_name, abi_name);
96 if ( ShlibVer == "rel" ) {
97 symlink(rel_name, abi_name);
98 symlink(abi_name, lib_name);
99 } else if ( ShlibVer == "abi" ) {
100 symlink(abi_name, lib_name);
106 function shlib_rule(directory) {
107 if ( ShlibVer == "cygdll" ) {
108 dst_libs = sprintf("%s/$(SHARED_LIB) %s/$(IMPORT_LIB)", directory, directory);
110 dst_libs = sprintf("%s/%s", directory, end_name);
112 printf "%s : %s $(%s_OBJS)\n", dst_libs, directory, OBJS
113 printf "\t@echo linking $@\n"
114 print "\t-@rm -f %s", dst_libs;
115 if ( subset == "termlib" || subset == "termlib+ext_tinfo" ) {
116 make_shlib(OBJS, "TINFO_LIST")
118 make_shlib(OBJS, "SHLIB_LIST")
120 sharedlinks(directory)
122 function install_dll(directory,filename) {
123 src_name = sprintf("../lib/%s", filename);
124 dst_name = sprintf("$(DESTDIR)%s/%s", directory, filename);
125 printf "\t@echo installing %s as %s\n", src_name, dst_name
126 printf "\t-@rm -f %s\n", dst_name
127 if ( directory == "$(bindir)" ) {
128 program = "$(INSTALL) -m 755";
130 program = "$(INSTALL_LIB)";
132 printf "\t%s %s %s\n", program, src_name, dst_name
140 if (subset == "none") {
142 } else if (index(subset,$2) > 0) {
146 printf "# generated by mk-1st.awk (subset=%s)\n", subset
147 printf "# name: %s\n", name
148 printf "# traces: %s\n", traces
149 printf "# MODEL: %s\n", MODEL
150 printf "# model: %s\n", model
151 printf "# prefix: %s\n", prefix
152 printf "# suffix: %s\n", suffix
153 printf "# subset: %s\n", subset
154 printf "# ShlibVer: %s\n", ShlibVer
155 printf "# ShlibVerInfix: %s\n", ShlibVerInfix
156 printf "# DoLinks: %s\n", DoLinks
157 printf "# rmSoLocs: %s\n", rmSoLocs
158 printf "# ldconfig: %s\n", ldconfig
159 printf "# overwrite: %s\n", overwrite
160 printf "# depend: %s\n", depend
161 printf "# host: %s\n", host
166 if ( subset == "termlib" || subset == "termlib+ext_tinfo" ) {
177 if (traces != "all" && traces != MODEL && $1 != "lib_trace")
182 && ( $1 != "link_test" ) \
190 printf "%s_OBJS =", OBJS
196 printf " \\\n\t../%s/%s$o", model, $1
203 printf "\n$(%s_OBJS) : %s\n", OBJS, depend
208 lib_name = sprintf("%s%s%s", prefix, name, suffix)
209 if ( MODEL == "SHARED" )
211 if (ShlibVerInfix == "cygdll") {
212 abi_name = sprintf("%s%s$(ABI_VERSION)%s", "cyg", name, suffix);
213 rel_name = sprintf("%s%s$(REL_VERSION)%s", "cyg", name, suffix);
214 imp_name = sprintf("%s%s%s.a", prefix, name, suffix);
215 } else if (ShlibVerInfix == "yes") {
216 abi_name = sprintf("%s%s.$(ABI_VERSION)%s", prefix, name, suffix);
217 rel_name = sprintf("%s%s.$(REL_VERSION)%s", prefix, name, suffix);
219 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
220 rel_name = sprintf("%s.$(REL_VERSION)", lib_name);
222 if ( DoLinks == "reverse") {
225 if ( ShlibVer == "rel" ) {
227 } else if ( ShlibVer == "abi" || ShlibVer == "cygdll" ) {
238 print "install.libs \\"
240 if ( ShlibVer == "cygdll" ) {
242 dst_dirs = "$(DESTDIR)$(bindir) $(DESTDIR)$(libdir)";
243 printf "install.%s :: %s $(LIBRARIES)\n", name, dst_dirs
244 install_dll("$(bindir)",end_name);
245 install_dll("$(libdir)",imp_name);
249 lib_dir = "$(DESTDIR)$(libdir)";
250 printf "install.%s :: %s/%s\n", name, lib_dir, end_name
255 if ( overwrite == "yes" && name == "ncurses" )
257 if ( ShlibVer == "cygdll" ) {
258 ovr_name = sprintf("libcurses%s.a", suffix)
259 printf "\t@echo linking %s to %s\n", imp_name, ovr_name
260 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, imp_name, ovr_name
262 ovr_name = sprintf("libcurses%s", suffix)
263 printf "\t@echo linking %s to %s\n", end_name, ovr_name
264 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, end_name, ovr_name
267 if ( ldconfig != "" && ldconfig != ":" ) {
268 printf "\t- test -z \"$(DESTDIR)\" && %s\n", ldconfig
272 print "uninstall.libs \\"
273 printf "uninstall.%s ::\n", name
274 if ( ShlibVer == "cygdll" ) {
276 printf "\t@echo uninstalling $(DESTDIR)$(bindir)/%s\n", end_name
277 printf "\t-@rm -f $(DESTDIR)$(bindir)/%s\n", end_name
279 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", imp_name
280 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", imp_name
283 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", end_name
284 removelinks("$(DESTDIR)$(libdir)")
285 if ( overwrite == "yes" && name == "ncurses" )
287 if ( ShlibVer == "cygdll" ) {
288 ovr_name = sprintf("libcurses%s.a", suffix)
290 ovr_name = sprintf("libcurses%s", suffix)
292 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", ovr_name
295 if ( rmSoLocs == "yes" ) {
297 print "mostlyclean \\"
299 printf "\t-@rm -f so_locations\n"
302 else if ( MODEL == "LIBTOOL" )
310 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
311 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
314 print "install.libs \\"
315 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
316 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
317 printf "\tcd ../lib; $(LIBTOOL_INSTALL) $(INSTALL) %s $(DESTDIR)$(libdir)\n", lib_name
320 print "uninstall.libs \\"
321 printf "uninstall.%s ::\n", name
322 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
323 printf "\t-@$(LIBTOOL_UNINSTALL) rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
328 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
329 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
330 printf "\t$(RANLIB) $@\n"
331 if ( host == "vxworks" )
333 printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=$o)\n"
337 print "install.libs \\"
338 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
339 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
340 printf "\t$(INSTALL_DATA) ../lib/%s $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
341 if ( overwrite == "yes" && lib_name == "libncurses.a" )
343 printf "\t@echo linking libcurses.a to libncurses.a\n"
344 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
345 printf "\t(cd $(DESTDIR)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
347 printf "\t$(RANLIB) $(DESTDIR)$(libdir)/%s\n", lib_name
348 if ( host == "vxworks" )
350 printf "\t@echo installing ../lib/lib%s$o as $(DESTDIR)$(libdir)/lib%s$o\n", name, name
351 printf "\t$(INSTALL_DATA) ../lib/lib%s$o $(DESTDIR)$(libdir)/lib%s$o\n", name, name
355 print "uninstall.libs \\"
356 printf "uninstall.%s ::\n", name
357 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
358 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
359 if ( overwrite == "yes" && lib_name == "libncurses.a" )
361 printf "\t@echo linking libcurses.a to libncurses.a\n"
362 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
364 if ( host == "vxworks" )
366 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/lib%s$o\n", name
367 printf "\t-@rm -f $(DESTDIR)$(libdir)/lib%s$o\n", name
372 removelinks("../lib");
374 print "mostlyclean::"
375 printf "\t-rm -f $(%s_OBJS)\n", OBJS
376 if ( MODEL == "LIBTOOL" ) {
377 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
380 else if ( found == 2 )
383 print "mostlyclean::"
384 printf "\t-rm -f $(%s_OBJS)\n", OBJS
385 if ( MODEL == "LIBTOOL" ) {
386 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
390 printf "\t-rm -f $(%s_OBJS)\n", OBJS
391 if ( MODEL == "LIBTOOL" ) {
392 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS