1 # $Id: mk-1st.awk,v 1.69 2006/12/24 00:12:23 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", etc.)
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 is_termlib() {
56 return ( subset ~ /^termlib(\+(ext_tinfo|programs))*$/ );
58 function symlink(src,dst) {
60 printf "rm -f %s; ", dst
61 printf "$(LN_S) %s %s; ", src, dst
64 function rmlink(directory, dst) {
65 printf "\t-rm -f %s/%s\n", directory, dst
67 function removelinks(directory) {
68 rmlink(directory, end_name);
69 if ( DoLinks == "reverse" ) {
70 if ( ShlibVer == "rel" ) {
71 rmlink(directory, abi_name);
72 rmlink(directory, rel_name);
73 } else if ( ShlibVer == "abi" ) {
74 rmlink(directory, abi_name);
77 if ( ShlibVer == "rel" ) {
78 rmlink(directory, abi_name);
79 rmlink(directory, lib_name);
80 } else if ( ShlibVer == "abi" ) {
81 rmlink(directory, lib_name);
85 function make_shlib(objs, shlib_list) {
86 printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(%s) $(LDFLAGS)\n", objs, shlib_list
88 function sharedlinks(directory) {
89 if ( ShlibVer != "auto" && ShlibVer != "cygdll" ) {
90 printf "\tcd %s && (", directory
91 if ( DoLinks == "reverse" ) {
92 if ( ShlibVer == "rel" ) {
93 symlink(lib_name, abi_name);
94 symlink(abi_name, rel_name);
95 } else if ( ShlibVer == "abi" ) {
96 symlink(lib_name, abi_name);
99 if ( ShlibVer == "rel" ) {
100 symlink(rel_name, abi_name);
101 symlink(abi_name, lib_name);
102 } else if ( ShlibVer == "abi" ) {
103 symlink(abi_name, lib_name);
109 function shlib_rule(directory) {
110 if ( ShlibVer == "cygdll" ) {
111 dst_libs = sprintf("%s/$(SHARED_LIB) %s/$(IMPORT_LIB)", directory, directory);
113 dst_libs = sprintf("%s/%s", directory, end_name);
115 printf "%s : %s $(%s_OBJS)\n", dst_libs, directory, OBJS
116 printf "\t@echo linking $@\n"
117 print "\t-@rm -f %s", dst_libs;
118 if ( is_termlib() ) {
119 make_shlib(OBJS, "TINFO_LIST")
121 make_shlib(OBJS, "SHLIB_LIST")
123 sharedlinks(directory)
125 function install_dll(directory,filename) {
126 src_name = sprintf("../lib/%s", filename);
127 dst_name = sprintf("$(DESTDIR)%s/%s", directory, filename);
128 printf "\t@echo installing %s as %s\n", src_name, dst_name
129 printf "\t-@rm -f %s\n", dst_name
130 if ( directory == "$(bindir)" ) {
131 program = "$(INSTALL) -m 755";
133 program = "$(INSTALL_LIB)";
135 printf "\t%s %s %s\n", program, src_name, dst_name
143 if (subset == "none") {
145 } else if (index(subset,$2) > 0) {
149 printf "# generated by mk-1st.awk (subset=%s)\n", subset
150 printf "# name: %s\n", name
151 printf "# traces: %s\n", traces
152 printf "# MODEL: %s\n", MODEL
153 printf "# model: %s\n", model
154 printf "# prefix: %s\n", prefix
155 printf "# suffix: %s\n", suffix
156 printf "# subset: %s\n", subset
157 printf "# ShlibVer: %s\n", ShlibVer
158 printf "# ShlibVerInfix: %s\n", ShlibVerInfix
159 printf "# DoLinks: %s\n", DoLinks
160 printf "# rmSoLocs: %s\n", rmSoLocs
161 printf "# ldconfig: %s\n", ldconfig
162 printf "# overwrite: %s\n", overwrite
163 printf "# depend: %s\n", depend
164 printf "# host: %s\n", host
169 if ( is_termlib() ) {
180 if (traces != "all" && traces != MODEL && $1 != "lib_trace")
185 && ( $1 != "link_test" ) \
193 printf "%s_OBJS =", OBJS
199 printf " \\\n\t../%s/%s$o", model, $1
206 printf "\n$(%s_OBJS) : %s\n", OBJS, depend
211 lib_name = sprintf("%s%s%s", prefix, name, suffix)
212 if ( MODEL == "SHARED" )
214 if (ShlibVerInfix == "cygdll") {
215 abi_name = sprintf("%s%s$(ABI_VERSION)%s", "cyg", name, suffix);
216 rel_name = sprintf("%s%s$(REL_VERSION)%s", "cyg", name, suffix);
217 imp_name = sprintf("%s%s%s.a", prefix, name, suffix);
218 } else if (ShlibVerInfix == "yes") {
219 abi_name = sprintf("%s%s.$(ABI_VERSION)%s", prefix, name, suffix);
220 rel_name = sprintf("%s%s.$(REL_VERSION)%s", prefix, name, suffix);
222 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
223 rel_name = sprintf("%s.$(REL_VERSION)", lib_name);
225 if ( DoLinks == "reverse") {
228 if ( ShlibVer == "rel" ) {
230 } else if ( ShlibVer == "abi" || ShlibVer == "cygdll" ) {
241 print "install.libs \\"
243 if ( ShlibVer == "cygdll" ) {
245 dst_dirs = "$(DESTDIR)$(bindir) $(DESTDIR)$(libdir)";
246 printf "install.%s :: %s $(LIBRARIES)\n", name, dst_dirs
247 install_dll("$(bindir)",end_name);
248 install_dll("$(libdir)",imp_name);
252 lib_dir = "$(DESTDIR)$(libdir)";
253 printf "install.%s :: %s/%s\n", name, lib_dir, end_name
258 if ( overwrite == "yes" && name == "ncurses" )
260 if ( ShlibVer == "cygdll" ) {
261 ovr_name = sprintf("libcurses%s.a", suffix)
262 printf "\t@echo linking %s to %s\n", imp_name, ovr_name
263 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, imp_name, ovr_name
265 ovr_name = sprintf("libcurses%s", suffix)
266 printf "\t@echo linking %s to %s\n", end_name, ovr_name
267 printf "\tcd $(DESTDIR)$(libdir) && (rm -f %s; $(LN_S) %s %s; )\n", ovr_name, end_name, ovr_name
270 if ( ldconfig != "" && ldconfig != ":" ) {
271 printf "\t- test -z \"$(DESTDIR)\" && %s\n", ldconfig
275 print "uninstall.libs \\"
276 printf "uninstall.%s ::\n", name
277 if ( ShlibVer == "cygdll" ) {
279 printf "\t@echo uninstalling $(DESTDIR)$(bindir)/%s\n", end_name
280 printf "\t-@rm -f $(DESTDIR)$(bindir)/%s\n", end_name
282 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", imp_name
283 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", imp_name
286 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", end_name
287 removelinks("$(DESTDIR)$(libdir)")
288 if ( overwrite == "yes" && name == "ncurses" )
290 if ( ShlibVer == "cygdll" ) {
291 ovr_name = sprintf("libcurses%s.a", suffix)
293 ovr_name = sprintf("libcurses%s", suffix)
295 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", ovr_name
298 if ( rmSoLocs == "yes" ) {
300 print "mostlyclean \\"
302 printf "\t-@rm -f so_locations\n"
305 else if ( MODEL == "LIBTOOL" )
313 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
314 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
317 print "install.libs \\"
318 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
319 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
320 printf "\tcd ../lib; $(LIBTOOL_INSTALL) $(INSTALL) %s $(DESTDIR)$(libdir)\n", lib_name
323 print "uninstall.libs \\"
324 printf "uninstall.%s ::\n", name
325 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
326 printf "\t-@$(LIBTOOL_UNINSTALL) rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
331 printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
332 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
333 printf "\t$(RANLIB) $@\n"
334 if ( host == "vxworks" )
336 printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=$o)\n"
340 print "install.libs \\"
341 printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
342 printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
343 printf "\t$(INSTALL_DATA) ../lib/%s $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
344 if ( overwrite == "yes" && lib_name == "libncurses.a" )
346 printf "\t@echo linking libcurses.a to libncurses.a\n"
347 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
348 printf "\t(cd $(DESTDIR)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
350 printf "\t$(RANLIB) $(DESTDIR)$(libdir)/%s\n", lib_name
351 if ( host == "vxworks" )
353 printf "\t@echo installing ../lib/lib%s$o as $(DESTDIR)$(libdir)/lib%s$o\n", name, name
354 printf "\t$(INSTALL_DATA) ../lib/lib%s$o $(DESTDIR)$(libdir)/lib%s$o\n", name, name
358 print "uninstall.libs \\"
359 printf "uninstall.%s ::\n", name
360 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
361 printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
362 if ( overwrite == "yes" && lib_name == "libncurses.a" )
364 printf "\t@echo linking libcurses.a to libncurses.a\n"
365 printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
367 if ( host == "vxworks" )
369 printf "\t@echo uninstalling $(DESTDIR)$(libdir)/lib%s$o\n", name
370 printf "\t-@rm -f $(DESTDIR)$(libdir)/lib%s$o\n", name
375 removelinks("../lib");
377 print "mostlyclean::"
378 printf "\t-rm -f $(%s_OBJS)\n", OBJS
379 if ( MODEL == "LIBTOOL" ) {
380 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
383 else if ( found == 2 )
386 print "mostlyclean::"
387 printf "\t-rm -f $(%s_OBJS)\n", OBJS
388 if ( MODEL == "LIBTOOL" ) {
389 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
393 printf "\t-rm -f $(%s_OBJS)\n", OBJS
394 if ( MODEL == "LIBTOOL" ) {
395 printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS