2014-03-01 00:40:26 +00:00
|
|
|
# $Id: mk-0th.awk,v 1.22 2012/06/30 20:56:11 tom Exp $
|
1999-08-24 01:06:48 +00:00
|
|
|
##############################################################################
|
2014-03-01 00:40:26 +00:00
|
|
|
# Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. #
|
1999-08-24 01:06:48 +00:00
|
|
|
# #
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a #
|
|
|
|
# copy of this software and associated documentation files (the "Software"), #
|
|
|
|
# to deal in the Software without restriction, including without limitation #
|
|
|
|
# the rights to use, copy, modify, merge, publish, distribute, distribute #
|
|
|
|
# with modifications, sublicense, and/or sell copies of the Software, and to #
|
|
|
|
# permit persons to whom the Software is furnished to do so, subject to the #
|
|
|
|
# following conditions: #
|
|
|
|
# #
|
|
|
|
# The above copyright notice and this permission notice shall be included in #
|
|
|
|
# all copies or substantial portions of the Software. #
|
|
|
|
# #
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
|
|
|
|
# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
|
|
|
|
# DEALINGS IN THE SOFTWARE. #
|
|
|
|
# #
|
|
|
|
# Except as contained in this notice, the name(s) of the above copyright #
|
|
|
|
# holders shall not be used in advertising or otherwise to promote the sale, #
|
|
|
|
# use or other dealings in this Software without prior written #
|
|
|
|
# authorization. #
|
|
|
|
##############################################################################
|
|
|
|
#
|
2014-02-28 19:18:07 +00:00
|
|
|
# Author: Thomas E. Dickey 1996-on
|
1999-08-24 01:06:48 +00:00
|
|
|
#
|
|
|
|
# Generate list of sources for a library, together with lint/lintlib rules
|
|
|
|
#
|
|
|
|
# Variables:
|
2002-05-21 05:30:25 +00:00
|
|
|
# libname (library name, e.g., "ncurses", "panel", "forms", "menus")
|
2007-01-20 07:32:02 +00:00
|
|
|
# subsets (is used here to decide if wide-character code is used)
|
2014-03-01 00:40:26 +00:00
|
|
|
# ticlib (library name for libtic, e.g., "tic")
|
|
|
|
# termlib (library name for libtinfo, e.g., "tinfo")
|
1999-08-24 01:06:48 +00:00
|
|
|
#
|
2014-03-01 00:40:26 +00:00
|
|
|
function make_lintlib(name,sources) {
|
|
|
|
print ""
|
|
|
|
print "clean ::"
|
|
|
|
printf "\trm -f llib-l%s.*\n", name
|
|
|
|
print ""
|
|
|
|
print "realclean ::"
|
|
|
|
printf "\trm -f llib-l%s\n", name
|
|
|
|
print ""
|
|
|
|
printf "llib-l%s : %s\n", name, sources
|
|
|
|
printf "\tcproto -a -l -DNCURSES_ENABLE_STDBOOL_H=0 -DLINT $(CPPFLAGS) %s >$@\n", sources
|
|
|
|
print ""
|
|
|
|
print "lintlib ::"
|
|
|
|
printf "\tsh $(srcdir)/../misc/makellib %s $(CPPFLAGS)\n", name
|
|
|
|
print ""
|
|
|
|
print "lint ::"
|
|
|
|
printf "\t$(LINT) $(LINT_OPTS) $(CPPFLAGS) %s $(LINT_LIBS)\n", sources
|
|
|
|
}
|
|
|
|
|
|
|
|
# A blank in "subsets" indicates a split-off of the library into a separate
|
|
|
|
# file, e.g., for libtic or libtinfo. They are all logical parts of the same
|
|
|
|
# library.
|
|
|
|
function which_library() {
|
|
|
|
if ( ( which == "ticlib" ) && ( subsets ~ /ticlib / ) ) {
|
|
|
|
return ticlib;
|
|
|
|
} else if ( ( which == "termlib" || which == "ext_tinfo" ) && ( subsets ~ /[[:space:]]base/ ) ) {
|
|
|
|
return termlib;
|
|
|
|
} else {
|
|
|
|
return libname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_list(name, len, list) {
|
|
|
|
if ( len > 0 ) {
|
|
|
|
printf "\n%s_SRC =", toupper(name);
|
|
|
|
for (n = 0; n < len; ++n)
|
|
|
|
printf " \\\n\t%s", list[n];
|
|
|
|
print "";
|
|
|
|
make_lintlib(name, sprintf("$(%s_SRC)", toupper(name)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-24 01:06:48 +00:00
|
|
|
BEGIN {
|
2014-02-28 19:18:07 +00:00
|
|
|
which = libname;
|
2007-01-20 07:32:02 +00:00
|
|
|
using = 0;
|
1999-08-24 01:06:48 +00:00
|
|
|
found = 0;
|
2014-03-01 00:40:26 +00:00
|
|
|
count_ticlib = 0;
|
|
|
|
count_termlib = 0;
|
|
|
|
count_library = 0;
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
2014-02-28 19:18:07 +00:00
|
|
|
/^@/ {
|
|
|
|
which = $0;
|
2014-03-01 00:40:26 +00:00
|
|
|
sub(/^@[[:blank:]]+/, "", which);
|
|
|
|
sub(/[[:blank:]]+$/, "", which);
|
2014-02-28 19:18:07 +00:00
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
!/^[@#]/ {
|
2007-01-20 07:32:02 +00:00
|
|
|
if (using == 0)
|
|
|
|
{
|
|
|
|
print ""
|
|
|
|
print "# generated by mk-0th.awk"
|
|
|
|
printf "# libname: %s\n", libname
|
|
|
|
printf "# subsets: %s\n", subsets
|
2014-03-01 00:40:26 +00:00
|
|
|
if ( libname ~ /ncurses/ ) {
|
|
|
|
printf "# ticlib: %s\n", ticlib
|
|
|
|
printf "# termlib: %s\n", termlib
|
|
|
|
}
|
2007-01-20 07:32:02 +00:00
|
|
|
print ""
|
|
|
|
print ".SUFFIXES: .c .cc .h .i .ii"
|
|
|
|
print ".c.i :"
|
|
|
|
printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
|
|
|
|
print ".cc.ii :"
|
|
|
|
printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
|
|
|
|
print ".h.i :"
|
|
|
|
printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
|
|
|
|
print ""
|
|
|
|
using = 1;
|
|
|
|
}
|
2014-02-28 19:18:07 +00:00
|
|
|
if (which ~ /port_/ )
|
|
|
|
{
|
|
|
|
# skip win32 source
|
|
|
|
}
|
|
|
|
else if ( $0 != "" && $1 != "link_test" )
|
1999-08-24 01:06:48 +00:00
|
|
|
{
|
|
|
|
if ( found == 0 )
|
|
|
|
{
|
2002-05-21 05:30:25 +00:00
|
|
|
if ( subsets ~ /widechar/ )
|
|
|
|
widechar = 1;
|
|
|
|
else
|
|
|
|
widechar = 0;
|
1999-08-24 01:06:48 +00:00
|
|
|
printf "C_SRC ="
|
|
|
|
if ( $2 == "lib" )
|
|
|
|
found = 1
|
|
|
|
else
|
|
|
|
found = 2
|
|
|
|
}
|
2002-05-21 05:30:25 +00:00
|
|
|
if ( libname == "c++" || libname == "c++w" ) {
|
2014-03-01 00:40:26 +00:00
|
|
|
srcname = sprintf("%s/%s.cc", $3, $1);
|
|
|
|
printf " \\\n\t%s", srcname;
|
2002-05-21 05:30:25 +00:00
|
|
|
} else if ( widechar == 1 || $3 != "$(wide)" ) {
|
2014-03-01 00:40:26 +00:00
|
|
|
srcname = sprintf("%s/%s.c", $3, $1);
|
|
|
|
printf " \\\n\t%s", srcname;
|
|
|
|
if ( which_library() == libname ) {
|
|
|
|
list_library[count_library++] = srcname;
|
|
|
|
} else if ( which_library() == ticlib ) {
|
|
|
|
list_ticlib[count_ticlib++] = srcname;
|
|
|
|
} else {
|
|
|
|
list_termlib[count_termlib++] = srcname;
|
|
|
|
}
|
2002-05-21 05:30:25 +00:00
|
|
|
}
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
END {
|
|
|
|
print ""
|
|
|
|
if ( found == 1 )
|
|
|
|
{
|
|
|
|
print ""
|
2014-03-01 00:40:26 +00:00
|
|
|
printf "# Producing llib-l%s is time-consuming, so there's no direct-dependency for\n", libname;
|
|
|
|
print "# it in the lintlib rule. We'll only remove in the cleanest setup.";
|
|
|
|
show_list(libname, count_library, list_library);
|
|
|
|
show_list(ticlib, count_ticlib, list_ticlib);
|
|
|
|
show_list(termlib, count_termlib, list_termlib);
|
1999-08-24 01:06:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print ""
|
|
|
|
print "lintlib :"
|
|
|
|
print "\t@echo no action needed"
|
|
|
|
}
|
|
|
|
}
|
2014-03-01 00:40:26 +00:00
|
|
|
# vile:ts=4 sw=4
|