micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 1 | # $Id: mk-hdr.awk,v 1.8 2021/06/17 21:20:30 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 2 | ############################################################################## |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 3 | # Copyright 2020,2021 Thomas E. Dickey # |
| 4 | # Copyright 2007-2010,2013 Free Software Foundation, Inc. # |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 42 | function in_subset(value) { |
| 43 | value = " " value " "; |
| 44 | check = subset; |
| 45 | gsub("[+]", " ", check); |
| 46 | check = " " check " "; |
| 47 | return index(check,value); |
| 48 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | BEGIN { |
| 50 | found = 0 |
| 51 | using = 1 |
| 52 | count = 0 |
| 53 | } |
| 54 | /^@/ { |
| 55 | using = 0 |
| 56 | if (subset == "none") { |
| 57 | using = 1 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 58 | } else if (in_subset($2) > 0) { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 59 | using = 1 |
| 60 | } else { |
| 61 | using = 0 |
| 62 | } |
| 63 | } |
| 64 | /^[@#]/ { |
| 65 | next |
| 66 | } |
| 67 | { |
| 68 | if (using && NF != 0) { |
| 69 | if (found == 0) { |
| 70 | print "" |
| 71 | print "# generated by mk-hdr.awk" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 72 | printf "# subset: %s\n", subset |
| 73 | printf "# compat: %s\n", compat |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 74 | print "" |
| 75 | found = 1 |
| 76 | } |
| 77 | data[count] = $1 |
| 78 | count = count + 1 |
| 79 | } |
| 80 | } |
| 81 | END { |
| 82 | if ( count > 0 ) |
| 83 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 84 | print "${INCLUDEDIR} :" |
| 85 | print " mkdir -p $@" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 86 | print "" |
| 87 | print "install \\" |
| 88 | print "install.libs \\" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 89 | print "install.includes :: ${AUTO_SRC} ${INCLUDEDIR} \\" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 90 | |
| 91 | for (i = 0; i < count - 1; ++i) { |
| 92 | printf " %s \\\n", data[i] |
| 93 | } |
| 94 | printf " %s\n", data[count - 1] |
| 95 | |
| 96 | for (i = 0; i < count; ++i) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 97 | printf " @ (cd ${INCLUDEDIR} && rm -f %s) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} %s\n", basename(data[i]), data[i] |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 98 | if (data[i] == "curses.h" && compat == "yes") { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 99 | printf " @ (cd ${INCLUDEDIR} && rm -f ncurses.h && ${LN_S} %s ncurses.h)\n", data[i] |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | print "" |
| 103 | print "uninstall \\" |
| 104 | print "uninstall.libs \\" |
| 105 | print "uninstall.includes ::" |
| 106 | |
| 107 | for (i = 0; i < count; ++i) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 108 | printf " -@ (cd ${INCLUDEDIR} && rm -f %s)\n", basename(data[i]) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 109 | if (data[i] == "curses.h" && compat == "yes") { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 110 | printf " -@ (cd ${INCLUDEDIR} && rm -f ncurses.h)\n" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | # vile:ts=4 sw=4 |