1#! /bin/sh 2# $Id: MKncurses_def.sh,v 1.5 2022/07/16 17:03:59 tom Exp $ 3############################################################################## 4# Copyright 2020,2022 Thomas E. Dickey # 5# Copyright 2000,2003 Free Software Foundation, Inc. # 6# # 7# Permission is hereby granted, free of charge, to any person obtaining a # 8# copy of this software and associated documentation files (the "Software"), # 9# to deal in the Software without restriction, including without limitation # 10# the rights to use, copy, modify, merge, publish, distribute, distribute # 11# with modifications, sublicense, and/or sell copies of the Software, and to # 12# permit persons to whom the Software is furnished to do so, subject to the # 13# following conditions: # 14# # 15# The above copyright notice and this permission notice shall be included in # 16# all copies or substantial portions of the Software. # 17# # 18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 21# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 24# DEALINGS IN THE SOFTWARE. # 25# # 26# Except as contained in this notice, the name(s) of the above copyright # 27# holders shall not be used in advertising or otherwise to promote the sale, # 28# use or other dealings in this Software without prior written # 29# authorization. # 30############################################################################## 31# 32# MKncurses_def.sh -- generate fallback definitions for ncurses_cfg.h 33# 34# Author: Thomas E. Dickey 2000 35# 36# Given the choice between constructs such as 37# 38# #if defined(foo) && foo 39# #if foo 40# 41# we chose the latter. It is guaranteed by the language standard, and there 42# appear to be no broken compilers that do not honor that detail. But some 43# people want to use gcc's -Wundef option (corresponding to one of the less 44# useful features in Watcom's compiler) to check for misspellings. So we 45# generate a set of fallback definitions to quiet the warnings without making 46# the code ugly. 47# 48DEFS="${1-ncurses_defs}" 49cat <<EOF 50/* 51 * This file is generated by $0 52 */ 53 54#ifndef NC_DEFINE_H 55#define NC_DEFINE_H 1 56 57EOF 58 59"${AWK-awk}" <"$DEFS" ' 60!/^[@#]/ { 61 if ( NF == 1 ) 62 { 63 print "#ifndef", $1 64 print "#define", $1, "0" 65 print "#endif" 66 print "" 67 } else if ( NF != 0 ) { 68 print "#ifndef", $1 69 printf "#define" 70 for (n = 1; n <= NF; n++) { 71 printf " %s", $n 72 } 73 print "" 74 print "#endif" 75 print "" 76 } 77} 78END { 79print "#endif /* NC_DEFINE_H */" 80 } 81' 82