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