1# $Id: mk-1st.awk,v 1.125 2023/04/22 15:49:59 tom Exp $
2##############################################################################
3# Copyright 2018-2021,2023 Thomas E. Dickey                                  #
4# Copyright 1998-2016,2017 Free Software Foundation, Inc.                    #
5#                                                                            #
6# Permission is hereby granted, free of charge, to any person obtaining a    #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation  #
9# the rights to use, copy, modify, merge, publish, distribute, distribute    #
10# with modifications, sublicense, and/or sell copies of the Software, and to #
11# permit persons to whom the Software is furnished to do so, subject to the  #
12# following conditions:                                                      #
13#                                                                            #
14# The above copyright notice and this permission notice shall be included in #
15# all copies or substantial portions of the Software.                        #
16#                                                                            #
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23# DEALINGS IN THE SOFTWARE.                                                  #
24#                                                                            #
25# Except as contained in this notice, the name(s) of the above copyright     #
26# holders shall not be used in advertising or otherwise to promote the sale, #
27# use or other dealings in this Software without prior written               #
28# authorization.                                                             #
29##############################################################################
30#
31# Author: Thomas E. Dickey
32#
33# Generate list of objects for a given model library
34# Variables:
35#	name		  (library name, e.g., "ncurses", "panel", "forms", "menus")
36#	traces		  ("all" or "DEBUG", to control whether tracing is compiled in)
37#	MODEL		  (e.g., "DEBUG", uppercase; toupper is not portable)
38#	CXX_MODEL	  (e.g., "DEBUG", uppercase)
39#	LIB_SUFFIX	  (e.g., "", "w", "t", "tw")
40#	USE_LIB_SUFFIX (e.g., "", "w", "t", "tw")
41#	model		  (directory into which we compile, e.g., "obj")
42#	prefix		  (e.g., "lib", for Unix-style libraries)
43#	suffix		  (e.g., "_g.a", for debug libraries)
44#	subset		  ("none", "base", "base+ext_funcs" or "termlib", etc.)
45#	driver		  ("yes" or "no", depends on --enable-term-driver)
46#	ShlibVer	  ("rel", "abi" or "auto", to augment DoLinks variable)
47#	ShlibVerInfix ("yes" or "no", determines location of version #)
48#	SymLink		  ("ln -s", etc)
49#	TermlibRoot	  ("tinfo" or other root for libterm.so)
50#	TermlibSuffix (".so" or other suffix for libterm.so)
51#	ReLink		  ("yes", or "no", flag to rebuild shared libs on install)
52#	ReRanlib	  ("yes", or "no", flag to rerun ranlib for installing static)
53#	DoLinks		  ("yes", "reverse" or "no", flag to add symbolic links)
54#	rmSoLocs	  ("yes" or "no", flag to add extra clean target)
55#	ldconfig	  (path for this tool, if used)
56#	make_phony    ("yes" if the make-program accepts ".PHONY" directive.
57#	overwrite	  ("yes" or "no", flag to add link to libcurses.a
58#	depend		  (optional dependencies for all objects, e.g, ncurses_cfg.h)
59#	host		  (cross-compile host, if any)
60#	libtool_version (libtool "-version-info" or "-version-number")
61#
62# Notes:
63#	CLIXs nawk does not like underscores in command-line variable names.
64#	Mixed-case variable names are ok.
65#	HP-UX requires shared libraries to have executable permissions.
66#
67function is_ticlib() {
68		return ( subset ~ /^ticlib$/ );
69	}
70function is_termlib() {
71		return ( subset ~ /^(ticlib\+)?termlib((\+[^+ ]+)*\+[a-z_]+_tinfo)?$/ );
72	}
73# see lib_name
74function lib_name_of(a_name) {
75		return sprintf("%s%s%s", prefix, a_name, suffix)
76	}
77# see imp_name
78function imp_name_of(a_name) {
79		if (ShlibVerInfix == "cygdll" || ShlibVerInfix == "msysdll" || ShlibVerInfix == "mingw") {
80			result = sprintf("%s%s%s.a", prefix, a_name, suffix);
81		} else if (ShlibVerInfix == "msvcdll") {
82			result = sprintf("%s%s%s.lib", prefix, a_name, suffix);
83		} else{
84			result = "";
85		}
86		return result;
87	}
88# see abi_name
89function abi_name_of(a_name) {
90		if (ShlibVerInfix == "cygdll") {
91			result = sprintf("%s%s$(ABI_VERSION)%s", "cyg", a_name, suffix);
92		} else if (ShlibVerInfix == "msysdll") {
93			result = sprintf("%s%s$(ABI_VERSION)%s", "msys-", a_name, suffix);
94		} else if (ShlibVerInfix == "mingw" || ShlibVerInfix == "msvcdll") {
95			result = sprintf("%s%s$(ABI_VERSION)%s", prefix, a_name, suffix);
96		} else if (ShlibVerInfix == "yes") {
97			result = sprintf("%s%s.$(ABI_VERSION)%s", prefix, a_name, suffix);
98		} else {
99			result = sprintf("%s.$(ABI_VERSION)", lib_name_of(a_name));
100		}
101		return result;
102	}
103# see rel_name
104function rel_name_of(a_name) {
105		if (ShlibVerInfix == "cygdll") {
106			result = sprintf("%s%s$(REL_VERSION)%s", "cyg", a_name, suffix);
107		} else if (ShlibVerInfix == "msysdll") {
108			result = sprintf("%s%s$(ABI_VERSION)%s", "msys-", a_name, suffix);
109		} else if (ShlibVerInfix == "mingw" || ShlibVerInfix == "msvcdll") {
110			result = sprintf("%s%s$(REL_VERSION)%s", prefix, a_name, suffix);
111		} else if (ShlibVerInfix == "yes") {
112			result = sprintf("%s%s.$(REL_VERSION)%s", prefix, a_name, suffix);
113		} else {
114			result = sprintf("%s.$(REL_VERSION)", lib_name_of(a_name));
115		}
116		return result;
117	}
118# see end_name
119function end_name_of(a_name) {
120		if ( MODEL != "SHARED" ) {
121			result = lib_name_of(a_name);
122		} else if ( DoLinks == "reverse") {
123			result = lib_name_of(a_name);
124		} else {
125			if ( ShlibVer == "rel" ) {
126				result = rel_name_of(a_name);
127			} else if ( ShlibVer == "abi" || ShlibVer == "cygdll" || ShlibVer == "msysdll" || ShlibVer == "mingw" || ShlibVer == "msvcdll" ) {
128				result = abi_name_of(a_name);
129			} else {
130				result = lib_name_of(a_name);
131			}
132		}
133		return result
134	}
135function symlink(src,dst) {
136		if ( src != dst ) {
137			if ( SymLink !~ /.*-f.*/ ) {
138				printf "rm -f %s; ", dst
139			}
140			printf "$(LN_S) %s %s; ", src, dst
141		}
142	}
143function rmlink(directory, dst) {
144		if ( dst != "" ) {
145			printf "\t-rm -f %s/%s\n", directory, dst
146		}
147	}
148function removelinks(directory) {
149		nlinks = 0;
150		links[nlinks++] = end_name;
151		if ( DoLinks == "reverse" ) {
152			if ( ShlibVer == "rel" ) {
153				links[nlinks++] = abi_name;
154				links[nlinks++] = rel_name;
155			} else if ( ShlibVer == "abi" ) {
156				links[nlinks++] = abi_name;
157			}
158		} else {
159			if ( ShlibVer == "rel" ) {
160				links[nlinks++] = abi_name;
161				links[nlinks++] = lib_name;
162			} else if ( ShlibVer == "abi" ) {
163				links[nlinks++] = lib_name;
164			}
165		}
166		for (j = 0; j < nlinks; ++j) {
167			found = 0;
168			for (k = 0; k < j; ++k ) {
169				if ( links[j] == links[k] ) {
170					found = 1;
171					break;
172				}
173			}
174			if ( !found ) {
175				rmlink(directory, links[j]);
176			}
177		}
178	}
179function make_shlib(objs, shlib_list) {
180		printf "\t$(MK_SHARED_LIB) $(%s_OBJS) $(%s)\n", objs, shlib_list
181	}
182function sharedlinks(directory) {
183		if ( ShlibVer != "auto" && ShlibVer != "cygdll" && ShlibVer != "msysdll" && ShlibVer != "mingw" && ShlibVer != "msvcdll" ) {
184			printf "\tcd %s && (", directory
185			if ( DoLinks == "reverse" ) {
186				if ( ShlibVer == "rel" ) {
187					symlink(lib_name, abi_name);
188					symlink(abi_name, rel_name);
189				} else if ( ShlibVer == "abi" ) {
190					symlink(lib_name, abi_name);
191				}
192			} else {
193				if ( ShlibVer == "rel" ) {
194					symlink(rel_name, abi_name);
195					symlink(abi_name, lib_name);
196				} else if ( ShlibVer == "abi" ) {
197					symlink(abi_name, lib_name);
198				}
199			}
200			printf ")\n"
201		}
202	}
203# termlib may be named explicitly via "--with-termlib=XXX", which overrides
204# any suffix.  Temporarily override "suffix" to account for this.
205function termlib_end_of() {
206	termlib_save_suffix = suffix;
207	suffix = TermlibSuffix;
208	termlib_temp_result = end_name_of(TermlibRoot);
209	suffix = termlib_save_suffix;
210	return termlib_temp_result;
211}
212function shlib_build(directory) {
213		dst_libs = sprintf("%s/%s", directory, end_name);
214		printf "%s : \\\n", dst_libs
215		if (subset == "ticlib" && driver == "yes" ) {
216			base = name;
217			sub(/^tic/, "ncurses", base); # workaround for "w"
218			printf "\t\t%s/%s \\\n", directory, end_name_of(base);
219		}
220		if (subset ~ /^base/ || subset == "ticlib" ) {
221			save_suffix = suffix
222			sub(/^[^.]\./,".",suffix)
223			if (directory != "../lib") {
224				printf "\t\t%s/%s \\\n", "../lib", termlib_end_of();
225			}
226			printf "\t\t%s/%s \\\n", directory, termlib_end_of();
227			suffix = save_suffix
228		}
229		printf "\t\t$(RESULTING_SYMS) $(%s_OBJS)\n", OBJS
230		printf "\t@echo linking $@\n"
231		printf "\t@mkdir -p %s\n", directory
232		if ( ReLink != "yes" ) {
233			printf "\t@sleep 1\n"
234		}
235		if ( is_ticlib() ) {
236			make_shlib(OBJS, "TICS_LIST")
237		} else if ( is_termlib() ) {
238			make_shlib(OBJS, "TINFO_LIST")
239		} else {
240			make_shlib(OBJS, "SHLIB_LIST")
241		}
242		sharedlinks(directory)
243	}
244function shlib_install(directory) {
245		src_lib1 = sprintf("../lib/%s", end_name);
246		dst_lib1 = sprintf("%s/%s", directory, end_name);
247		printf "%s : \\\n", dst_lib1
248		printf "\t\t%s \\\n", directory
249		printf "\t\t%s\n", src_lib1
250		printf "\t@echo installing $@\n"
251		printf "\t$(INSTALL_LIB) %s %s\n", src_lib1, dst_lib1;
252		sharedlinks(directory)
253	}
254function install_dll(directory,filename) {
255		src_name = sprintf("../lib/%s", filename);
256		dst_name = sprintf("$(DESTDIR)%s/%s", directory, filename);
257		printf "\t@echo installing %s as %s\n", src_name, dst_name
258		if ( directory == "$(bindir)" ) {
259			program = "$(INSTALL) -m 755";
260		} else {
261			program = "$(INSTALL_LIB)";
262		}
263		printf "\t%s %s %s\n", program, src_name, dst_name
264	}
265function in_subset(value) {
266		value = " " value " ";
267		check = subset;
268		gsub("[+]", " ", check);
269		check = " " check " ";
270		return index(check,value);
271	}
272function trim_suffix(value) {
273	if (USE_LIB_SUFFIX != "" && length(value) > length(USE_LIB_SUFFIX)) {
274		check = substr(value, 1 + length(value) - length(USE_LIB_SUFFIX));
275		if (check == USE_LIB_SUFFIX) {
276			value = substr(value, 1, length(value) - length(USE_LIB_SUFFIX));
277		}
278	}
279	return value;
280}
281BEGIN	{
282		TOOL_PREFIX = "";
283		found = 0;
284		using = 0;
285	}
286	/^@/ {
287		using = 0
288		if (subset == "none") {
289			using = 1
290			print  ""
291			print "# generated by mk-1st.awk"
292		} else if (in_subset($2) > 0) {
293			if (using == 0) {
294				if (found == 0) {
295					if ( name ~ /^.*\+\+.*/ ) {
296						if ( CXX_MODEL == "NORMAL" && MODEL == "SHARED" ) {
297							print  ""
298							printf "# overriding model from %s to match CXX_MODEL\n", MODEL;
299							MODEL = "NORMAL";
300							suffix = ".a";
301							DoLinks = "no";
302						}
303					}
304					print  ""
305					printf "# generated by mk-1st.awk (subset=%s)\n", subset
306					printf "#  name:            %s\n", name
307					printf "#  traces:          %s\n", traces
308					printf "#  MODEL:           %s\n", MODEL
309					printf "#  CXX_MODEL:       %s\n", CXX_MODEL
310					printf "#  LIB_SUFFIX:      %s\n", LIB_SUFFIX
311					printf "#  USE_LIB_SUFFIX:  %s\n", USE_LIB_SUFFIX
312					printf "#  model:           %s\n", model
313					printf "#  prefix:          %s\n", prefix
314					printf "#  suffix:          %s\n", suffix
315					printf "#  subset:          %s\n", subset
316					printf "#  driver:          %s\n", driver
317					printf "#  ShlibVer:        %s\n", ShlibVer
318					printf "#  ShlibVerInfix:   %s\n", ShlibVerInfix
319					printf "#  SymLink:         %s\n", SymLink
320					printf "#  TermlibRoot:     %s\n", TermlibRoot
321					printf "#  TermlibSuffix:   %s\n", TermlibSuffix
322					printf "#  ReLink:          %s\n", ReLink
323					printf "#  ReRanlib:        %s\n", ReRanlib
324					printf "#  DoLinks:         %s\n", DoLinks
325					printf "#  rmSoLocs:        %s\n", rmSoLocs
326					printf "#  ldconfig:        %s\n", ldconfig
327					printf "#  make_phony:      %s\n", make_phony
328					printf "#  overwrite:       %s\n", overwrite
329					printf "#  depend:          %s\n", depend
330					printf "#  host:            %s\n", host
331					printf "#  libtool_version: %s\n", libtool_version
332					print  ""
333				}
334				using = 1
335			}
336			if ( is_ticlib() ) {
337				OBJS  = MODEL "_P"
338			} else if ( is_termlib() ) {
339				OBJS  = MODEL "_T"
340			} else {
341				OBJS  = MODEL
342			}
343		}
344	}
345	/^[@#]/ {
346		next
347	}
348	$1 ~ /trace/ {
349		if (traces != "all" && traces != MODEL && $1 != "lib_trace")
350			next
351	}
352	{
353		if (using \
354		 && ( $1 != "link_test" ) \
355		 && ( $2 == "lib" \
356		   || $2 == "progs" \
357		   || $2 == "c++" ))
358		{
359			if ( found == 0 )
360			{
361				printf "%s_OBJS =", OBJS
362				if ( $2 == "lib" ) {
363					found = 1;
364				} else if ( $2 == "c++" ) {
365					TOOL_PREFIX = "CXX_";
366					found = 1;
367				} else {
368					found = 2;
369				}
370				if ( $2 == "c++" ) {
371					CC_NAME="CXX"
372					CC_FLAG="CXXFLAGS"
373				} else {
374					CC_NAME="CC"
375					CC_FLAG="CFLAGS"
376				}
377			}
378			printf " \\\n\t../%s/%s$o", model, $1;
379		}
380	}
381END	{
382		print  ""
383		if ( found != 0 )
384		{
385			printf "\n$(%s_OBJS) : %s\n", OBJS, depend
386		}
387		if ( found == 1 )
388		{
389			print  ""
390			lib_name = lib_name_of(name);
391			if ( MODEL == "SHARED" )
392			{
393				abi_name = abi_name_of(name);
394				rel_name = rel_name_of(name);
395				imp_name = imp_name_of(name);
396				end_name = end_name_of(name);
397
398				shlib_build("../lib")
399
400				print  ""
401				print  "install \\"
402				print  "install.libs \\"
403
404				if ( ShlibVer == "cygdll" || ShlibVer == "msysdll" || ShlibVer == "mingw" || ShlibVer == "msvcdll") {
405
406					dst_dirs = "$(DESTDIR)$(bindir) $(DESTDIR)$(libdir)";
407					printf "install.%s :: %s $(LIBRARIES)\n", name, dst_dirs
408					install_dll("$(bindir)",end_name);
409					install_dll("$(libdir)",imp_name);
410
411				} else {
412
413					lib_dir = "$(DESTDIR)$(libdir)";
414					printf "install.%s :: %s/%s\n", name, lib_dir, end_name
415					print ""
416					if ( ReLink == "yes" ) {
417						shlib_build(lib_dir)
418					} else {
419						shlib_install(lib_dir)
420					}
421				}
422
423				if ( overwrite == "yes" && name == "ncurses" )
424				{
425					if ( ShlibVer == "cygdll" || ShlibVer == "msysdll" || ShlibVer == "mingw" || SlibVer == "msvcdll") {
426						if (ShlibVer == "msvcdll") {
427							curses_prefix = ""
428						} else {
429							curses_prefix = "lib"
430						}
431						ovr_name = sprintf("%scurses%s.a", curses_prefix, suffix)
432						printf "\t@echo linking %s to %s\n", imp_name, ovr_name
433						printf "\tcd $(DESTDIR)$(libdir) && ("
434						symlink(imp_name, ovr_name)
435						printf ")\n"
436					} else {
437						ovr_name = sprintf("libcurses%s", suffix)
438						printf "\t@echo linking %s to %s\n", end_name, ovr_name
439						printf "\tcd $(DESTDIR)$(libdir) && ("
440						symlink(end_name, ovr_name)
441						printf ")\n"
442					}
443				}
444				if ( ldconfig != "" && ldconfig != ":" ) {
445					printf "\t- test -z \"$(DESTDIR)\" && %s\n", ldconfig
446				}
447				print  ""
448				print  "uninstall \\"
449				print  "uninstall.libs \\"
450				printf "uninstall.%s ::\n", name
451				if ( ShlibVer == "cygdll" || ShlibVer == "msysdll" || ShlibVer == "mingw" || ShlibVer == "msvcdll") {
452
453					printf "\t@echo uninstalling $(DESTDIR)$(bindir)/%s\n", end_name
454					printf "\t-@rm -f $(DESTDIR)$(bindir)/%s\n", end_name
455
456					printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", imp_name
457					printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", imp_name
458
459				} else {
460					printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", end_name
461					removelinks("$(DESTDIR)$(libdir)")
462					if ( overwrite == "yes" && name == "ncurses" )
463					{
464						ovr_name = sprintf("libcurses%s", suffix)
465						printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", ovr_name
466					}
467				}
468				if ( rmSoLocs == "yes" ) {
469					print  ""
470					print  "mostlyclean \\"
471					print  "clean ::"
472					printf "\t-@rm -f so_locations\n"
473				}
474			}
475			else if ( MODEL == "LIBTOOL" )
476			{
477				end_name = lib_name;
478				use_name = trim_suffix(TermlibRoot) USE_LIB_SUFFIX
479				printf "../lib/%s : \\\n", lib_name
480				if ( (name != use_name ) && ( index(name, "++") == 0 ) && ( index(name, "tic") == 1 || index(name, "ncurses") == 1 ) ) {
481					printf "\t\t../lib/lib%s.la \\\n", use_name;
482					if ( index(name, "tic") == 1 && index(TermlibRoot, "ncurses") != 1 ) {
483						printf "\t\t../lib/lib%s%s.la \\\n", "ncurses", USE_LIB_SUFFIX;
484					}
485				}
486				printf "\t\t$(%s_OBJS)\n", OBJS
487				if ( is_ticlib() ) {
488					which_list = "TICS_LIST";
489				} else if ( is_termlib() ) {
490					which_list = "TINFO_LIST";
491				} else {
492					which_list = "SHLIB_LIST";
493				}
494				printf "\tcd ../lib && $(LIBTOOL_LINK) $(%s) $(%s) \\\n", CC_NAME, CC_FLAG;
495				printf "\t\t-o %s $(%s_OBJS:$o=.lo) \\\n", lib_name, OBJS;
496				printf "\t\t-rpath $(libdir) \\\n";
497				printf "\t\t%s $(NCURSES_MAJOR):$(NCURSES_MINOR) $(LT_UNDEF) $(%s) $(LDFLAGS)\n", libtool_version, which_list;
498				if ( make_phony == "yes" ) {
499					print  ""
500					printf ".PHONY :\tinstall.%s\n", trim_suffix(name);
501				}
502				print  ""
503				print  "install \\"
504				print  "install.libs \\"
505				printf "install.%s :: \\\n", trim_suffix(name);
506				printf "\t\t$(DESTDIR)$(libdir) \\\n";
507				use_name = TermlibRoot USE_LIB_SUFFIX
508				if ( (name != use_name ) && ( index(name, "++") == 0 ) && ( index(name, "tic") == 1 || index(name, "ncurses") == 1 ) ) {
509					if ( trim_suffix(TermlibRoot) != trim_suffix(name) ) {
510						printf "\t\tinstall.%s \\\n", trim_suffix(TermlibRoot);
511					}
512					if ( index(name, "tic") == 1 && index(TermlibRoot, "ncurses") != 1 && trim_suffix(name) != "ncurses" ) {
513						printf "\t\tinstall.%s \\\n", "ncurses";
514					}
515				}
516				printf "\t\t../lib/%s\n", lib_name
517				printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
518				printf "\tcd ../lib; $(LIBTOOL_INSTALL) $(INSTALL) %s $(DESTDIR)$(libdir)\n", lib_name
519				print  ""
520				print  "uninstall \\"
521				print  "uninstall.libs \\"
522				printf "uninstall.%s ::\n", trim_suffix(name)
523				printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
524				printf "\t-@$(LIBTOOL_UNINSTALL) rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
525			}
526			else
527			{
528				end_name = lib_name;
529				printf "../lib/%s : $(%s_OBJS)\n", lib_name, OBJS
530				# workaround: binutils' ranlib tries to be clever with
531				# timestamps, by pretending its update took no time, confusing
532				# the make utility.
533				if ( ReLink != "yes" ) {
534					printf "\t@sleep 1\n"
535				}
536				printf "\t$(%sAR) $(%sARFLAGS) $@ $?\n", TOOL_PREFIX, TOOL_PREFIX;
537				printf "\t$(RANLIB) $@\n"
538				if ( host == "vxworks" )
539				{
540					printf "\t$(LD) $(LD_OPTS) $? -o $(@:.a=$o)\n"
541				}
542				print  ""
543				print  "install \\"
544				print  "install.libs \\"
545				printf "install.%s :: $(DESTDIR)$(libdir) ../lib/%s\n", name, lib_name
546				printf "\t@echo installing ../lib/%s as $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
547				printf "\t$(INSTALL_DATA) ../lib/%s $(DESTDIR)$(libdir)/%s\n", lib_name, lib_name
548				if ( overwrite == "yes" && lib_name == "libncurses.a" )
549				{
550					printf "\t@echo linking libcurses.a to libncurses.a\n"
551					printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
552					printf "\t(cd $(DESTDIR)$(libdir) && "
553					symlink("libncurses.a", "libcurses.a")
554					printf ")\n"
555				}
556				if ( ReRanlib == "yes" )
557				{
558					printf "\t$(RANLIB) $(DESTDIR)$(libdir)/%s\n", lib_name
559				}
560				if ( host == "vxworks" )
561				{
562					printf "\t@echo installing ../lib/lib%s$o as $(DESTDIR)$(libdir)/lib%s$o\n", name, name
563					printf "\t$(INSTALL_DATA) ../lib/lib%s$o $(DESTDIR)$(libdir)/lib%s$o\n", name, name
564				}
565				print  ""
566				print  "uninstall \\"
567				print  "uninstall.libs \\"
568				printf "uninstall.%s ::\n", name
569				printf "\t@echo uninstalling $(DESTDIR)$(libdir)/%s\n", lib_name
570				printf "\t-@rm -f $(DESTDIR)$(libdir)/%s\n", lib_name
571				if ( overwrite == "yes" && lib_name == "libncurses.a" )
572				{
573					printf "\t@echo linking libcurses.a to libncurses.a\n"
574					printf "\t-@rm -f $(DESTDIR)$(libdir)/libcurses.a\n"
575				}
576				if ( host == "vxworks" )
577				{
578					printf "\t@echo uninstalling $(DESTDIR)$(libdir)/lib%s$o\n", name
579					printf "\t-@rm -f $(DESTDIR)$(libdir)/lib%s$o\n", name
580				}
581			}
582			print ""
583			print "clean ::"
584			removelinks("../lib");
585			print ""
586			print "mostlyclean::"
587			printf "\t-rm -f $(%s_OBJS)\n", OBJS
588			if ( MODEL == "LIBTOOL" ) {
589				printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
590			}
591		}
592		else if ( found == 2 )
593		{
594			print ""
595			print "mostlyclean::"
596			printf "\t-rm -f $(%s_OBJS)\n", OBJS
597			if ( MODEL == "LIBTOOL" ) {
598				printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
599			}
600			print ""
601			print "clean ::"
602			printf "\t-rm -f $(%s_OBJS)\n", OBJS
603			if ( MODEL == "LIBTOOL" ) {
604				printf "\t-$(LIBTOOL_CLEAN) rm -f $(%s_OBJS:$o=.lo)\n", OBJS
605			}
606		}
607	}
608# vile:ts=4 sw=4
609