1 # $Id: mk-1st.awk,v 1.20 1997/05/05 21:28:17 tom Exp $
2 ################################################################################
3 # Copyright 1996,1997 by Thomas E. Dickey <dickey@clark.net> #
4 # All Rights Reserved. #
6 # Permission to use, copy, modify, and distribute this software and its #
7 # documentation for any purpose and without fee is hereby granted, provided #
8 # that the above copyright notice appear in all copies and that both that #
9 # copyright notice and this permission notice appear in supporting #
10 # documentation, and that the name of the above listed copyright holder(s) not #
11 # be used in advertising or publicity pertaining to distribution of the #
12 # software without specific, written prior permission. THE ABOVE LISTED #
13 # COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, #
14 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
15 # SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, #
16 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM #
17 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE #
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR #
19 # PERFORMANCE OF THIS SOFTWARE. #
20 ################################################################################
21 # Generate list of objects for a given model library
23 # name (library name, e.g., "ncurses", "panel", "forms", "menus")
24 # model (directory into which we compile, e.g., "obj")
25 # suffix (e.g., "_g.a", for debug libraries)
26 # MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
27 # DoLinks ("yes" or "no", flag to add symbolic links)
28 # rmSoLocs ("yes" or "no", flag to add extra clean target)
29 # overwrite ("yes" or "no", flag to add link to libcurses.a
32 # CLIXs nawk does not like underscores in command-line variable names.
34 # HP/UX requires shared libraries to have executable permissions.
36 function symlink(src,dst) {
38 printf "rm -f %s; ", dst
39 printf "$(LN_S) %s %s; ", src, dst
42 function sharedlinks(directory) {
43 if ( end_name != lib_name ) {
44 printf "\tcd %s && (", directory
45 abi_name = sprintf("%s.$(ABI_VERSION)", lib_name);
46 symlink(end_name, abi_name);
47 symlink(abi_name, lib_name);
51 function removelinks() {
52 if ( end_name != lib_name ) {
53 printf "\trm -f ../lib/%s ../lib/%s\n", abi_name, end_name
56 function installed_name() {
57 if ( DO_LINKS == "yes" ) {
58 return sprintf("%s.$(REL_VERSION)", lib_name);
65 print "# generated by mk-1st.awk"
70 if ( $2 == "lib" || $2 == "progs" )
74 printf "%s_OBJS =", MODEL
80 printf " \\\n\t../%s/%s.o", model, $1
87 printf "\n$(%s_OBJS) : %s\n", MODEL, depend
92 lib_name = sprintf("lib%s%s", name, suffix)
93 if ( MODEL == "SHARED" )
95 if ( DoLinks == "yes" ) {
96 end_name = sprintf("%s.$(REL_VERSION)", lib_name);
100 printf "../lib/%s : $(%s_OBJS)\n", lib_name, MODEL
102 printf "\t$(MK_SHARED_LIB) $(%s_OBJS)\n", MODEL
103 sharedlinks("../lib")
105 if ( end_name != lib_name ) {
106 printf "../lib/%s : ../lib/%s\n", end_name, lib_name
110 print "install.libs \\"
111 printf "install.%s :: $(INSTALL_PREFIX)$(libdir) ../lib/%s\n", name, end_name
112 printf "\t@echo installing ../lib/%s as $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, end_name
113 printf "\t-rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", end_name
114 printf "\t$(INSTALL) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, end_name
115 sharedlinks("$(INSTALL_PREFIX)$(libdir)")
116 if ( overwrite == "yes" && name == "ncurses" )
118 ovr_name = sprintf("libcurses%s", suffix)
119 printf "\t@echo linking %s to %s\n", ovr_name, lib_name
120 printf "\t-rm -f $(INSTALL_PREFIX)$(libdir)/%s \n", ovr_name
121 printf "\t(cd $(INSTALL_PREFIX)$(libdir) && $(LN_S) %s %s)\n", lib_name, ovr_name
123 printf "\t- ldconfig\n"
124 if ( rmSoLocs == "yes" ) {
126 print "mostlyclean \\"
128 printf "\t@-rm -f so_locations\n"
134 printf "../lib/%s : $(%s_OBJS)\n", lib_name, MODEL
135 printf "\t$(AR) $(AR_OPTS) $@ $?\n"
136 printf "\t$(RANLIB) $@\n"
139 print "install.libs \\"
140 printf "install.%s :: $(INSTALL_PREFIX)$(libdir) ../lib/%s\n", name, lib_name
141 printf "\t@echo installing ../lib/%s as $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
142 printf "\t$(INSTALL_DATA) ../lib/%s $(INSTALL_PREFIX)$(libdir)/%s \n", lib_name, lib_name
143 if ( overwrite == "yes" && lib_name == "libncurses.a" )
145 printf "\t@echo linking libcurses.a to libncurses.a \n"
146 printf "\t-rm -f $(INSTALL_PREFIX)$(libdir)/libcurses.a \n"
147 printf "\t(cd $(INSTALL_PREFIX)$(libdir) && $(LN_S) libncurses.a libcurses.a)\n"
149 printf "\t$(RANLIB) $(INSTALL_PREFIX)$(libdir)/%s\n", lib_name
152 print "mostlyclean \\"
154 printf "\trm -f ../lib/%s\n", lib_name
155 printf "\trm -f $(%s_OBJS)\n", MODEL
158 else if ( found == 2 )
161 print "mostlyclean \\"
163 printf "\trm -f $(%s_OBJS)\n", MODEL