ncurses 6.0 - patch 20160611
[ncurses.git] / mk-0th.awk
index fe91cca689f65883f5eb2fe3e3a9f72a294d722a..6a01feded914e2eb265cf4319f07eea5d28175bf 100644 (file)
@@ -1,6 +1,6 @@
-# $Id: mk-0th.awk,v 1.17 2005/01/22 16:31:40 tom Exp $
+# $Id: mk-0th.awk,v 1.22 2012/06/30 20:56:11 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2010,2012 Free Software Foundation, Inc.                #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
 # authorization.                                                             #
 ##############################################################################
 #
-# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
+# Author: Thomas E. Dickey 1996-on
 #
 # Generate list of sources for a library, together with lint/lintlib rules
 #
 # Variables:
 #      libname (library name, e.g., "ncurses", "panel", "forms", "menus")
 #      subsets (is used here to decide if wide-character code is used)
+#      ticlib (library name for libtic, e.g., "tic")
+#      termlib (library name for libtinfo, e.g., "tinfo")
 #
+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)));
+       }
+}
+
 BEGIN  {
+               which = libname;
                using = 0;
                found = 0;
+               count_ticlib = 0;
+               count_termlib = 0;
+               count_library = 0;
+       }
+       /^@/ {
+               which = $0;
+               sub(/^@[[:blank:]]+/, "", which);
+               sub(/[[:blank:]]+$/, "", which);
        }
        !/^[@#]/ {
                if (using == 0)
@@ -46,6 +98,10 @@ BEGIN        {
                        print  "# generated by mk-0th.awk"
                        printf "#   libname:    %s\n", libname
                        printf "#   subsets:    %s\n", subsets
+                       if ( libname ~ /ncurses/ ) {
+                               printf "#   ticlib:     %s\n", ticlib
+                               printf "#   termlib:    %s\n", termlib
+                       }
                        print  ""
                        print  ".SUFFIXES: .c .cc .h .i .ii"
                        print  ".c.i :"
@@ -57,7 +113,11 @@ BEGIN       {
                        print  ""
                        using = 1;
                }
-               if ( $0 != "" && $1 != "link_test" )
+               if (which ~ /port_/ )
+               {
+                       # skip win32 source
+               }
+               else if ( $0 != "" && $1 != "link_test" )
                {
                        if ( found == 0 )
                        {
@@ -72,9 +132,18 @@ BEGIN       {
                                        found = 2
                        }
                        if ( libname == "c++" || libname == "c++w" ) {
-                               printf " \\\n\t%s/%s.cc", $3, $1
+                               srcname = sprintf("%s/%s.cc", $3, $1);
+                               printf " \\\n\t%s", srcname;
                        } else if ( widechar == 1 || $3 != "$(wide)" ) {
-                               printf " \\\n\t%s/%s.c", $3, $1
+                               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;
+                               }
                        }
                }
        }
@@ -83,22 +152,11 @@ END        {
                if ( found == 1 )
                {
                        print  ""
-                       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."
-                       print  "clean ::"
-                       printf "\trm -f llib-l%s.*\n", libname
-                       print  ""
-                       print  "realclean ::"
-                       printf "\trm -f llib-l%s\n", libname
-                       print  ""
-                       printf "llib-l%s : $(C_SRC)\n", libname
-                       printf "\tcproto -a -l -DNCURSES_ENABLE_STDBOOL_H=0 -DLINT $(CPPFLAGS) $(C_SRC) >$@\n"
-                       print  ""
-                       print  "lintlib :"
-                       printf "\tsh $(srcdir)/../misc/makellib %s $(CPPFLAGS)", libname
-                       print ""
-                       print "lint :"
-                       print "\t$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(C_SRC) $(LINT_LIBS)"
+                       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);
                }
                else
                {
@@ -107,3 +165,4 @@ END {
                        print  "\t@echo no action needed"
                }
        }
+# vile:ts=4 sw=4