]> ncurses.scripts.mit.edu Git - ncurses.git/blob - mk-hdr.awk
ncurses 6.2 - patch 20200816
[ncurses.git] / mk-hdr.awk
1 # $Id: mk-hdr.awk,v 1.5 2020/02/02 23:34:34 tom Exp $
2 ##############################################################################
3 # Copyright 2020 Thomas E. Dickey                                            #
4 # Copyright 2007-2010,2013 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      2007
32 #
33 # Generate install/uninstall rules for header files
34 # Variables:
35 #       subset    ("none", "base", "base+ext_funcs" or "termlib", etc.)
36 #       compat    ("yes" or "no", flag to add link to curses.h
37 #
38 function basename(path) {
39         sub(/^.*\//,"",path)
40         return path;
41 }
42 BEGIN   {
43                 found = 0
44                 using = 1
45                 count = 0
46         }
47         /^@/ {
48                 using = 0
49                 if (subset == "none") {
50                         using = 1
51                 } else if (index(subset,$2) > 0) {
52                         using = 1
53                 } else {
54                         using = 0
55                 }
56         }
57         /^[@#]/ {
58                 next
59         }
60         {
61                 if (using && NF != 0) {
62                         if (found == 0) {
63                                 print  ""
64                                 print  "# generated by mk-hdr.awk"
65                                 printf "#  subset:     %s\n", subset 
66                                 printf "#  compat:     %s\n", compat 
67                                 print  ""
68                                 found = 1
69                         }
70                         data[count] = $1
71                         count = count + 1
72                 }
73         }
74 END     {
75                 if ( count > 0 )
76                 {
77                         print "${INCLUDEDIR} :"
78                         print " mkdir -p $@"
79                         print ""
80                         print "install \\"
81                         print "install.libs \\"
82                         print "install.includes :: ${AUTO_SRC} ${INCLUDEDIR} \\"
83
84                         for (i = 0; i < count - 1; ++i) {
85                                 printf "                %s \\\n", data[i]
86                         }
87                         printf "                %s\n", data[count - 1]
88
89                         for (i = 0; i < count; ++i) {
90                                 printf "        @ (cd ${INCLUDEDIR} && rm -f %s) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} %s\n", basename(data[i]), data[i]
91                                 if (data[i] == "curses.h" && compat == "yes") {
92                                         printf "        @ (cd ${INCLUDEDIR} && rm -f ncurses.h && ${LN_S} %s ncurses.h)\n", data[i]
93                                 }
94                         }
95                         print ""
96                         print "uninstall \\"
97                         print "uninstall.libs \\"
98                         print "uninstall.includes ::"
99
100                         for (i = 0; i < count; ++i) {
101                                 printf "        -@ (cd ${INCLUDEDIR} && rm -f %s)\n", basename(data[i])
102                                 if (data[i] == "curses.h" && compat == "yes") {
103                                         printf "        -@ (cd ${INCLUDEDIR} && rm -f ncurses.h)\n"
104                                 }
105                         }
106                 }
107         }
108 # vile:ts=4 sw=4