]> ncurses.scripts.mit.edu Git - ncurses.git/blob - mk-0th.awk
ncurses 5.8 - patch 20110305
[ncurses.git] / mk-0th.awk
1 # $Id: mk-0th.awk,v 1.18 2010/01/09 21:45:41 tom Exp $
2 ##############################################################################
3 # Copyright (c) 1998-2005,2010 Free Software Foundation, Inc.                #
4 #                                                                            #
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:                                                      #
12 #                                                                            #
13 # The above copyright notice and this permission notice shall be included in #
14 # all copies or substantial portions of the Software.                        #
15 #                                                                            #
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.                                                  #
23 #                                                                            #
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               #
27 # authorization.                                                             #
28 ##############################################################################
29 #
30 # Author: Thomas E. Dickey 1996-on
31 #
32 # Generate list of sources for a library, together with lint/lintlib rules
33 #
34 # Variables:
35 #       libname (library name, e.g., "ncurses", "panel", "forms", "menus")
36 #       subsets (is used here to decide if wide-character code is used)
37 #
38 BEGIN   {
39                 which = libname;
40                 using = 0;
41                 found = 0;
42         }
43         /^@/ {
44                 which = $0;
45         }
46         !/^[@#]/ {
47                 if (using == 0)
48                 {
49                         print  ""
50                         print  "# generated by mk-0th.awk"
51                         printf "#   libname:    %s\n", libname
52                         printf "#   subsets:    %s\n", subsets
53                         print  ""
54                         print  ".SUFFIXES: .c .cc .h .i .ii"
55                         print  ".c.i :"
56                         printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
57                         print  ".cc.ii :"
58                         printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
59                         print  ".h.i :"
60                         printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
61                         print  ""
62                         using = 1;
63                 }
64                 if (which ~ /port_/ )
65                 {
66                         # skip win32 source
67                 }
68                 else if ( $0 != "" && $1 != "link_test" )
69                 {
70                         if ( found == 0 )
71                         {
72                                 if ( subsets ~ /widechar/ )
73                                         widechar = 1;
74                                 else
75                                         widechar = 0;
76                                 printf "C_SRC ="
77                                 if ( $2 == "lib" )
78                                         found = 1
79                                 else
80                                         found = 2
81                         }
82                         if ( libname == "c++" || libname == "c++w" ) {
83                                 printf " \\\n\t%s/%s.cc", $3, $1
84                         } else if ( widechar == 1 || $3 != "$(wide)" ) {
85                                 printf " \\\n\t%s/%s.c", $3, $1
86                         }
87                 }
88         }
89 END     {
90                 print  ""
91                 if ( found == 1 )
92                 {
93                         print  ""
94                         printf "# Producing llib-l%s is time-consuming, so there's no direct-dependency for\n", libname
95                         print  "# it in the lintlib rule.  We'll only remove in the cleanest setup."
96                         print  "clean ::"
97                         printf "\trm -f llib-l%s.*\n", libname
98                         print  ""
99                         print  "realclean ::"
100                         printf "\trm -f llib-l%s\n", libname
101                         print  ""
102                         printf "llib-l%s : $(C_SRC)\n", libname
103                         printf "\tcproto -a -l -DNCURSES_ENABLE_STDBOOL_H=0 -DLINT $(CPPFLAGS) $(C_SRC) >$@\n"
104                         print  ""
105                         print  "lintlib :"
106                         printf "\tsh $(srcdir)/../misc/makellib %s $(CPPFLAGS)", libname
107                         print ""
108                         print "lint :"
109                         print "\t$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(C_SRC) $(LINT_LIBS)"
110                 }
111                 else
112                 {
113                         print  ""
114                         print  "lintlib :"
115                         print  "\t@echo no action needed"
116                 }
117         }